From 50b4759c71b42bcf0e010d04e304e1eeaaddccf5 Mon Sep 17 00:00:00 2001 From: Jack Greisman Date: Tue, 8 Sep 2020 12:21:32 -0400 Subject: [PATCH] Change signature of get_phase_restrictions() to return list of lists --- reciprocalspaceship/utils/phases.py | 11 ++++++----- tests/utils/test_phase_restrictions.py | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/reciprocalspaceship/utils/phases.py b/reciprocalspaceship/utils/phases.py index 0ec6ca39..c1bec841 100644 --- a/reciprocalspaceship/utils/phases.py +++ b/reciprocalspaceship/utils/phases.py @@ -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 ---------- @@ -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 @@ -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 diff --git a/tests/utils/test_phase_restrictions.py b/tests/utils/test_phase_restrictions.py index 0f2be150..11464cb8 100644 --- a/tests/utils/test_phase_restrictions.py +++ b/tests/utils/test_phase_restrictions.py @@ -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))))