Metric¶
-
class
lsst.verify.Metric(name, description, unit, tags=None, reference_doc=None, reference_url=None, reference_page=None)[source]¶ Bases:
lsst.verify.jsonmixin.JsonSerializationMixinContainer for the definition of a metric.
Metrics can either be instantiated programatically, or from a metric YAML file through
lsst.verify.MetricSet.Parameters: name :
strName of the metric (e.g.,
'PA1').description :
strShort description about the metric.
unit :
strorastropy.units.UnitUnits of the metric.
Measurements of this metric must be in an equivalent (that is, convertable) unit. Argument can either be anastropy.unit.Unitinstance, or aUnit-compatible string representation. Use an empty string,'', orastropy.units.dimensionless_unscaledfor a unitless quantity.Tags associated with this metric. Tags are user-submitted string tokens that are used to group metrics.
reference_doc :
str, optionalThe document handle that originally defined the metric (e.g.,
'LPM-17').reference_url :
str, optionalThe document’s URL.
reference_page :
str, optionalPage where metric in defined in the reference document.
Attributes Summary
descriptionShort description of the metric ( str).jsondictthat can be serialized as semantic JSON, compatible withnameMetric’s name ( Name).referenceDocumentation reference as human-readable text ( str, read-only).reference_docName of the document that specifies this metric ( str).reference_pagePage number in the document that specifies this metric ( int).reference_urlURL of the document that specifies this metric ( str).tagsTag labels ( setofstr).unitThe metric’s unit ( astropy.units.Unit).unit_strThe string representation of the metric’s unit ( Unit-compatiblestr).Methods Summary
check_unit(quantity)Check that a Quantityhas equivalent units to this metric.deserialize([name, description, unit, tags, ...])Create a Metric instance from a parsed YAML/JSON document. jsonify_dict(d)Recursively build JSON-renderable objects on all values in a dict. write_json(filepath)Write JSON to a file. Attributes Documentation
-
reference¶ Documentation reference as human-readable text (
str, read-only).Uses
reference_doc,reference_page, andreference_url, as available.
-
unit¶ The metric’s unit (
astropy.units.Unit).
Methods Documentation
-
check_unit(quantity)[source]¶ Check that a
Quantityhas equivalent units to this metric.Parameters: quantity :
astropy.units.QuantityQuantity to be tested.
Returns: is_equivalent :
bool
-
classmethod
deserialize(name=None, description=None, unit=None, tags=None, reference=None)[source]¶ Create a Metric instance from a parsed YAML/JSON document.
Parameters: kwargs :
dictKeyword arguments that match fields from the
Metric.jsonserialization.Returns: metric :
MetricA Metric instance.
-
jsonify_dict(d)¶ Recursively build JSON-renderable objects on all values in a dict.
Parameters: d :
dictDictionary to convert into a JSON-serializable object. Values are recursively JSON-ified.
Returns: json_dict :
dictDictionary 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, })
-