@@ -118,6 +118,17 @@ def _crystal_system_from_name_hm(name_hm: str) -> str | None:
118118 return crystal_system
119119
120120
121+ _CELL_FIXED_AXES_BY_SYSTEM : dict [str , set [str ]] = {
122+ 'cubic' : {'lattice_b' , 'lattice_c' , 'angle_alpha' , 'angle_beta' , 'angle_gamma' },
123+ 'tetragonal' : {'lattice_b' , 'angle_alpha' , 'angle_beta' , 'angle_gamma' },
124+ 'orthorhombic' : {'angle_alpha' , 'angle_beta' , 'angle_gamma' },
125+ 'hexagonal' : {'lattice_b' , 'angle_alpha' , 'angle_beta' , 'angle_gamma' },
126+ 'trigonal' : {'lattice_b' , 'angle_alpha' , 'angle_beta' , 'angle_gamma' },
127+ 'monoclinic' : {'angle_alpha' , 'angle_gamma' },
128+ 'triclinic' : set (),
129+ }
130+
131+
121132def _cell_fixed_axes (crystal_system : str ) -> set [str ]:
122133 """
123134 Return cell keys that are dependent on others for a crystal system.
@@ -136,19 +147,7 @@ def _cell_fixed_axes(crystal_system: str) -> set[str]:
136147 set[str]
137148 Subset of cell keys that are fixed by symmetry.
138149 """
139- if crystal_system == 'cubic' :
140- return {'lattice_b' , 'lattice_c' , 'angle_alpha' , 'angle_beta' , 'angle_gamma' }
141- if crystal_system == 'tetragonal' :
142- return {'lattice_b' , 'angle_alpha' , 'angle_beta' , 'angle_gamma' }
143- if crystal_system == 'orthorhombic' :
144- return {'angle_alpha' , 'angle_beta' , 'angle_gamma' }
145- if crystal_system in {'hexagonal' , 'trigonal' }:
146- return {'lattice_b' , 'angle_alpha' , 'angle_beta' , 'angle_gamma' }
147- if crystal_system == 'monoclinic' :
148- return {'angle_alpha' , 'angle_gamma' }
149- if crystal_system == 'triclinic' :
150- return set ()
151- return set ()
150+ return _CELL_FIXED_AXES_BY_SYSTEM .get (crystal_system , set ())
152151
153152
154153def cell_symmetry_fixed_flags (name_hm : str ) -> dict [str , bool ]:
@@ -170,7 +169,7 @@ def cell_symmetry_fixed_flags(name_hm: str) -> dict[str, bool]:
170169 """
171170 crystal_system = _crystal_system_from_name_hm (name_hm )
172171 if crystal_system is None :
173- return { key : False for key in _CELL_KEYS }
172+ return dict . fromkeys ( _CELL_KEYS , False )
174173 fixed = _cell_fixed_axes (crystal_system )
175174 return {key : key in fixed for key in _CELL_KEYS }
176175
@@ -207,6 +206,12 @@ def _get_wyckoff_exprs(
207206 log .error ('IT_coordinate_system_code is not set' )
208207 return None
209208
209+ if (it_number , coord_code ) not in SPACE_GROUPS :
210+ # Space group is not in the local SPACE_GROUPS table (e.g. P 1,
211+ # where cryspy reports no coordinate-system codes). Treat as
212+ # "no symmetry constraints to apply".
213+ return None
214+
210215 entry = SPACE_GROUPS [it_number , coord_code ]
211216 first_position = entry ['Wyckoff_positions' ][wyckoff_letter ]['coords_xyz' ][0 ]
212217 components = first_position .strip ('()' ).split (',' )
@@ -217,9 +222,9 @@ def _fract_fixed_flags(parsed_exprs: list[Expr]) -> dict[str, bool]:
217222 """
218223 Return per-axis flags marking coordinates fixed by site symmetry.
219224
220- For each axis (x, y, z), the coordinate is considered fixed when
221- the corresponding symbol does not appear as a free symbol in any of
222- the Wyckoff position expressions.
225+ For each axis (x, y, z), the coordinate is considered fixed when the
226+ corresponding symbol does not appear as a free symbol in any of the
227+ Wyckoff position expressions.
223228
224229 Parameters
225230 ----------
@@ -327,9 +332,9 @@ def atom_site_symmetry_fixed_flags(
327332 Returns
328333 -------
329334 dict[str, bool]
330- Mapping ``'fract_x' / 'fract_y' / 'fract_z'`` to ``True`` if
331- the axis is fully determined by site symmetry. Returns all
332- ``False`` when the Wyckoff position cannot be resolved.
335+ Mapping ``'fract_x' / 'fract_y' / 'fract_z'`` to ``True`` if the
336+ axis is fully determined by site symmetry. Returns all ``False``
337+ when the Wyckoff position cannot be resolved.
333338 """
334339 parsed_exprs = _get_wyckoff_exprs (name_hm , coord_code , wyckoff_letter )
335340 if parsed_exprs is None :
0 commit comments