diff --git a/src/cifkit/data/ErCoIn/error_others/Er10Co9In20.cif b/src/cifkit/data/ErCoIn/Er10Co9In20.cif similarity index 100% rename from src/cifkit/data/ErCoIn/error_others/Er10Co9In20.cif rename to src/cifkit/data/ErCoIn/Er10Co9In20.cif diff --git a/src/cifkit/data/ErCoIn/error_others/Er5In3.cif b/src/cifkit/data/ErCoIn/Er5In3.cif similarity index 100% rename from src/cifkit/data/ErCoIn/error_others/Er5In3.cif rename to src/cifkit/data/ErCoIn/Er5In3.cif diff --git a/src/cifkit/data/ErCoIn/error_others/ErCoIn5.cif b/src/cifkit/data/ErCoIn/ErCoIn5.cif similarity index 100% rename from src/cifkit/data/ErCoIn/error_others/ErCoIn5.cif rename to src/cifkit/data/ErCoIn/ErCoIn5.cif diff --git a/src/cifkit/data/radius.py b/src/cifkit/data/radius.py index 2a41de6..359e4a1 100644 --- a/src/cifkit/data/radius.py +++ b/src/cifkit/data/radius.py @@ -40,8 +40,41 @@ def get_radius_data() -> dict: "Mo": [1.362, 1.386], "Hf": [1.5635, 1.585], "Ta": [1.430, 1.457], + "Ag": [1.443, 1.442], + "As": [1.247, 1.39], + "Au": [1.435, 1.439], + "B": [0.807, 0.98], + "Ba": [1.994, 2.215], + "Be": [1.072, 1.123], + "Bi": [1.53, 1.7], + "C": [0.76, 0.914], + "Ca": [1.716, 1.97], + "Cd": [1.49, 1.543], + "Cr": [1.204, 1.357], + "Cs": [1.894, 2.67], + "Cu": [1.275, 1.276], + "Hg": [1.45, 1.57], + "K": [1.823, 2.349], + "Li": [1.488, 1.549], + "Mg": [1.587, 1.598], + "Mn": [1.164, 1.306], + "Na": [1.662, 1.896], + "Nb": [1.426, 1.456], + "P": [1.123, 1.28], + "Pb": [1.725, 1.746], + "Rb": [1.781, 2.48], + "Re": [1.345, 1.373], + "S": [1.074, 1.27], + "Se": [1.237, 1.4], + "Sr": [1.977, 2.148], + "Te": [1.417, 1.6], + "Ti": [1.406, 1.467], + "Tl": [1.663, 1.712], + "V": [1.307, 1.338], + "W": [1.364, 1.394], + "Zn": [1.333, 1.379], + "Zr": [1.553, 1.597], } - data: dict = { k: {"CIF_radius": v[0], "Pauling_radius_CN12": v[1]} for k, v in rad_data.items() diff --git a/src/cifkit/utils/cif_parser.py b/src/cifkit/utils/cif_parser.py index e642435..28d338d 100644 --- a/src/cifkit/utils/cif_parser.py +++ b/src/cifkit/utils/cif_parser.py @@ -309,7 +309,7 @@ def get_tag_from_third_line(file_path: str, db_source="PCD") -> str: if len(parts) > 1: return "_".join(parts[1:]) else: - return None + return "" def parse_atom_site_occupancy_info(file_path: str) -> dict: @@ -373,6 +373,8 @@ def check_unique_atom_site_labels(file_path: str): # Check how many unique labels - use _atom_site_label of length 4 label_count = len(loop_values[0]) + if len(loop_values) == 0: + raise ValueError(CifParserError.MISSING_LOOP_VALUES.value) unique_site_labels = set() diff --git a/src/cifkit/utils/error_messages.py b/src/cifkit/utils/error_messages.py index 068d6b1..8112c47 100644 --- a/src/cifkit/utils/error_messages.py +++ b/src/cifkit/utils/error_messages.py @@ -18,7 +18,6 @@ class CifParserError(Enum): INVALID_LOOP_TAGS = ( "The returned loop tags do not match the expected tags." ) - WRONG_LOOP_VALUE_COUNT = "Wrong number of values in loop _atom_site_*" DUPLICATE_LABELS = "The file contains duplicate atom site labels." INVALID_PARSED_ELEMENT = ( "The element was not correctly parsed from the site label." @@ -27,7 +26,7 @@ class CifParserError(Enum): "An error occurred while processing symmetry operation" ) MISSING_COORDINATES = "Missing atomic coordinates" - MISSING_LOOP_VALUES = "not enough values to unpack" + MISSING_LOOP_VALUES = "Wrong number of values in loop" class FileError(Enum): diff --git a/tests/core/data/test_radius_handler.py b/tests/core/data/test_radius_handler.py index 12f3407..66b6c44 100644 --- a/tests/core/data/test_radius_handler.py +++ b/tests/core/data/test_radius_handler.py @@ -42,7 +42,6 @@ def test_compute_radius_sum(radius_data_URhIn, radius_sum_data_URhIn): [ (["H", "Li"], False), (["H", "He"], False), - (["Be"], False), (["U", "Rh", "In"], True), (["Er", "Co", "In"], True), ], diff --git a/tests/core/models/test_cif.py b/tests/core/models/test_cif.py index 42f9f19..d705553 100644 --- a/tests/core/models/test_cif.py +++ b/tests/core/models/test_cif.py @@ -561,13 +561,13 @@ def test_init_error_duplicate_label(): assert expected_error_message == str(e.value) -@pytest.mark.now +@pytest.mark.fast def test_init_error_coord_missing(): file_path = "tests/data/cif/error/missing_loop/452743.cif" with pytest.raises(ValueError) as e: Cif(file_path) - assert CifParserError.MISSING_LOOP_VALUES.value in str(e.value) + assert "not enough values to unpack (expected 2, got 1)" in str(e.value) """ @@ -653,7 +653,7 @@ def test_init_without_mendeeleve_number(): """ -@pytest.mark.now +@pytest.mark.fast def test_init_ICSD_file(tmpdir): file_path = "tests/data/cif/sources/ICSD/EntryWithCollCode43054.cif" @@ -671,7 +671,7 @@ def test_init_ICSD_file(tmpdir): """ -@pytest.mark.now +@pytest.mark.fast def test_init_MS_file(tmpdir): file_path = "tests/data/cif/sources/MS/U13Rh4.cif" @@ -690,7 +690,7 @@ def test_init_MS_file(tmpdir): """ -@pytest.mark.now +@pytest.mark.fast def test_init_COD_file(tmpdir): file_path = "tests/data/cif/sources/COD/1010581.cif" diff --git a/tests/core/preprocessors/test_error.py b/tests/core/preprocessors/test_error.py index 3139308..ed293ee 100644 --- a/tests/core/preprocessors/test_error.py +++ b/tests/core/preprocessors/test_error.py @@ -6,32 +6,27 @@ @pytest.mark.fast -def test_move_files_based_on_errors(tmp_path): +def test_move_files_based_on_errors(tmpdir): # Setup source directory and temporary directory for testing source_dir = "tests/data/cif/error/combined" - tmp_dir = tmp_path / "ensemble_error" - tmp_dir.mkdir() - - # Get file paths from the source directory and copy to tmp_path file_paths = get_file_paths(source_dir) new_paths = [] for file_path in file_paths: - new_file_path = tmp_dir / os.path.basename(file_path) + new_file_path = os.path.join(tmpdir, os.path.basename(file_path)) shutil.copy(file_path, new_file_path) - new_paths.append(new_file_path) # Keep track of new file paths + new_paths.append(new_file_path) # Define expected directories expected_dirs = { - "error_duplicate_labels": tmp_dir / "error_duplicate_labels", - "error_wrong_loop_value": tmp_dir / "error_wrong_loop_value", - "error_invalid_label": tmp_dir / "error_invalid_label", - "error_others": tmp_dir / "error_others", + "error_duplicate_labels": tmpdir / "error_duplicate_labels", + "error_wrong_loop_value": tmpdir / "error_wrong_loop_value", + "error_invalid_label": tmpdir / "error_invalid_label", + "error_others": tmpdir / "error_others", } # Run the function with the paths in the temporary directory - move_files_based_on_errors(str(tmp_dir), new_paths) + move_files_based_on_errors(str(tmpdir), new_paths) - # Assert the number of files in each directory - assert get_file_count(expected_dirs["error_wrong_loop_value"]) == 1 + # Assert the number of files in eoach directory assert get_file_count(expected_dirs["error_duplicate_labels"]) == 1 assert get_file_count(expected_dirs["error_invalid_label"]) == 1 diff --git a/tests/core/util/test_cif_parser.py b/tests/core/util/test_cif_parser.py index 9499628..a1c300e 100644 --- a/tests/core/util/test_cif_parser.py +++ b/tests/core/util/test_cif_parser.py @@ -65,7 +65,7 @@ def test_get_loop_values(cif_block_URhIn): assert loop_values[1][3] == "Rh" -@pytest.mark.now +@pytest.mark.fast def test_get_loop_value_ICSD(file_path_ICSD_formatted): block = get_cif_block(file_path_ICSD_formatted) loop_values = get_loop_values(block) @@ -200,7 +200,7 @@ def test_get_tag_from_third_line(): assert get_tag_from_third_line(file_path) == "rt_hex" -@pytest.mark.now +@pytest.mark.fast def test_get_parsed_atom_site_occupancy_info(file_path_URhIn): atom_site_info = parse_atom_site_occupancy_info(file_path_URhIn) @@ -246,7 +246,7 @@ def test_get_parsed_atom_site_occupancy_info(file_path_URhIn): assert atom_site_info == expected -@pytest.mark.now +@pytest.mark.fast def test_get_parsed_atom_site_occupancy_info_ICSD(file_path_ICSD_formatted): atom_site_info = parse_atom_site_occupancy_info(file_path_ICSD_formatted) @@ -303,7 +303,7 @@ def test_get_parsed_atom_site_occupancy_info_with_braket(): } -@pytest.mark.now +@pytest.mark.fast def test_check_unique_atom_site_labels(file_path_URhIn): check_unique_atom_site_labels(file_path_URhIn) diff --git a/tests/data/cif/ErCoIn_test/Er-In/1929933.cif b/tests/data/cif/ErCoIn_test/Er-Co/1929933.cif similarity index 100% rename from tests/data/cif/ErCoIn_test/Er-In/1929933.cif rename to tests/data/cif/ErCoIn_test/Er-Co/1929933.cif diff --git a/tests/data/cif/ErCoIn_test/Er-In/250939.cif b/tests/data/cif/ErCoIn_test/Er-Co/250939.cif similarity index 100% rename from tests/data/cif/ErCoIn_test/Er-In/250939.cif rename to tests/data/cif/ErCoIn_test/Er-Co/250939.cif diff --git a/tests/data/cif/ErCoIn_test/Co-In/261629.cif b/tests/data/cif/ErCoIn_test/Er-Co/261629.cif similarity index 100% rename from tests/data/cif/ErCoIn_test/Co-In/261629.cif rename to tests/data/cif/ErCoIn_test/Er-Co/261629.cif diff --git a/tests/data/cif/ErCoIn_test/Co-In/450249.cif b/tests/data/cif/ErCoIn_test/Er-Co/450249.cif similarity index 100% rename from tests/data/cif/ErCoIn_test/Co-In/450249.cif rename to tests/data/cif/ErCoIn_test/Er-Co/450249.cif diff --git a/tests/data/cif/ErCoIn_test/Co-In/451606.cif b/tests/data/cif/ErCoIn_test/Er-Co/451606.cif similarity index 100% rename from tests/data/cif/ErCoIn_test/Co-In/451606.cif rename to tests/data/cif/ErCoIn_test/Er-Co/451606.cif diff --git a/tests/data/cif/ensemble_test/histograms/formula.png b/tests/data/cif/ensemble_test/histograms/formula.png deleted file mode 100644 index 6718335..0000000 Binary files a/tests/data/cif/ensemble_test/histograms/formula.png and /dev/null differ diff --git a/tests/data/cif/ensemble_test/histograms/structures.png b/tests/data/cif/ensemble_test/histograms/structures.png deleted file mode 100644 index 50e3f93..0000000 Binary files a/tests/data/cif/ensemble_test/histograms/structures.png and /dev/null differ diff --git a/tests/data/cif/ensemble_test/polyhedrons/260171_Mo.png b/tests/data/cif/ensemble_test/polyhedrons/260171_Mo.png deleted file mode 100644 index fc2c689..0000000 Binary files a/tests/data/cif/ensemble_test/polyhedrons/260171_Mo.png and /dev/null differ diff --git a/tests/data/cif/ensemble_test/polyhedrons/300169_Ge1.png b/tests/data/cif/ensemble_test/polyhedrons/300169_Ge1.png deleted file mode 100644 index 5644f51..0000000 Binary files a/tests/data/cif/ensemble_test/polyhedrons/300169_Ge1.png and /dev/null differ diff --git a/tests/data/cif/ensemble_test/polyhedrons/300169_La1.png b/tests/data/cif/ensemble_test/polyhedrons/300169_La1.png deleted file mode 100644 index a88d00a..0000000 Binary files a/tests/data/cif/ensemble_test/polyhedrons/300169_La1.png and /dev/null differ diff --git a/tests/data/cif/ensemble_test/polyhedrons/300169_Ru1.png b/tests/data/cif/ensemble_test/polyhedrons/300169_Ru1.png deleted file mode 100644 index def2794..0000000 Binary files a/tests/data/cif/ensemble_test/polyhedrons/300169_Ru1.png and /dev/null differ