def test_cif_symmetry_operators(file): """Test that the non-translation part of the symmetry_operators is an invertible matrix of determinant 1 | -1""" with CIFParser(file) as p: for sym_op in p.symmetry_operators(): t = sym_op[:3, :3] assert round(abs(abs(np.linalg.det(t)) - 1), 7) == 0
def test_fractional_atoms(self): """ Test the CIFParser returns fractional atomic coordinates. """ for name in self._cif_files(): with self.subTest(name.split("\\")[-1]): with CIFParser(name) as p: for atm in p.atoms(): self.assertLessEqual(atm.coords_fractional.max(), 1) self.assertGreaterEqual(atm.coords_fractional.min(), 0)
def test_symmetry_operators(self): """ Test that the non-translation part of the symmetry_operators is an invertible matrix of determinant 1 | -1 """ for name in self._cif_files(): with self.subTest(name.split("\\")[-1]): with CIFParser(name) as p: for sym_op in p.symmetry_operators(): t = sym_op[:3, :3] self.assertAlmostEqual(abs(np.linalg.det(t)), 1)
def test_cif_international_number(file): """Test that the international space group number found by CIFParser is the same as spglib's""" with CIFParser(file) as p: from_parser = Hall2Number[p.hall_symbol()] crystal = Crystal.from_cif(file) from_spglib = crystal.international_number assert from_parser == from_spglib
def test_site_occupancy(self): """ Test that atom site occupancy is correctly parsed from CIF files. """ path = os.path.join("tests", "data", "SiC_partial_site_occ.cif") with CIFParser(path) as parser: atoms = list(parser.atoms()) for atm in filter(is_element("Si"), atoms): self.assertEqual(atm.occupancy, 0.75) for atm in filter(is_element("C"), atoms): self.assertEqual(atm.occupancy, 0.85)
def test_cif_site_occupancy(): """Test that atom site occupancy is correctly parsed from CIF files.""" path = Path(__file__).parent / "data" / "SiC_partial_site_occ.cif" with CIFParser(path) as parser: atoms = list(parser.atoms()) for atm in filter(is_element("Si"), atoms): assert atm.occupancy == 0.75 for atm in filter(is_element("C"), atoms): assert atm.occupancy == 0.85
def test_international_number(self): """ Test that the international space group number found by CIFParser is the same as spglib's """ for name in self._cif_files(): with self.subTest(name.split("\\")[-1]): with CIFParser(name) as p: from_parser = Hall2Number[p.hall_symbol()] crystal = Crystal.from_cif(name) from_spglib = crystal.international_number self.assertEqual(from_parser, from_spglib)
def test_cif_fractional_atoms(file): """Test the CIFParser returns fractional atomic coordinates.""" with CIFParser(file) as p: for atm in p.atoms(): assert atm.coords_fractional.max() <= 1 assert atm.coords_fractional.min() >= 0