Skip to content

Commit

Permalink
Change signature of get_phase_restrictions() to return list of lists
Browse files Browse the repository at this point in the history
  • Loading branch information
JBGreisman committed Sep 8, 2020
1 parent 6c1f4eb commit 50b4759
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions reciprocalspaceship/utils/phases.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def get_phase_restrictions(H, spacegroup):
"""
Return phase restrictions for Miller indices in a given space group.
If there are no phase restrictions, an empty array is returned for that
If there are no phase restrictions, an empty list is returned for that
Miller index. If a given Miller index is systematically absent an
empty array is also returned.
empty list is also returned.
Parameters
----------
Expand All @@ -30,8 +30,9 @@ def get_phase_restrictions(H, spacegroup):
Returns
-------
restrictions : list of arrays
list of arrays with phase restrictions for each Miller index
restrictions : list of lists
List of lists of phase restrictions for each Miller index. An empty
list is returned for Miller indices without phase restrictions
"""
from reciprocalspaceship.utils.asu import hkl_is_absent
from reciprocalspaceship.utils.structurefactors import is_centric
Expand All @@ -49,7 +50,7 @@ def get_phase_restrictions(H, spacegroup):
restriction = np.array([shift/2, 180+(shift/2)])
restriction = canonicalize_phases(restriction)
restriction.sort()
restrictions.append(restriction)
restrictions.append(restriction.tolist())
hit = True
break

Expand Down
4 changes: 2 additions & 2 deletions tests/utils/test_phase_restrictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_phase_restrictions(sgtbx_by_xhm):
restrictions = rs.utils.get_phase_restrictions(H, sg)
assert len(ref_restrictions) == len(restrictions)
for ref, test in zip(ref_restrictions, restrictions):
if isinstance(ref, list):
if ref is []:
assert ref == test
else:
assert np.allclose(np.sin(np.deg2rad(ref)), np.sin(np.deg2rad(test)))
assert np.allclose(np.sin(np.deg2rad(ref)), np.sin(np.deg2rad(np.array(test))))

0 comments on commit 50b4759

Please sign in to comment.