DimensionKeyDict¶
-
class
lsst.daf.butler.
DimensionKeyDict
(other=None, *, universe=None, keys=None, factory=None, where=None)¶ Bases:
collections.abc.Mapping
An immutable mapping that uses
DimensionElement
instances as keys.Parameters: - other :
Mapping
Another mapping from which to copy keys and values. Keys that are string names will be converted into
DimensionElement
instances.- universe :
DimensionGraph
, optional All known dimensions; must be provided if
keys
is not aDimensionGraph
orDimensionSet
andother
is not itself aDimensionKeyDict
.- keys : iterable of
DimensionElement
, optional The exact keys that should be present in the constructed dictionary. If not provided, defaults to the keys in
other
. If provided, keys inother
that are not inkeys
will be ignored, and keys missing fromother
will associated with values constructed by callingfactory
.- factory : callable, optional
A no-argument callable that should be used to construct values for keys not provided.
- where : callable, optional
A predicate taking a single
DimensionElement
argument that indicates (by returningTrue
) whether a value for that element should be copied fromother
or (by returningFalse
) constructed by callingfactory
. PassingNone
(default) uses a callable that always returnsTrue
.
Notes
As with most other operations involving dimension objects, string names can be used lieu of
DimensionElement
instances in lookup (get
,__getitem__
,__contains__
).Because
DimensionKeyDict
instances are themselves immutable (in that new keys and values cannot be added, and the value associated with a key cannot be modified), they are frequently used to hold mutable values, such asset
ordict
objects, giving them a specific and limited kind of overall mutability (sometimes referred to as “interior” mutability). This is particularly useful in the dimension system, where in many contexts the set of relevant dimensions cannot change but the information associated with them can.Attributes Summary
universe
All known dimensions, including those not represented by this dict ( DimensionGraph
).Methods Summary
get
(k[,d])items
()keys
()updateValues
(other)Update nested dictionaries or sets from those in another nested mapping. values
()Attributes Documentation
-
universe
¶ All known dimensions, including those not represented by this dict (
DimensionGraph
).
Methods Documentation
-
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¶
-
updateValues
(other)¶ Update nested dictionaries or sets from those in another nested mapping.
Parameters: - other :
Mapping
Mapping containing values that should be used to update the corresponding values in
self
. May have eitherDimensionElement
orstr
names (or both) as keys.
Returns: - missing :
set
Any keys present in
other
that were not present inself
.
Notes
This method assumes the values of
self
are objects with anupdate
method (such asdict
orset
), and that the values ofother
are appropriate arguments to thoseupdate
methods (i.e. typically alsodict
orset
).- other :
-
values
() → an object providing a view on D's values¶
- other :