DimensionKeyDict¶
-
class
lsst.daf.butler.DimensionKeyDict(other=None, *, universe=None, keys=None, factory=None, where=None)¶ Bases:
collections.abc.MappingAn immutable mapping that uses
DimensionElementinstances as keys.Parameters: - other :
Mapping Another mapping from which to copy keys and values. Keys that are string names will be converted into
DimensionElementinstances.- universe :
DimensionGraph, optional All known dimensions; must be provided if
keysis not aDimensionGraphorDimensionSetandotheris 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 inotherthat are not inkeyswill be ignored, and keys missing fromotherwill 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
DimensionElementargument that indicates (by returningTrue) whether a value for that element should be copied fromotheror (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
DimensionElementinstances in lookup (get,__getitem__,__contains__).Because
DimensionKeyDictinstances 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 assetordictobjects, 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
universeAll 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 eitherDimensionElementorstrnames (or both) as keys.
Returns: - missing :
set Any keys present in
otherthat were not present inself.
Notes
This method assumes the values of
selfare objects with anupdatemethod (such asdictorset), and that the values ofotherare appropriate arguments to thoseupdatemethods (i.e. typically alsodictorset).- other :
-
values() → an object providing a view on D's values¶
- other :