LSST Applications  22.0.1,22.0.1+01bcf6a671,22.0.1+046ee49490,22.0.1+05c7de27da,22.0.1+0c6914dbf6,22.0.1+1220d50b50,22.0.1+12fd109e95,22.0.1+1a1dd69893,22.0.1+1c910dc348,22.0.1+1ef34551f5,22.0.1+30170c3d08,22.0.1+39153823fd,22.0.1+611137eacc,22.0.1+771eb1e3e8,22.0.1+94e66cc9ed,22.0.1+9a075d06e2,22.0.1+a5ff6e246e,22.0.1+a7db719c1a,22.0.1+ba0d97e778,22.0.1+bfe1ee9056,22.0.1+c4e1e0358a,22.0.1+cc34b8281e,22.0.1+d640e2c0fa,22.0.1+d72a2e677a,22.0.1+d9a6b571bd,22.0.1+e485e9761b,22.0.1+ebe8d3385e
LSST Data Management Base Package
Public Member Functions | Public Attributes | List of all members
lsst.pipe.base.graphBuilder._DatasetDict Class Reference
Inheritance diagram for lsst.pipe.base.graphBuilder._DatasetDict:

Public Member Functions

def __init__ (self, *args, DimensionGraph universe)
 
_DatasetDict fromDatasetTypes (cls, Iterable[DatasetType] datasetTypes, *DimensionUniverse universe)
 
_DatasetDict fromSubset (cls, Iterable[DatasetType] datasetTypes, _DatasetDict first, *_DatasetDict rest)
 
DimensionGraph dimensions (self)
 
NamedKeyDict[DatasetType, DatasetRef] unpackSingleRefs (self)
 
NamedKeyDict[DatasetType, DatasetRef] unpackMultiRefs (self)
 
Iterator[DatasetRef] extract (self, DatasetType datasetType, Iterable[DataCoordinate] dataIds)
 

Public Attributes

 universe
 

Detailed Description

A custom dictionary that maps `DatasetType` to a nested dictionary of
the known `DatasetRef` instances of that type.

Parameters
----------
args
    Positional arguments are forwarded to the `dict` constructor.
universe : `DimensionUniverse`
    Universe of all possible dimensions.

Definition at line 63 of file graphBuilder.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pipe.base.graphBuilder._DatasetDict.__init__ (   self,
args,
DimensionGraph  universe 
)

Definition at line 74 of file graphBuilder.py.

74  def __init__(self, *args, universe: DimensionGraph):
75  super().__init__(*args)
76  self.universe = universe
77 

Member Function Documentation

◆ dimensions()

DimensionGraph lsst.pipe.base.graphBuilder._DatasetDict.dimensions (   self)
The union of all dimensions used by all dataset types in this
dictionary, including implied dependencies (`DimensionGraph`).

Definition at line 124 of file graphBuilder.py.

124  def dimensions(self) -> DimensionGraph:
125  """The union of all dimensions used by all dataset types in this
126  dictionary, including implied dependencies (`DimensionGraph`).
127  """
128  base = self.universe.empty
129  if len(self) == 0:
130  return base
131  return base.union(*[datasetType.dimensions for datasetType in self.keys()])
132 
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:49

◆ extract()

Iterator[DatasetRef] lsst.pipe.base.graphBuilder._DatasetDict.extract (   self,
DatasetType  datasetType,
Iterable[DataCoordinate]   dataIds 
)
Iterate over the contained `DatasetRef` instances that match the
given `DatasetType` and data IDs.

Parameters
----------
datasetType : `DatasetType`
    Dataset type to match.
dataIds : `Iterable` [ `DataCoordinate` ]
    Data IDs to match.

Returns
-------
refs : `Iterator` [ `DatasetRef` ]
    DatasetRef instances for which ``ref.datasetType == datasetType``
    and ``ref.dataId`` is in ``dataIds``.

Definition at line 163 of file graphBuilder.py.

164  ) -> Iterator[DatasetRef]:
165  """Iterate over the contained `DatasetRef` instances that match the
166  given `DatasetType` and data IDs.
167 
168  Parameters
169  ----------
170  datasetType : `DatasetType`
171  Dataset type to match.
172  dataIds : `Iterable` [ `DataCoordinate` ]
173  Data IDs to match.
174 
175  Returns
176  -------
177  refs : `Iterator` [ `DatasetRef` ]
178  DatasetRef instances for which ``ref.datasetType == datasetType``
179  and ``ref.dataId`` is in ``dataIds``.
180  """
181  refs = self[datasetType]
182  return (refs[dataId] for dataId in dataIds)
183 
184 

◆ fromDatasetTypes()

_DatasetDict lsst.pipe.base.graphBuilder._DatasetDict.fromDatasetTypes (   cls,
Iterable[DatasetType]  datasetTypes,
*DimensionUniverse  universe 
)
Construct a dictionary from a flat iterable of `DatasetType` keys.

Parameters
----------
datasetTypes : `iterable` of `DatasetType`
    DatasetTypes to use as keys for the dict.  Values will be empty
    dictionaries.
universe : `DimensionUniverse`
    Universe of all possible dimensions.

