MetricSet¶
-
class
lsst.verify.MetricSet(metrics=None)[source]¶ Bases:
lsst.verify.jsonmixin.JsonSerializationMixinA collection of
Metrics.Parameters: metrics : sequence of
Metricinstances, optionalMetrics to be contained within theMetricSet.Attributes Summary
jsonA JSON-serializable object ( list).Methods Summary
deserialize([metrics])Deserialize metric JSON objects into a MetricSet instance. insert(metric)Insert a Metricinto the set.items()Iterate over (name, metric)pairs in the set.jsonify_dict(d)Recursively build JSON-renderable objects on all values in a dict. keys()Get a list of metric names included in the set load_metrics_package([package_name_or_path, ...])Create a MetricSet from a Verification Framework metrics package. load_single_package(metrics_yaml_path)Create a MetricSet from a single YAML file containing metric definitions for a single package. subset([package, tags])Create a new MetricSetwith metrics belonging to a single package and/or tag.update(other)Merge another MetricSetinto this one.write_json(filepath)Write JSON to a file. Attributes Documentation
Methods Documentation
-
classmethod
deserialize(metrics=None)[source]¶ Deserialize metric JSON objects into a MetricSet instance.
Parameters: metrics :
listList of metric JSON serializations (typically created by
MetricSet.json).Returns: metric_set :
MetricSetMetricSetinstance.
-
insert(metric)[source]¶ Insert a
Metricinto the set.Any pre-existing metric with the same name is replaced
Parameters: metric :
MetricA metric.
-
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, })
-
keys()[source]¶ Get a list of metric names included in the set
Returns: List of
Names included in the set.
-
classmethod
load_metrics_package(package_name_or_path='verify_metrics', subset=None)[source]¶ Create a MetricSet from a Verification Framework metrics package.
Parameters: package_name_or_path :
str, optionalName of an EUPS package that hosts metric and specification definition YAML files or the file path to a metrics package.
'verify_metrics'is the default package, and is where metrics and specifications are defined for most packages.subset :
str, optionalIf set, only metrics for this package are loaded. For example, if
subset='validate_drp', onlyvalidate_drpmetrics are included in theMetricSet. This argument is equivalent to theMetricSet.subsetmethod. Default isNone.Returns: metric_set :
MetricSetNotes
EUPS packages that host metrics and specification definitions for the Verification Framework have top-level directories named
'metrics'and'specs'. The metrics package chosen with thepackage_name_or_pathargument. The default metric package for LSST Science Pipelines isverify_metrics.To make a
MetricSetfrom a single package’s YAML metric definition file that is not contained in a metrics package, useload_single_packageinstead.
-
classmethod
load_single_package(metrics_yaml_path)[source]¶ Create a MetricSet from a single YAML file containing metric definitions for a single package.
Returns: metric_set :
MetricSetNotes
The YAML file’s name, without extension, is taken as the package name for all metrics.
For example,
validate_drp.yamlcontains metrics that are identified as belonging to thevalidate_drppackage.
-
subset(package=None, tags=None)[source]¶ Create a new
MetricSetwith metrics belonging to a single package and/or tag.Parameters: package :
strorlsst.verify.Name, optionalName of the package to subset metrics by. If the package name is
'pkg_a', then metric'pkg_a.metric_1'would be included in the subset, while'pkg_b.metric_2'would be excluded.tags : sequence of
str, optionalTags to select metrics by. These tags must be a subset (
<=) of theMetric.tagsfor the metric to be selected.Returns: metric_subset :
MetricSetSubset of this metric set containing only metrics belonging to the specified package and/or tag.
Notes
If both
packageandtagare provided then the resultingMetricSetcontains the intersection of the package-based and tag-based selections. That is, metrics will belong topackageand posess the tagtag.
-
classmethod