ThresholdSpecification#
- class lsst.verify.ThresholdSpecification(name, threshold, operator_str, **kwargs)#
Bases:
SpecificationA threshold-type specification, associated with a
Metric, that defines a binary comparison against a measurement.Parameters#
- name
str Name of the specification for a metric. LPM-17, for example, uses
'design','minimum'and'stretch'terminology.- quantity
astropy.units.Quantity The specification threshold level.
- operator_str
str The threshold’s binary comparison operator. The operator is oriented so that
measurement {{ operator }} threshold quantityis the specification test. Can be one of:'<','<=','>','>=','==', or'!='.- metadata_query
dict, optional Dictionary of key-value terms that the measurement’s metadata must have for this specification to apply.
- tagssequence of
str, optional Sequence of tags that group this specification with others.
- kwargs
dict Keyword arguments passed directly to the
lsst.validate.base.Specificationconstructor.
Raises#
- TypeError
If
nameis not compartible withName, orthresholdis not aQuantity, or if theoperator_strcannot be converted into a Python binary comparison operator.
Attributes Summary
Representation of this
ThresholdSpecification's threshold as aDatum.Binary comparision operator that tests success of a measurement fulfilling a specification of this metric.
Threshold comparision operator ('str').
The specification threshold level (
astropy.units.Quantity).Specification type (
str).Methods Summary
check(measurement)Check if a measurement passes this specification.
convert_operator_str(op_str)Convert a string representing a binary comparison operator to the operator function itself.
deserialize([name, threshold, metric, package])Deserialize from keys in a specification YAML document or a JSON serialization into a
ThresholdSpecificationinstance.Attributes Documentation
- datum#
Representation of this
ThresholdSpecification‘s threshold as aDatum.
- operator#
Binary comparision operator that tests success of a measurement fulfilling a specification of this metric.
Measured value is on left side of comparison and specification level is on right side.
- operator_str#
Threshold comparision operator (‘str’).
A measurement passes the specification if:
measurement {{ operator }} threshold == True
The operator string is a standard Python binary comparison token, such as:
'<','>','<=','>=','=='or'!='.
- threshold = None#
The specification threshold level (
astropy.units.Quantity).
- type#
Methods Documentation
- check(measurement)#
Check if a measurement passes this specification.
Parameters#
- measurement
astropy.units.Quantity The measurement value. The measurement
Quantitymust have units compatible withthreshold.
Returns#
- passed
bool Trueif the measurement meets the specification,Falseotherwise.
Raises#
- astropy.units.UnitError
Raised if the measurement cannot be compared to the threshold. For example, if the measurement is not an
astropy.units.Quantityor if the units are not compatible.
- measurement
- static convert_operator_str(op_str)#
Convert a string representing a binary comparison operator to the operator function itself.
Operators are oriented so that the measurement is on the left-hand side, and specification threshold on the right hand side.
The following operators are permitted:
op_strFunction
>=operator.ge>operator.gt<operator.lt<=operator.le==operator.eq!=operator.neParameters#
- op_str
str A string representing a binary operator.
Returns#
- op_funcobj
An operator function from the
operatorstandard library module.
Raises#
- ValueError
Raised if
op_stris not a supported binary comparison operator.
- op_str
- classmethod deserialize(name=None, threshold=None, metric=None, package=None, **kwargs)#
Deserialize from keys in a specification YAML document or a JSON serialization into a
ThresholdSpecificationinstance.Parameters#
- name
strorlsst.validate.base.Name Specification name, either as a string or
Name.- threshold
dict A
dictwith fields:'value': threshold value (floatorint).'unit': threshold unit, as anastropy.units.Unit- compatiblestr.'operator': a binary comparison operator, described in the class parameters documentation (str).
- metric
strorlsst.validate.base.Name, optional Name of the fully-qualified name of the metric the specification corresponds to. This parameter is optional if
nameis already fully-qualified.- package
strorlsst.validate.base.Name, optional Name of the package the specification corresponds to. This parameter is optional if
nameormetricare already fully-qualified.- kwargs
dict Keyword arguments passed directly to the
lsst.validate.base.Specificationconstructor.
Returns#
- specification
ThresholdSpecification A specification instance.
- name
- name