NonemptyMapping¶
- class lsst.daf.butler.nonempty_mapping.NonemptyMapping(default_factory: Callable[[], _V])¶
Bases:
Mapping
[_K
,_V
]A
Mapping
that implicitly adds values (likedefaultdict
) but treats any that evaluate toFalse
as not present.- Parameters:
- default_factory
Callable
A callable that takes no arguments and returns a new instance of the value type.
- default_factory
Notes
Unlike
defaultdict
, this class implements onlycollections.abc.Mapping
, notMutableMapping
, and hence it can be modified only by invoking__getitem__
with a key that does not exist. It is expected that the value type will be a mutable container likeset
ordict
, and that an empty nested container should be considered equivalent to the absence of a key.Methods Summary
get
()D.get(k[,d]) -> D[k] if k in D, else d.
items
()keys
()values
()Methods Documentation
- get(key: _K) _V | None ¶
- get(key: _K, default: _T) _V | _T
D.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 ¶
- values() an object providing a view on D's values ¶