Returns
-------
dictionary : `_DatasetDict`
    A new `_DatasetDict` instance.

Definition at line 79 of file graphBuilder.py.

80  universe: DimensionUniverse) -> _DatasetDict:
81  """Construct a dictionary from a flat iterable of `DatasetType` keys.
82 
83  Parameters
84  ----------
85  datasetTypes : `iterable` of `DatasetType`
86  DatasetTypes to use as keys for the dict. Values will be empty
87  dictionaries.
88  universe : `DimensionUniverse`
89  Universe of all possible dimensions.
90 
91  Returns
92  -------
93  dictionary : `_DatasetDict`
94  A new `_DatasetDict` instance.
95  """
96  return cls({datasetType: {} for datasetType in datasetTypes}, universe=universe)
97 

◆ fromSubset()

_DatasetDict lsst.pipe.base.graphBuilder._DatasetDict.fromSubset (   cls,
Iterable[DatasetType]  datasetTypes,
_DatasetDict  first,
*_DatasetDict   rest 
)
Return a new dictionary by extracting items corresponding to the
given keys from one or more existing dictionaries.

Parameters
----------
datasetTypes : `iterable` of `DatasetType`
    DatasetTypes to use as keys for the dict.  Values will be obtained
    by lookups against ``first`` and ``rest``.
first : `_DatasetDict`
    Another dictionary from which to extract values.
rest
    Additional dictionaries from which to extract values.

Returns
-------
dictionary : `_DatasetDict`
    A new dictionary instance.

Definition at line 99 of file graphBuilder.py.

100  ) -> _DatasetDict:
101  """Return a new dictionary by extracting items corresponding to the
102  given keys from one or more existing dictionaries.
103 
104  Parameters
105  ----------
106  datasetTypes : `iterable` of `DatasetType`
107  DatasetTypes to use as keys for the dict. Values will be obtained
108  by lookups against ``first`` and ``rest``.
109  first : `_DatasetDict`
110  Another dictionary from which to extract values.
111  rest
112  Additional dictionaries from which to extract values.
113 
114  Returns
115  -------
116  dictionary : `_DatasetDict`
117  A new dictionary instance.
118  """
119  combined = ChainMap(first, *rest)
120  return cls({datasetType: combined[datasetType] for datasetType in datasetTypes},
121  universe=first.universe)
122 

◆ unpackMultiRefs()

NamedKeyDict[DatasetType, DatasetRef] lsst.pipe.base.graphBuilder._DatasetDict.unpackMultiRefs (   self)
Unpack nested multi-element `DatasetRef` dicts into a new
mapping with `DatasetType` keys and `set` of `DatasetRef` values.

Returns
-------
dictionary : `NamedKeyDict`
    Dictionary mapping `DatasetType` to `DatasetRef`, with both
    `DatasetType` instances and string names usable as keys.

Definition at line 151 of file graphBuilder.py.

151  def unpackMultiRefs(self) -> NamedKeyDict[DatasetType, DatasetRef]:
152  """Unpack nested multi-element `DatasetRef` dicts into a new
153  mapping with `DatasetType` keys and `set` of `DatasetRef` values.
154 
155  Returns
156  -------
157  dictionary : `NamedKeyDict`
158  Dictionary mapping `DatasetType` to `DatasetRef`, with both
159  `DatasetType` instances and string names usable as keys.
160  """
161  return NamedKeyDict({datasetType: list(refs.values()) for datasetType, refs in self.items()})
162 
daf::base::PropertyList * list
Definition: fits.cc:913

◆ unpackSingleRefs()

NamedKeyDict[DatasetType, DatasetRef] lsst.pipe.base.graphBuilder._DatasetDict.unpackSingleRefs (   self)
Unpack nested single-element `DatasetRef` dicts into a new
mapping with `DatasetType` keys and `DatasetRef` values.

This method assumes that each nest contains exactly one item, as is the
case for all "init" datasets.

Returns
-------
dictionary : `NamedKeyDict`
    Dictionary mapping `DatasetType` to `DatasetRef`, with both
    `DatasetType` instances and string names usable as keys.

Definition at line 133 of file graphBuilder.py.

133  def unpackSingleRefs(self) -> NamedKeyDict[DatasetType, DatasetRef]:
134  """Unpack nested single-element `DatasetRef` dicts into a new
135  mapping with `DatasetType` keys and `DatasetRef` values.
136 
137  This method assumes that each nest contains exactly one item, as is the
138  case for all "init" datasets.
139 
140  Returns
141  -------
142  dictionary : `NamedKeyDict`
143  Dictionary mapping `DatasetType` to `DatasetRef`, with both
144  `DatasetType` instances and string names usable as keys.
145  """
146  def getOne(refs: Dict[DataCoordinate, DatasetRef]) -> DatasetRef:
147  ref, = refs.values()
148  return ref
149  return NamedKeyDict({datasetType: getOne(refs) for datasetType, refs in self.items()})
150 

Member Data Documentation

◆ universe

lsst.pipe.base.graphBuilder._DatasetDict.universe

Definition at line 76 of file graphBuilder.py.


The documentation for this class was generated from the following file: