Coverage for python/lsst/daf/butler/core/datasets/association.py : 74%

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
1# This file is part of daf_butler.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
22from __future__ import annotations
24from dataclasses import dataclass
25from typing import Any, Optional
27from .ref import DatasetRef
28from ..timespan import Timespan
31@dataclass
32class DatasetAssociation:
33 """A struct that represents the membership of a single dataset in a
34 single collection.
35 """
37 __slots__ = ("ref", "collection", "timespan")
39 ref: DatasetRef
40 """Resolved reference to a dataset (`DatasetRef`).
41 """
43 collection: str
44 """Name of a collection (`str`).
45 """
47 timespan: Optional[Timespan]
48 """Validity range of the dataset if this is a `~CollectionType.CALIBRATION`
49 collection (`Timespan` or `None`).
50 """
52 def __lt__(self, other: Any) -> bool:
53 # Allow sorting of associations
54 if not isinstance(other, type(self)):
55 return NotImplemented
57 return (self.ref, self.collection, self.timespan) < (other.ref, other.collection, other.timespan)