Skip to content

Commit

Permalink
MNT #78 per review suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Apr 19, 2021
1 parent cf0506e commit 6ce2560
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
22 changes: 11 additions & 11 deletions hkl/diffract.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ class Diffractometer(PseudoPositioner):
~engine
~forward
~inverse
~forwardSolutionsTable
~applyConstraints
~resetConstraints
~showConstraints
~undoLastConstraints
~forward_solutions_table
~apply_constraints
~reset_constraints
~show_constraints
~undo_last_constraints
~pa
~wh
~_energy_changed
Expand Down Expand Up @@ -395,7 +395,7 @@ def check_value(self, pos):
pos = [pos.get(p.attr_name, p.position) for p in self.pseudo_positioners]
super().check_value(pos)

def applyConstraints(self, constraints):
def apply_constraints(self, constraints):
"""
Constrain the diffractometer's motions.
Expand All @@ -405,13 +405,13 @@ def applyConstraints(self, constraints):
self._push_current_constraints()
self._set_constraints(constraints)

def resetConstraints(self):
def reset_constraints(self):
"""Set constraints back to initial settings."""
if len(self._constraints_stack) > 0:
self._set_constraints(self._constraints_stack[0])
self._constraints_stack = []

def showConstraints(self, fmt="simple", printing=True):
def show_constraints(self, fmt="simple", printing=True):
"""Print the current constraints in a table."""
tbl = pyRestTable.Table()
tbl.labels = "axis low_limit high_limit value fit".split()
Expand All @@ -432,7 +432,7 @@ def showConstraints(self, fmt="simple", printing=True):

return tbl

def undoLastConstraints(self):
def undo_last_constraints(self):
"""
Remove the current constraints additions, restore previous.
"""
Expand All @@ -458,7 +458,7 @@ def _set_constraints(self, constraints):
self.calc[axis].value = constraint.value
self.calc[axis].fit = constraint.fit

def forwardSolutionsTable(self, reflections, full=False):
def forward_solutions_table(self, reflections, full=False):
"""
Return table of computed solutions for each (hkl) in the supplied reflections list.
Expand Down Expand Up @@ -561,7 +561,7 @@ def Package(**kwargs):
pt.addRow(row)
table.addRow(("positions", addTable(pt)))

t = self.showConstraints(printing=False)
t = self.show_constraints(printing=False)
table.addRow(("constraints", addTable(t)))

if all_samples:
Expand Down
12 changes: 6 additions & 6 deletions hkl/tests/test_diffract.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def test_names(fourc):
assert fourc.class_name.get() == "Fourc"


def test_forwardSolutionsTable(fourc):
def test_forward_solutions_table(fourc):
fourc.energy.put(A_KEV / 1.54)

# (100) has chi ~ 0 which poses occasional roundoff errors
Expand All @@ -156,7 +156,7 @@ def test_forwardSolutionsTable(fourc):
assert pytest.approx(sol.phi, 1e-5) == -90
assert pytest.approx(sol.tth, 1e-5) == -60

tbl = fourc.forwardSolutionsTable(
tbl = fourc.forward_solutions_table(
# fmt: off
[
[1, 1, 0],
Expand Down Expand Up @@ -261,8 +261,8 @@ def test_wh(fourc, capsys):
assert out == expected


def test_showConstraints(fourc, capsys):
fourc.showConstraints()
def test_show_constraints(fourc, capsys):
fourc.show_constraints()
out, err = capsys.readouterr()
assert len(out) > 0
assert err == ""
Expand All @@ -281,10 +281,10 @@ def test_showConstraints(fourc, capsys):
assert r.rstrip() == e.rstrip()


def test_applyConstraints(fourc):
def test_apply_constraints(fourc):
fourc.energy.put(A_KEV / 1.54)
# fmt: off
fourc.applyConstraints(
fourc.apply_constraints(
{
"tth": Constraint(0, 180, 0, True),
"chi": Constraint(0, 180, 0, True),
Expand Down

0 comments on commit 6ce2560

Please sign in to comment.