DimensionGraph¶
-
class
lsst.daf.butler.DimensionGraph(universe, elements, dimensions, joins)¶ Bases:
objectAn automatically-expanded collection of both
Dimensions andDimensionJoins.Notes
DimensionGraphs can only be constructed from an instance of a special subclass,DimensionUniverse, which itself constructed via from configuration (seeDimensionUniverse.fromConfig). A universe graph contains all dimension elements, and all otherDimensionGraphs orDimensionSets constructed from that universe are subsets of it.A
DimensionGraphbehaves much like aDimensionSetcontaining onlyDimensionobjects, with a few key differences:- A
DimensionGraphalways contains all of the required dependencies of any of its elements. That means some standard set operations (namelysymmetric_difference/^anddifference/-) can’t behave the way one would expect, and hence aren’t available (that’s whyDimensionGraphdoesn’t inherit fromcollections.abc.SetwhileDimensionSetdoes). - Any
DimensionJoins whose dependencies are present in the graph are accessible via thejoins()method (which is why we consider this graph - it contains the relationships as well as the elements of a system of dimensions).
Attributes Summary
elementsA set containing both DimensionandDimensionJoinobjects (DimensionSet).leavesDimensions that are not required or implied dependencies of any other dimension in the graph ( DimensionSet).namesThe names of all elements ( set-like, immutable).universeThe graph of all dimensions compatible with self ( DimensionGraph).Methods Summary
findIf(predicate[, default])Return the element in selfthat matches the given predicate.get(key[, default])Return the element with the given name, or defaultif it does not exist.getRegionHolder()Return the Dimension that provides the spatial region for this combination of dimensions. implied([only])Return the (recursive) implied dependencies of the dimensions in this graph. intersection(*others[, implied])Return a new graph containing all elements that are in both selfisdisjoint(other)Return Trueif there are no dimensions in bothselfandother, andFalseotherwise.issubset(other)Return Trueif all dimensions inselfare also inother.issuperset(other)Return Trueif all dimensions inotherare also inself, andFalseotherwise.joins([summaries])Return the DimensionJoinobjects held by this graph.links()Return the names of all fields that uniquely identify these dimensions in a data ID dict. toSet()Return a DimensionSetwith the same dimensions asself.union(*others[, implied])Return a new graph containing all elements that are in selfor any of the other given graphs.Attributes Documentation
-
elements¶ A set containing both
DimensionandDimensionJoinobjects (DimensionSet).
-
leaves¶ Dimensions that are not required or implied dependencies of any other dimension in the graph (
DimensionSet).
-
names¶ The names of all elements (
set-like, immutable).The order of the names is consistent with the iteration order of the
DimensionSetitself.
-
universe¶ The graph of all dimensions compatible with self (
DimensionGraph).The universe of a
DimensionGraphthat is itself a universe isself.
Methods Documentation
-
findIf(predicate, default=None)¶ Return the element in
selfthat matches the given predicate.Parameters: - predicate : callable
Callable that takes a single
DimensionElementargument and returns abool, indicating whether the given value should be returned.- default :
DimensionElement, optional Object to return if no matching elements are found.
Returns: - matching :
DimensionElement Element matching the given predicate.
Raises: - ValueError
Raised if multiple elements match the given predicate.
-
get(key, default=None)¶ Return the element with the given name, or
defaultif it does not exist.keymay also be aDimension, in which case an equivalent object will be returned.
-
getRegionHolder()¶ Return the Dimension that provides the spatial region for this combination of dimensions.
Returns: - holder :
DimensionElement, or None. DimensionorDimensionJointhat provides a unique region for this graph, orNoneif there is no region or multiple regions.holder.hasRegionis guaranteed to beTrueifholderis notNone.
- holder :
-
implied(only=True)¶ Return the (recursive) implied dependencies of the dimensions in this graph.
Parameters: Returns: - set :
DimensionSet A set containing dimensions that are implied dependencies of those in the graph, possibly (if
onlyisFalse) along with those in the graph.
- set :
-
intersection(*others, implied=False)¶ - Return a new graph containing all elements that are in both
self - and all of the other given graphs.
Parameters: Returns: - result :
DimensionGraph Graph containing all elements in all of the inputs.
- Return a new graph containing all elements that are in both
-
isdisjoint(other)¶ Return
Trueif there are no dimensions in bothselfandother, andFalseotherwise.All graphs (including the empty graph) are disjoint with the empty graph.
-
issubset(other)¶ Return
Trueif all dimensions inselfare also inother.The empty graph is a subset of all graphs (including the empty graph).
-
issuperset(other)¶ Return
Trueif all dimensions inotherare also inself, andFalseotherwise.All graphs (including the empty graph) are supersets of the empty graph.
-
joins(summaries=True)¶ Return the
DimensionJoinobjects held by this graph.Parameters: Returns: - joins :
DimensionSet The joins held by this graph, possibly filtered.
- joins :
-
links()¶ Return the names of all fields that uniquely identify these dimensions in a data ID dict.
Returns:
-
toSet()¶ Return a
DimensionSetwith the same dimensions asself.
-
union(*others, implied=False)¶ Return a new graph containing all elements that are in
selfor any of the other given graphs.Parameters: Returns: - result :
DimensionGraph Graph containing any elements in any of the inputs.
- result :
- A