MetricSet#

class lsst.verify.MetricSet(metrics=None)#

Bases: JsonSerializationMixin

A collection of Metrics.

Parameters#

metricssequence of Metric instances, optional

Metrics to be contained within the MetricSet.

Attributes Summary

json

A JSON-serializable object (list).

Methods Summary

deserialize([metrics])

Deserialize metric JSON objects into a MetricSet instance.

insert(metric)

Insert a Metric into the set.

items()

Iterate over (name, metric) pairs in the set.

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 MetricSet with metrics belonging to a single package and/or tag.

update(other)

Merge another MetricSet into this one.

Attributes Documentation

json#

A JSON-serializable object (list).

Methods Documentation

classmethod deserialize(metrics=None)#

Deserialize metric JSON objects into a MetricSet instance.

Parameters#

metricslist

List of metric JSON serializations (typically created by MetricSet.json).

Returns#

metric_setMetricSet

MetricSet instance.

insert(metric)#

Insert a Metric into the set.

Any pre-existing metric with the same name is replaced

Parameters#

metricMetric

A metric.

items()#

Iterate over (name, metric) pairs in the set.

Yields#

itemtuple

Tuple containing:

keys()#

Get a list of metric names included in the set

Returns#

keyslist of Name

List of Names included in the set.

classmethod load_metrics_package(package_name_or_path='verify_metrics', subset=None)#

Create a MetricSet from a Verification Framework metrics package.

Parameters#

package_name_or_pathstr, optional

Name 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.

subsetstr, optional

If set, only metrics for this package are loaded. For example, if subset='validate_drp', only validate_drp metrics are included in the MetricSet. This argument is equivalent to the MetricSet.subset method. Default is None.

Returns#

metric_setMetricSet

A MetricSet containing Metric instances.

See also#

lsst.verify.MetricSet.load_single_package

Notes#

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 the package_name_or_path argument. The default metric package for LSST Science Pipelines is verify_metrics.

To make a MetricSet from a single package’s YAML metric definition file that is not contained in a metrics package, use load_single_package instead.

classmethod load_single_package(metrics_yaml_path)#

Create a MetricSet from a single YAML file containing metric definitions for a single package.

Returns#

metric_setMetricSet

A MetricSet containing Metric instances found in the YAML file.

See also#

lsst.verify.MetricSet.load_metrics_package

Notes#

The YAML file’s name, without extension, is taken as the package name for all metrics.

For example, validate_drp.yaml contains metrics that are identified as belonging to the validate_drp package.

subset(package=None, tags=None)#

Create a new MetricSet with metrics belonging to a single package and/or tag.

Parameters#

packagestr or lsst.verify.Name, optional

Name 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.

tagssequence of str, optional

Tags to select metrics by. These tags must be a subset (<=) of the Metric.tags for the metric to be selected.

Returns#

metric_subsetMetricSet

Subset of this metric set containing only metrics belonging to the specified package and/or tag.

Notes#

If both package and tag are provided then the resulting MetricSet contains the intersection of the package-based and tag-based selections. That is, metrics will belong to package and posess the tag tag.

update(other)#

Merge another MetricSet into this one.

Parameters#

otherMetricSet

Another MetricSet. Metrics in other that do exist in this set are added to this one. Metrics in other replace metrics of the same name in this one.