Constraints#

Computation of the real-space axis positions given a set of reciprocal-space coordinates can have many solutions. One or more constraints (Constraint) (a.k.a, cut points), together with a choice of operating mode, can:

  • Limit the range of forward() solutions accepted for that positioner.

  • Declare the value to use when the positioner should be kept constant. (not implemented yet)

Source Code Documentation#

Limitations on acceptable positions for computed ‘forward()’ solutions.

RealAxisConstraints(reals)

Constraints for every (real) axis of the diffractometer.

ConstraintBase()

Base class for all constraints for selecting 'forward()' solutions.

LimitsConstraint([low_limit, high_limit, label])

Value must fall between low & high limits.

From hklpy, these TODO items:

  • _constraints_dict

  • _constraints_for_databroker

  • _push_current_constraints

  • _set_constraints

class hklpy2.operations.constraints.ConstraintBase[source]#

Bases: ABC

Base class for all constraints for selecting ‘forward()’ solutions.

_asdict()

Return a new dict which maps field names to their values.

valid(**values)

Is this constraint satisifed by current value(s)?

_asdict()[source]#

Return a new dict which maps field names to their values.

_fromdict(config)[source]#

Redefine this constraint from a (configuration) dictionary.

abstract valid(**values: Dict[str, int | float]) bool[source]#

Is this constraint satisifed by current value(s)?

PARAMETERS

values dict:

Dictionary of current ‘axis: value’ pairs for comparison.

class hklpy2.operations.constraints.LimitsConstraint(low_limit=-180, high_limit=180, label=None)[source]#

Bases: ConstraintBase

Value must fall between low & high limits.

Parameters:
  • low_limit (float) – Lowest acceptable value for this axis when computing real-space solutions from given reciprocal-space positions.

  • high_limit (float) – Highest acceptable value for this axis when computing real-space solutions from given reciprocal-space positions.

  • label (str) – Name of the axis for these limits.

  • autosummary:: (..) – ~limits ~valid

_asdict()#

Return a new dict which maps field names to their values.

_fromdict(config)#

Redefine this constraint from a (configuration) dictionary.

property limits#

Return the low and high limits of this constraint.

valid(**values: Dict[str, int | float]) bool[source]#

True if low <= value <= high.

PARAMETERS

reals dict:

Dictionary of current ‘axis: value’ pairs for comparison.

class hklpy2.operations.constraints.RealAxisConstraints(reals: List[str])[source]#

Bases: dict

Constraints for every (real) axis of the diffractometer.

_asdict()

Return all constraints as a dictionary.

_fromdict(config)

Redefine existing constraints from a (configuration) dictionary.

valid(**reals)

Are all constraints satisfied?

_asdict()[source]#

Return all constraints as a dictionary.

_fromdict(config)[source]#

Redefine existing constraints from a (configuration) dictionary.

clear() None.  Remove all items from D.#
copy() a shallow copy of D#
fromkeys(value=None, /)#

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)#

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items#
keys() a set-like object providing a view on D's keys#
pop(k[, d]) v, remove specified key and return the corresponding value.#

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()#

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)#

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from dict/iterable E and F.#

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

valid(**reals: Dict[str, int | float]) bool[source]#

Are all constraints satisfied?

values() an object providing a view on D's values#