Ejemplo n.º 1
0
    def test_otherwise_raise_error(self):
        data = {
            "Sample": ["AAA", "BBB"],
        }
        df = pd.DataFrame(data)

        message = "Sample name uses wrong format."
        with pytest.raises(ValueError, match=message):
            create_sample_cols(df["Sample"])
Ejemplo n.º 2
0
    def test_raises_error_if_type_has_multiple_letters(self):
        data = {
            "Sample": ["1-U1h-1tt-3-a"],
        }
        df = pd.DataFrame(data)

        message = "Sample name uses wrong format."
        with pytest.raises(ValueError, match=message):
            create_sample_cols(df["Sample"])
Ejemplo n.º 3
0
    def test_raises_error_if_hole_is_a_number(self):
        data = {
            "Sample": ["1-U11-2t-3-a"],
        }
        df = pd.DataFrame(data)

        message = "Sample name uses wrong format."
        with pytest.raises(ValueError, match=message):
            create_sample_cols(df["Sample"])
Ejemplo n.º 4
0
    def test_raises_error_if_site_ends_with_letters(self):
        data = {
            "Sample": ["1-Ush-2t-3-a"],
        }
        df = pd.DataFrame(data)

        message = "Sample name uses wrong format."
        with pytest.raises(ValueError, match=message):
            create_sample_cols(df["Sample"])
Ejemplo n.º 5
0
    def test_rejects_exp_string(self):
        data = {
            "Sample": ["1", "10"],
        }
        df = pd.DataFrame(data)

        message = "Sample name uses wrong format."
        with pytest.raises(ValueError, match=message):
            df = create_sample_cols(df["Sample"])
Ejemplo n.º 6
0
    def test_returns_none_when_input_is_No_data_this_hole(self):
        data = {
            "Sample": ["No data this hole"],
        }
        df = pd.DataFrame(data)

        data = {
            "Exp": [None],
            "Site": [None],
            "Hole": [None],
            "Core": [None],
            "Type": [None],
            "Section": [None],
            "A/W": [None],
        }
        expected = pd.DataFrame(data)

        df = create_sample_cols(df["Sample"])
        assert_frame_equal(df, expected)
Ejemplo n.º 7
0
    def test_ignores_hash_symbol_element_in_sample_name(self):
        data = {
            "Sample": ["349-U1431E-7R-1-#1-A", "349-U1431E-7R-1-#1"],
        }
        df = pd.DataFrame(data)

        data = {
            "Exp": ["349", "349"],
            "Site": ["U1431", "U1431"],
            "Hole": ["E", "E"],
            "Core": ["7", "7"],
            "Type": ["R", "R"],
            "Section": ["1", "1"],
            "A/W": ["A", None],
        }
        expected = pd.DataFrame(data)

        df = create_sample_cols(df["Sample"])
        assert_frame_equal(df, expected)
Ejemplo n.º 8
0
    def test_ignores_ending_interval(self):
        data = {
            "Sample": ["1-U1h-2t-3, 0-20", "10-U2H-20T-3"],
        }
        df = pd.DataFrame(data)

        data = {
            "Exp": ["1", "10"],
            "Site": ["U1", "U2"],
            "Hole": ["h", "H"],
            "Core": ["2", "20"],
            "Type": ["t", "T"],
            "Section": ["3", "3"],
            "A/W": [None, None],
        }
        expected = pd.DataFrame(data)

        df = create_sample_cols(df["Sample"])
        assert_frame_equal(df, expected)
Ejemplo n.º 9
0
    def test_accepts_exp_site_hole_string(self):
        data = {
            "Sample": ["1-U1h", "10-U2H"],
        }
        df = pd.DataFrame(data)

        data = {
            "Exp": ["1", "10"],
            "Site": ["U1", "U2"],
            "Hole": ["h", "H"],
            "Core": [None, None],
            "Type": [None, None],
            "Section": [None, None],
            "A/W": [None, None],
        }
        expected = pd.DataFrame(data)

        df = create_sample_cols(df["Sample"])
        assert_frame_equal(df, expected)
Ejemplo n.º 10
0
    def test_accepts_exp_site_hole_core_type_section_string(self):
        data = {
            "Label ID": ["1-U1h-2t-3", "10-U2H-20T-3"],
        }
        df = pd.DataFrame(data)

        data = {
            "Exp": ["1", "10"],
            "Site": ["U1", "U2"],
            "Hole": ["h", "H"],
            "Core": ["2", "20"],
            "Type": ["t", "T"],
            "Section": ["3", "3"],
            "A/W": [None, None],
        }
        expected = pd.DataFrame(data)

        df = create_sample_cols(df["Label ID"])
        assert_frame_equal(df, expected)
Ejemplo n.º 11
0
    def test_handles_missing_type(self):
        data = {
            "Sample": ["1-U1h-11-3-a"],
        }
        df = pd.DataFrame(data)

        data = {
            "Exp": ["1"],
            "Site": ["U1"],
            "Hole": ["h"],
            "Core": ["11"],
            "Type": [None],
            "Section": ["3"],
            "A/W": ["a"],
        }
        expected = pd.DataFrame(data)

        df = create_sample_cols(df["Sample"])
        assert_frame_equal(df, expected)
Ejemplo n.º 12
0
    def test_extracts_parts_from_exp_site_hole_core_type_section_aw_string(
            self):
        data = {
            "Label ID": ["1-U1h-2t-3-a", "10-U20H-20T-Sec-4AA"],
        }
        df = pd.DataFrame(data)

        data = {
            "Exp": ["1", "10"],
            "Site": ["U1", "U20"],
            "Hole": ["h", "H"],
            "Core": ["2", "20"],
            "Type": ["t", "T"],
            "Section": ["3", "Sec"],
            "A/W": ["a", "4AA"],
        }
        expected = pd.DataFrame(data)

        df = create_sample_cols(df["Label ID"])
        assert_frame_equal(df, expected)