DataCoordinate¶
-
class
lsst.daf.butler.
DataCoordinate
¶ Bases:
lsst.daf.butler.core.utils.IndexedTupleDict
An immutable data ID dictionary that guarantees that its key-value pairs identify all required dimensions in a
DimensionGraph
.DataCoordinate
instances should usually be constructed via thestandardize
class method; the constructor is reserved for callers that can guarantee that thevalues
tuple has exactly the right elements.- Parameters
- graph
DimensionGraph
The dimensions identified by this instance.
- values
tuple
Tuple of primary key values for the given dimensions.
- graph
Notes
Like any data ID class,
DataCoordinate
behaves like a dictionary, mostly via methods inherited fromIndexedTupleDict
. LikeNamedKeyDict
, bothDimension
instances andstr
names thereof may be used as keys in lookup operations.Subclasses are permitted to support lookup for any dimension in
self.graph.dimensions
, but the base class only supports lookup for those inself.graph.required
, which is the minimal set needed to identify all others in aRegistry
. Both the base class and subclasses define comparisons, iterators, and thekeys
,values
, anditems
views to just theself.graph.required
subset in order to guarantee true (i.e. Liskov) substitutability.Attributes Summary
The dimensions identified by this data ID (
DimensionGraph
).The universe that defines all known dimensions compatible with this coordinate (
DimensionUniverse
).Methods Summary
byName
()Return a true
dict
keyed bystr
dimension name and the same values asself
.fingerprint
(update)Update a secure hash function with the values in this data ID.
get
(k[,d])items
()keys
()matches
(other)Test whether the values of all keys in both coordinates are equal.
standardize
([mapping, graph, universe])Adapt an arbitrary mapping and/or additional arguments into a true
DataCoordinate
, or augment an existing one.subset
(graph)Return a new
DataCoordinate
whose graph is a subset ofself.graph
.values
()Attributes Documentation
-
graph
¶ The dimensions identified by this data ID (
DimensionGraph
).Note that values are only required to be present for dimensions in
self.graph.required
; all others may be retrieved (from aRegistry
) given these.
-
universe
¶ The universe that defines all known dimensions compatible with this coordinate (
DimensionUniverse
).
Methods Documentation
-
byName
() → Dict[str, Any]¶ Return a true
dict
keyed bystr
dimension name and the same values asself
.
-
fingerprint
(update)¶ Update a secure hash function with the values in this data ID.
-
get
(k[, d]) → D[k] if k in D, else d. d defaults to None.¶
-
items
() → a set-like object providing a view on D's items¶
-
keys
() → a set-like object providing a view on D's keys¶
-
matches
(other: lsst.daf.butler.core.dimensions.coordinate.DataCoordinate) → bool¶ Test whether the values of all keys in both coordinates are equal.
- Parameters
- other
DataCoordinate
The other coordinate to compare to.
- other
- Returns
-
static
standardize
(mapping: Optional[Mapping[str, Any]] = None, *, graph: Optional[DimensionGraph] = None, universe: Optional[DimensionUniverse] = None, **kwds) → DataCoordinate¶ Adapt an arbitrary mapping and/or additional arguments into a true
DataCoordinate
, or augment an existing one.- Parameters
- mapping
Mapping
, optional An informal data ID that maps dimension names to their primary key values (may also be a true
DataCoordinate
).- graph
DimensionGraph
The dimensions to be identified by the new
DataCoordinate
. If not provided, will be inferred from the keys ofmapping
, anduniverse
must be provided unlessmapping
is already aDataCoordinate
.- universe
DimensionUniverse
All known dimensions and their relationships; used to expand and validate dependencies when
graph
is not provided.- kwds
Additional keyword arguments are treated like additional key-value pairs in
mapping
.
- mapping
- Returns
- coordinate
DataCoordinate
A validated
DataCoordinate
instance. May be a subclass instance if and only ifmapping
is a subclass instance andgraph
is a subset ofmapping.graph
.
- coordinate
- Raises
- TypeError
Raised if the set of optional arguments provided is not supported.
- KeyError
Raised if a key-value pair for a required dimension is missing.
Notes
Because
DataCoordinate
stores only values for required dimensions, key-value pairs for other related dimensions will be ignored and excluded from the result. This means that aDataCoordinate
may contain fewer key-value pairs than the informal data ID dictionary it was constructed from.
-
subset
(graph: lsst.daf.butler.core.dimensions.graph.DimensionGraph) → lsst.daf.butler.core.dimensions.coordinate.DataCoordinate¶ Return a new
DataCoordinate
whose graph is a subset ofself.graph
.Subclasses may override this method to return a subclass instance.
- Parameters
- graph
DimensionGraph
The dimensions identified by the returned
DataCoordinate
.
- graph
- Returns
- coordinate
DataCoordinate
A
DataCoordinate
instance that identifies only the given dimensions.
- coordinate
- Raises
- KeyError
Raised if
graph
is not a subset ofself.graph
, and hence one or more dimensions has no associated primary key value.
-
values
() → an object providing a view on D's values¶