Skip to content

Commit

Permalink
Merge pull request #304 from bluesky/302-get-constraints-function
Browse files Browse the repository at this point in the history
add diffractometer get_axis_constraints() method
  • Loading branch information
prjemian authored Dec 1, 2023
2 parents c068bf2 + 46834d2 commit 4898aef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hkl/diffract.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Diffractometer(PseudoPositioner):
~inverse
~forward_solutions_table
~apply_constraints
~get_axis_constraints
~reset_constraints
~show_constraints
~undo_last_constraints
Expand Down Expand Up @@ -540,6 +541,10 @@ def _constraints_for_databroker(self):
]
# fmt: on

def get_axis_constraints(self, axis):
"""Show the constraints for one axis."""
return self._constraints_dict[axis]

def show_constraints(self, fmt="simple", printing=True):
"""Print the current constraints in a table."""
tbl = pyRestTable.Table()
Expand Down
10 changes: 10 additions & 0 deletions hkl/tests/test_diffract.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,13 @@ class Q4C(hkl.E4CV):
assert value.omega == 0.0
assert value.chi == 0.0
assert value.phi == 0.0


@pytest.mark.parametrize("axis", "alpha phi omega".split())
def test_get_constraint(axis, fourc):
if axis in fourc.calc._geometry.axis_names_get():
constraint = fourc.get_axis_constraints(axis)
assert isinstance(constraint, Constraint)
else:
with pytest.raises(KeyError):
fourc.get_axis_constraints(axis)

0 comments on commit 4898aef

Please sign in to comment.