DimensionGraph¶
-
class
lsst.daf.butler.DimensionGraph¶ Bases:
objectAn immutable, dependency-complete collection of dimensions.
DimensionGraphbehaves in many respects like a set ofDimensioninstances that maintains several special subsets and supersets of relatedDimensionElementinstances. It does not fully implement thecollections.abc.Setinterface, as its automatic expansion of dependencies would make set difference and XOR operations behave surprisingly.It also provides dict-like lookup of
DimensionElementinstances from their names.Parameters: - universe :
DimensionUniverse The special graph of all known dimensions of which this graph will be a subset.
- dimensions : iterable of
Dimension, optional An iterable of
Dimensioninstances that must be included in the graph. All (recursive) dependencies of these dimensions will also be included. At most one ofdimensionsandnamesmust be provided.- names : iterable of
str, optional An iterable of the names of dimensiosn that must be included in the graph. All (recursive) dependencies of these dimensions will also be included. At most one of
dimensionsandnamesmust be provided.- conform :
bool, optional If
True(default), expand to include dependencies.Falseshould only be used for callers that can guarantee that other arguments are already correctly expanded, and is primarily for internal use.
Notes
DimensionGraphshould be used instead of other collections in any context where a collection of dimensions is required and aDimensionUniverseis available.While
DimensionUniverseinherits fromDimensionGraph, it should otherwise not be used as a base class.Attributes Summary
namesA set of the names of all dimensions in the graph ( KeysView).Methods Summary
get(name, default)Return the element with the given name. getSpatial(*, independent, prefer)Return the elements that are associated with spatial regions, possibly with some filtering. getTemporal(*, independent, prefer)Return the elements that are associated with a timespan, possibly with some filtering. intersection(*others)Construct a new graph containing only dimensions in all of the operands. isdisjoint(other)Test whether the intersection of two graphs is empty. issubset(other)Test whether all dimensions in selfare also inother.issuperset(other)Test whether all dimensions in otherare also inself.union(*others)Construct a new graph containing all dimensions in any of the operands. Attributes Documentation
-
names¶ A set of the names of all dimensions in the graph (
KeysView).
Methods Documentation
-
get(name: str, default: Any = None) → DimensionElement¶ Return the element with the given name.
This lookup covers all
DimensionElementinstances inself.elements, not just trueDimensioninstances).
-
getSpatial(*, independent: bool = True, prefer: Optional[Iterable[DimensionElement]] = None) → NamedValueSet[DimensionElement]¶ Return the elements that are associated with spatial regions, possibly with some filtering.
Parameters: - independent :
bool If
True(default) ensure that all returned elements are independent of each other, by resolving any dependencies between spatial elements in favor of the dependent one (which is the one with the smaller, more precise region). A graph that includes both “tract” and “patch”, for example, would have only “patch” returned here ifindependentisTrue. IfFalse, all spatial elements are returned.- prefer : iterable of
DimensionElement Elements that should be returned instead of their dependents when
independentisTrue(ignored ifindependentisFalse). For example, passingprefer=[tract]to a graph with both “tract” and “patch” would result in only “tract” being returned.
Returns: - spatial :
NamedValueSetofDimensionElement Elements that have
DimensionElement.spatialTrue, filtered as specified by the arguments.
- independent :
-
getTemporal(*, independent: bool = True, prefer: Optional[Iterable[DimensionElement]] = None) → NamedValueSet[DimensionElement]¶ Return the elements that are associated with a timespan, possibly with some filtering.
Parameters: - independent :
bool If
True(default) ensure that all returned elements are independent of each other, by resolving any dependencies between spatial elements in favor of the dependent one (which is the one with the smaller, more precise timespans).- prefer : iterable of
DimensionElement Elements that should be returned instead of their dependents when
independentisTrue(ignored ifindependentisFalse).
Returns: - temporal :
NamedValueSetofDimensionElement Elements that have
DimensionElement.temporalTrue, filtered as specified by the arguments.
- independent :
-
intersection(*others)¶ Construct a new graph containing only dimensions in all of the operands.
-
isdisjoint(other: lsst.daf.butler.core.dimensions.graph.DimensionGraph) → bool¶ Test whether the intersection of two graphs is empty.
Returns
Trueif either operand is the empty.
-
issubset(other: lsst.daf.butler.core.dimensions.graph.DimensionGraph) → bool¶ Test whether all dimensions in
selfare also inother.Returns
Trueifselfis empty.
-
issuperset(other: lsst.daf.butler.core.dimensions.graph.DimensionGraph) → bool¶ Test whether all dimensions in
otherare also inself.Returns
Trueifotheris empty.
-
union(*others)¶ Construct a new graph containing all dimensions in any of the operands.
The elements of the returned graph may exceed the naive union of their elements, as some
DimensionElementinstances are included in graphs whenever multiple dimensions are present, and those dependency dimensions could have been provided by different operands.
- universe :