ThresholdSpecification¶
- class lsst.verify.ThresholdSpecification(name, threshold, operator_str, **kwargs)¶
- Bases: - Specification- A threshold-type specification, associated with a - Metric, that defines a binary comparison against a measurement.- Parameters:
- namestr
- Name of the specification for a metric. LPM-17, for example, uses - 'design',- 'minimum'and- 'stretch'terminology.
- quantityastropy.units.Quantity
- The specification threshold level. 
- operator_strstr
- 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_querydict, 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. 
- kwargsdict
- Keyword arguments passed directly to the - lsst.validate.base.Specificationconstructor.
 
- name
- Raises:
 - Attributes Summary - Representation of this - ThresholdSpecification's threshold as a- Datum.- dictthat can be serialized as semantic JSON, compatible with the SQUASH metric service.- Name of the metric this specification corresponds to ( - lsst.verify.Name).- Specification name ( - lsst.verify.Name).- 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.- jsonify_dict(d)- Recursively build JSON-renderable objects on all values in a dict. - query_metadata(metadata[, arg_driven])- Query a Job's metadata to determine if this specification applies. - write_json(filepath)- Write JSON to a file. - Attributes Documentation - datum¶
- Representation of this - ThresholdSpecification‘s threshold as a- Datum.
 - metric_name¶
- Name of the metric this specification corresponds to ( - lsst.verify.Name).
 - name¶
- Specification name ( - lsst.verify.Name).
 - 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:
- measurementastropy.units.Quantity
- The measurement value. The measurement - Quantitymust have units compatible with- threshold.
 
- measurement
- Returns:
- 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.
 
 
 - 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_str- Function - >=- >- <- <=- ==- !=
 - 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:
- namestrorlsst.validate.base.Name
- Specification name, either as a string or - Name.
- thresholddict
- A - dictwith fields:
- 'unit': threshold unit, as an- astropy.units.Unit- compatible- str.
- 'operator': a binary comparison operator, described in the class parameters documentation (- str).
 
- metricstrorlsst.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.
- packagestrorlsst.validate.base.Name, optional
- Name of the package the specification corresponds to. This parameter is optional if - nameor- metricare already fully-qualified.
- kwargsdict
- Keyword arguments passed directly to the - lsst.validate.base.Specificationconstructor.
 
- name
- Returns:
- specificationThresholdSpecification
- A specification instance. 
 
- specification
 
 - static jsonify_dict(d)¶
- Recursively build JSON-renderable objects on all values in a dict. - Parameters:
- ddict
- Dictionary to convert into a JSON-serializable object. Values are recursively JSON-ified. 
 
- d
- Returns:
- json_dictdict
- Dictionary that can be serialized to JSON. 
 
- json_dict
 - Examples - Subclasses can use this method to prepare output in their - json-method implementation. For example:- def json(self): return JsonSerializationMixin.jsonify_dict({ 'value': self.value, }) 
 - query_metadata(metadata, arg_driven=False)¶
- Query a Job’s metadata to determine if this specification applies. - Parameters:
- metadatalsst.verify.Metadataordict-type
- Metadata mapping. Typically this is the - lsst.verify.Job.metaattribute.
- arg_drivenbool, optional
- If - False(default),- metadatamatches the- MetadataQueryif- metadatahas all the terms defined in- MetadataQuery, and those terms match. If- metadatahas more terms than- MetadataQuery, it can still match. This behavior is appropriate for finding if a specification applies to a Job given metadata.- If - True, the orientation of the matching is reversed. Now- metadatamatches the- MetadataQueryif- MetadataQueryhas all the terms defined in- metadataand those terms match. If- MetadataQueryhas more terms than- metadata, it can still match. This behavior is appropriate for discovering specifications.
 
- metadata
- Returns:
 - See also