Specification

class lsst.verify.Specification(name, **kwargs)[source]

Bases: lsst.verify.jsonmixin.JsonSerializationMixin

Specification base class.

Specification classes must implement:

Subclasses should also call Specification.__init__ to initialize the specifications name attribute (a Name instance).

Attributes Summary

json dict that can be serialized as semantic JSON, compatible with
metric_name Name of the metric this specification corresponds to (lsst.verify.Name).
name Specification name (lsst.verify.Name).
tags Tag labels (set of str).
type Specification type (str).

Methods Summary

check(measurement) Check if a measurement passes this specification.
jsonify_dict(d) Recursively build JSON-renderable objects on all values in a dict.
query_metadata(metadata) Query a Job’s metadata to determine if this specification applies.
write_json(filepath) Write JSON to a file.

Attributes Documentation

json

dict that can be serialized as semantic JSON, compatible with the SQUASH metric service.

metric_name

Name of the metric this specification corresponds to (lsst.verify.Name).

name

Specification name (lsst.verify.Name).

tags

Tag labels (set of str).

type

Specification type (str).

Methods Documentation

check(measurement)[source]

Check if a measurement passes this specification.

Parameters:

measurement : astropy.units.Quantity

The measurement value. The measurement Quantity must have units compatible with the specification.

Returns:

passed : bool

True if the measurement meets the specification, False otherwise.

jsonify_dict(d)

Recursively build JSON-renderable objects on all values in a dict.

Parameters:

d : dict

Dictionary to convert into a JSON-serializable object. Values are recursively JSON-ified.

Returns:

json_dict : dict

Dictionary that can be serialized to JSON.

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)[source]

Query a Job’s metadata to determine if this specification applies.

Parameters:

metadata : lsst.verify.Metadata or dict-type

Metadata mapping. Typically this is the lsst.verify.Job.meta attribute.

Returns:

applies : bool

True if this specification applies to a Job’s measurement, or False otherwise.

write_json(filepath)

Write JSON to a file.

Parameters:

filepath : str

Destination file name for JSON output.