Python Materials Genomics (pymatgen) is a robust materials analysis code that defines classes for structures and molecules with support for many electronic structure codes. It powers the Materials Project.
# make sure that the orthorhombic supercell is different from the cubic cell
assert not np.array_equal(
supercell_generator_cubic.transformation_matrix,
supercell_generator_orthorhombic.transformation_matrix,
)
assert transformed_orthorhombic.lattice.abc != transformed_cubic.lattice.abc
# only angels are expected to be the same because of force_90_degrees = True
> assert transformed_cubic.lattice.angles == transformed_orthorhombic.lattice.angles
E assert (89.999970160...0000000086139) == (89.999970160...0000000086142)
E
E At index 2 diff: 90.00000000086139 != 90.00000000086142
E Use -v to get more diff
/<<PKGBUILDDIR>>/.pybuild/test_python3.12/tests/transformations/test_advanced_transformations.py:840: AssertionError
Floating point comparison needs to be used instead
Floating point numbers (angles) are compared in transformation tests at
https://github.com/materialsproject/pymatgen/blob/bd9fba9ec62437b5b62fbd0b2c2c723216cc5a2c/tests/transformations/test_advanced_transformations.py#L840
Using equality to compare floating point numbers inevitably fails e.g. https://buildd.debian.org/status/fetch.php?pkg=pymatgen&arch=amd64&ver=2024.10.29%2Bdfsg1-1&stamp=1731061592&raw=0
Floating point comparison needs to be used instead