Skip to content

Commit f7f5466

Browse files
committed
rm ase adapter tests
1 parent 8354820 commit f7f5466

File tree

1 file changed

+0
-91
lines changed

1 file changed

+0
-91
lines changed

tests/test_structure.py

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -892,97 +892,6 @@ def test_get_lattice_vector_angles(datafile):
892892
assert np.allclose(actual_lattice_vector_angles, expected_lattice_vector_angles)
893893

894894

895-
@pytest.mark.parametrize(
896-
"input",
897-
[
898-
# case: user calls the conversion function on a Structure object that already contains
899-
# a structure
900-
# expected: the structure is wiped clean and replaced with the converted structure
901-
# we use the fixture to create a Structure object that already contains a structure.
902-
"use_diffpy_structure_fixture",
903-
# case: user calls the conversion function on an empty Structure object
904-
# expected: the converted structure is added to the empty Structure object without issue
905-
Structure(),
906-
],
907-
)
908-
def test_convert_ase_to_diffpy_structure(input, build_ase_atom_object, build_diffpy_structure_object):
909-
"""Check convert_ase_to_diffpy_structure()"""
910-
# input: User wants to convert an ASE.Atoms object to a diffpy.structure.Structure object
911-
# expected: All similar data is transferred correctly,
912-
# including chemical symbols, fractional coordinates, and lattice parameters.
913-
914-
# Create an ASE.Atoms object
915-
ase_zb = build_ase_atom_object
916-
# Create an identical expected diffpy Structure object
917-
expected_structure = build_diffpy_structure_object
918-
919-
# Create new Structure object and convert ase to diffpy structure.
920-
# Use the string input to determine which type of Structure object to create for the test
921-
if isinstance(input, str):
922-
actual_structure = build_diffpy_structure_object
923-
else:
924-
actual_structure = input
925-
# set the lost_info variable, which gets the attribute of method from ASE.Atoms object, gets the values
926-
# and stores it in a dict. This is used because ASE.Atoms stores more/different
927-
# info that a diffpy.structure object
928-
lost_info_dict = actual_structure.convert_ase_to_diffpy_structure(ase_zb, lost_info="get_masses")
929-
actual_masses = lost_info_dict["get_masses"]
930-
expected_masses = ase_zb.get_masses()
931-
assert np.allclose(actual_masses, expected_masses)
932-
933-
# Compare the actual and expected values
934-
expected_lattice_vectors = expected_structure.get_lattice_vectors()
935-
actual_lattice_vectors = actual_structure.get_lattice_vectors()
936-
assert np.allclose(expected_lattice_vectors, actual_lattice_vectors)
937-
938-
expected_lattice_angle = expected_structure.get_lattice_vector_angles()
939-
actual_lattice_angle = actual_structure.get_lattice_vector_angles()
940-
assert np.allclose(expected_lattice_angle, actual_lattice_angle)
941-
942-
expected_symbols = expected_structure.get_chemical_symbols()
943-
actual_symbols = actual_structure.get_chemical_symbols()
944-
assert actual_symbols == expected_symbols
945-
946-
expected_coords = expected_structure.get_fractional_coordinates()
947-
actual_coords = actual_structure.get_fractional_coordinates()
948-
assert np.allclose(actual_coords, expected_coords)
949-
950-
951-
def test_convert_ase_to_diffpy_structure_bad_typeerror():
952-
"""Check convert_ase_to_diffpy_structure() with bad input."""
953-
bad_input = "string" # pass a string instead of ase.Atoms
954-
expected_error_msg = "Input must be an instance of ase.Atoms but got type <class 'str'>."
955-
actual_structure = Structure()
956-
with pytest.raises(TypeError, match=expected_error_msg):
957-
actual_structure.convert_ase_to_diffpy_structure(bad_input)
958-
959-
960-
@pytest.mark.parametrize(
961-
"bad_lost_info,error,expected_error_msg",
962-
[ # case: User provides an ASE.Atoms object but requests lost_info that is not an attribute of ASE.Atoms
963-
# expected: A ValueError is raised with a clear error message indicating the requested lost_info
964-
# attribute is invalid.
965-
(["invalid_method"], ValueError, "ASE.Atoms object has no attribute 'invalid_method'"),
966-
# case: User provides an ASE.Atoms object but requests lost_info that is an attribute of ASE.Atoms
967-
# but has not been set yet.
968-
# expected: The error message from ase is raised indicating the specific issue with the
969-
# requested lost_info attribute.
970-
# We set the expected error message to None because this expectation is
971-
# out of our control, but it is good to make sure that we are
972-
# raising the error from ASE.
973-
(["get_magnetic_moments"], RuntimeError, None),
974-
],
975-
)
976-
def test_convert_ase_to_diffpy_structure_bad_valueerror(
977-
bad_lost_info, error, expected_error_msg, build_ase_atom_object
978-
):
979-
"""Check convert_ase_to_diffpy_structure() with bad lost_info."""
980-
ase_zb = build_ase_atom_object
981-
actual_structure = Structure()
982-
with pytest.raises(error, match=expected_error_msg):
983-
actual_structure.convert_ase_to_diffpy_structure(ase_zb, lost_info=bad_lost_info)
984-
985-
986895
# ----------------------------------------------------------------------------
987896
@pytest.mark.parametrize(
988897
"existing, atype, xyz, expected_len, expected_element, expected_xyz",

0 commit comments

Comments
 (0)