Coverage for python/lsst/verify/measurementset.py : 81%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# # LSST Data Management System # # This product includes software developed by the # LSST Project (http://www.lsst.org/). # # See COPYRIGHT file at the top of the source tree. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the LSST License Statement and # the GNU General Public License along with this program. If not, # see <https://www.lsstcorp.org/LegalNotices/>. #
"""A collection of `~lsst.verify.Measurement`\ s of `~lsst.verify.Metric`\ s.
``MeasurementSet`` provides a dict-like interface for getting, setting, and iterating over `Measurement`\ s.
Parameters ---------- measurements : `list` of `lsst.verify.Measurement`\ s Measurements to include in the set. """
"""Create a measurement set from a parsed JSON dataset.
Parameters ---------- measurements : `list`, optional A list of `Measurement` JSON serializations. blob_set : `BlobSet`, optional A `BlobSet` instance that support measurement deserialization. metric_set : `MetricSet`, optional A `MetricSet` that supports measurement deserialization. If provided, measurements are validated for unit consistency with metric definitions. `Measurement` instances also gain a `Measurement.metric` attribute.
Returns ------- instance : `MeasurementSet` A `MeasurementSet` instance. """
measurements = []
# Job.deserialize may pass an empty MetricSet, so ignore that
except KeyError: # metric not in the MetricSet, but it's optional pass
raise KeyError('Key {0} is not a metric name'.format(key))
message = ('Measurement {0} is not a ' 'lsst.verify.Measurement-type') raise TypeError(message.format(value))
"metric name, {1}")
"""Merge another `MeasurementSet` into this one.
Parameters ---------- other : `MeasurementSet` Another `MeasurementSet`. Measurements in ``other`` that do exist in this set are added to this one. Measurements in ``other`` replace measurements of the same metric in this one.
Returns ------- self : `MeasurementSet` This `MeasurementSet`.
Notes ----- Equivalent to `update`. """
count = len(self) if count == 0: count_str = 'empty' elif count == 1: count_str = '1 Measurement' else: count_str = '{count:d} Measurements'.format(count=count) return '<MeasurementSet: {0}>'.format(count_str)
"""Get a sequence of metric names contained in the measurement set.
Returns ------- keys : sequence of `Name` Sequence of names of metrics for measurements in the set. """ return self._items.keys()
"""Iterete over (`Name`, `Measurement`) pairs in the set.
Yields ------ item : `tuple` Tuple containing:
- `Name` of the measurement's `Metric`. - `Measurement` instance. """
"""Insert a measurement into the set."""
"""Merge another `MeasurementSet` into this one.
Parameters ---------- other : `MeasurementSet` Another `MeasurementSet`. Measurements in ``other`` that do exist in this set are added to this one. Measurements in ``other`` replace measurements of the same metric in this one. """
"""Refresh `Measurement.metric` attributes in `Measurement`\ s contained by this set.
Parameters ---------- metric_set : `MetricSet` `Metric`\ s from this set are inserted into corresponding `Measurement`\ s contained in this `MeasurementSet`.
Notes ----- This method is especially useful for inserting `Metric` instances into `Measurement`\ s that weren't originally created with `Metric` instances. By including a `Metric` in a `Measurement`, the serialized units of a measurment are normalized to the metric's definition.
See also -------- lsst.verify.Job.reload_metrics_package """
def json(self): """A `dict` that can be serialized as JSON.""" [meas for name, meas in self.items()] ) |