@@ -104,6 +104,21 @@ def test_get_atoms_from_structure_dyn():
104
104
ase_mask = c .mask if isinstance (c , ase .constraints .FixCartesian ) else [True , True , True ]
105
105
assert len (c .index ) == len ([mask for mask in sel_dyn if np .array_equal (mask , ~ np .array (ase_mask ))])
106
106
107
+ def test_get_atoms_from_structure_spacegroup ():
108
+ # Get structure with space group dictionary in properties
109
+ space_group_info = STRUCTURE .get_space_group_info ()
110
+ STRUCTURE .properties ["spacegroup" ] = {"number" : space_group_info [1 ], "setting" : 1 }
111
+
112
+ # Convert to atoms and check that structure was not modified
113
+ atoms = AseAtomsAdaptor .get_atoms (STRUCTURE )
114
+ assert isinstance (STRUCTURE .properties ["spacegroup" ], dict )
115
+ assert isinstance (atoms .info ["spacegroup" ], ase .spacegroup .Spacegroup )
116
+
117
+ # Check that space group matches
118
+ assert atoms .info ["spacegroup" ].no == STRUCTURE .properties ["spacegroup" ]["number" ]
119
+ assert atoms .info ["spacegroup" ].setting == STRUCTURE .properties ["spacegroup" ]["setting" ]
120
+
121
+
107
122
108
123
def test_get_atoms_from_molecule ():
109
124
mol = Molecule .from_file (XYZ_STRUCTURE )
@@ -216,6 +231,24 @@ def test_get_structure_dyn(select_dyn):
216
231
217
232
assert len (ase_atoms ) == len (structure )
218
233
234
+ def test_get_structure_spacegroup ():
235
+ # set up Atoms object with spacegroup information
236
+ a = 4.05
237
+ atoms = ase .spacegroup .crystal (
238
+ "Al" , [(0 , 0 , 0 )], spacegroup = 225 , cellpar = [a , a , a , 90 , 90 , 90 ]
239
+ )
240
+ assert "spacegroup" in atoms .info
241
+ assert isinstance (atoms .info ["spacegroup" ], ase .spacegroup .Spacegroup )
242
+
243
+ # Test that get_structure does not mutate atoms
244
+ structure = AseAtomsAdaptor .get_structure (atoms )
245
+ assert isinstance (atoms .info ["spacegroup" ], ase .spacegroup .Spacegroup )
246
+ assert isinstance (structure .properties ["spacegroup" ], dict )
247
+
248
+ # Test that spacegroup info matches
249
+ assert atoms .info ["spacegroup" ].no == structure .properties ["spacegroup" ]["number" ]
250
+ assert atoms .info ["spacegroup" ].setting == structure .properties ["spacegroup" ]["setting" ]
251
+
219
252
220
253
def test_get_molecule ():
221
254
atoms = ase .io .read (XYZ_STRUCTURE )
0 commit comments