11from pymatgen .core import Lattice
22
33import tests .t_crystal .base_crystal as BaseTest
4- from xrdpattern .crystal import CrystalStructure , CrystalBasis
4+ from xrdpattern .crystal import CrystalStructure , CrystalBasis , CrystalExamples
55
66
77# ---------------------------------------------------------
@@ -36,11 +36,24 @@ def test_to_cif(self):
3636 print (f'CIF = \n { cif } ' )
3737
3838 def test_standardize (self ):
39- lattice = Lattice .from_parameters (5.801 , 11.272 , 5.57 , 90 , 90 , 90 )
40- phase = CrystalStructure (lattice = lattice , basis = CrystalBasis .empty ())
41- new_phase = phase .get_standardized ()
39+ a ,b ,c = 5.801 , 11.272 , 5.57
40+ alpha , beta , gamma = 90 ,90 ,90
41+
42+ lattice = Lattice .from_parameters (a = a , b = b , c = c , alpha = alpha , beta = beta , gamma = gamma )
43+ empty_phase = CrystalStructure (lattice = lattice , basis = CrystalBasis .empty ())
44+ empty_standardized = empty_phase .get_standardized ()
45+ self .assertTrue (len (empty_standardized .basis ) == 0 )
46+
47+ nonempty_phase = CrystalStructure .from_cif (cif_content = CrystalExamples .get_cif_content ())
48+ nonempty_standardized = nonempty_phase .get_standardized ()
49+ for j ,l in enumerate (sorted ([a ,b ,c ])):
50+ self .assertAlmostEqual (nonempty_standardized .lengths [j ],l )
51+
52+ for k ,angle in enumerate (sorted ([alpha , beta , gamma ])):
53+ self .assertAlmostEqual (nonempty_standardized .angles [k ], angle )
54+
55+ self .assertTrue (len (nonempty_standardized .basis ) == len (nonempty_phase .basis ))
4256
43- self .assertTrue (len (new_phase .basis ) == 0 )
4457
4558if __name__ == "__main__" :
46- TestCifParsing .execute_all ()
59+ TestCifParsing .execute_all ()2
0 commit comments