DimensionGraph¶
- 
class lsst.daf.butler.DimensionGraph(universe, dimensions=(), joins=(), optional=False)¶
- Bases: - object- An automatically-expanded collection of both - Dimensions and- DimensionJoins.- Parameters: - universe : DimensionGraph
- The ultimate graph the new graph should be a subset of. 
- dimensions : iterable of Dimensionorstr
- Dimensionobjects that should be included in the graph, or their string names. Note that the new graph will in general return more than these dimensions, due to expansion to include dependenies.
- joins : iterable of DimensionJoinorstr.
- DimensionJoinobjects that should be included in the graph, or their string names.
- optional : bool
- If - True, expand the graph to (recursively) include optional dependencies as well as required dependencies.
 - Notes - A - DimensionGraphbehaves much like a- DimensionSetcontaining only- Dimensionobjects, 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).
 - Unlike most other dimension classes, - DimensionGraphobjects can be constructed directly, but only after a special “universe”- DimensionGraphis constructed via a call to- fromConfig. A “universe” graph contains all dimension elements, and all other- DimensionGraphs or- DimensionSets constructed from that universe are subsets of it.- Attributes Summary - asSet- A set view of the - Dimensionsin- self(- DimensionSet).- elements- A set containing both - Dimensionand- DimensionJoinobjects (- DimensionSet).- leaves- Dimensions that are not required or optional dependencies of any other dimension in the graph ( - DimensionSet).- links- The names of all fields that uniquely identify these dimensions in a data ID dict ( - frozensetof- str).- names- The names of all elements ( - set-like, immutable).- optionals- A set containing all (recursive) optional dependencies of the dimensions in this graph that are not included in the graph itself ( - DimensionSet).- universe- The graph of all dimensions compatible with self ( - DimensionGraph).- Methods Summary - extract(elements[, optional])- Return a new graph containing the given elements. - findIf(predicate[, default])- Return the element in - selfthat matches the given predicate.- fromConfig([config])- Construct a “universe” - DimensionGraphfrom configuration.- 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. - intersection(*others[, optional])- Return a new graph containing all elements that are in both - self- isdisjoint(other)- Return - Trueif there are no dimensions in both- selfand- other, and- Falseotherwise.- issubset(other)- Return - Trueif all dimensions in- selfare also in- other.- issuperset(other)- Return - Trueif all dimensions in- otherare also in- self, and- Falseotherwise.- joins([summaries])- Return the - DimensionJoinobjects held by this graph.- union(*others[, optional])- Return a new graph containing all elements that are in - selfor any of the other given graphs.- withLink(link)- Return the set of - Dimensionand- DimensionJoinobjects that have the given link name in their primary or foreign keys.- Attributes Documentation - 
asSet¶
- A set view of the - Dimensionsin- self(- DimensionSet).
 - 
elements¶
- A set containing both - Dimensionand- DimensionJoinobjects (- DimensionSet).
 - 
leaves¶
- Dimensions that are not required or optional dependencies of any other dimension in the graph ( - DimensionSet).
 - 
links¶
- The names of all fields that uniquely identify these dimensions in a data ID dict ( - frozensetof- str).
 - 
names¶
- The names of all elements ( - set-like, immutable).- The order of the names is consistent with the iteration order of the - DimensionSetitself.
 - 
optionals¶
- A set containing all (recursive) optional dependencies of the dimensions in this graph that are not included in the graph itself ( - DimensionSet).
 - 
universe¶
- The graph of all dimensions compatible with self ( - DimensionGraph).- The universe of a - DimensionGraphthat is itself a universe is- self.
 - Methods Documentation - 
extract(elements, optional=False)¶
- Return a new graph containing the given elements. - Parameters: - elements : iterable of DimensionElementorstr
- Dimensions,- DimensionJoins, or names thereof. These must be in- selfor- self.joins().
- optional : bool
- If - True, expand the result to include optional dependencies as well as required dependencies.
 
- elements : iterable of 
 - 
findIf(predicate, default=None)¶
- Return the element in - selfthat matches the given predicate.- Parameters: - predicate : callable
- Callable that takes a single - DimensionElementargument and returns a- bool, 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. 
 
 - 
static fromConfig(config=None)¶
- Construct a “universe” - DimensionGraphfrom configuration.- Parameters: - config : DimensionConfig, optional
- Configuration specifying the elements and their relationships. If not provided, will be loaded from the default search path (see - ConfigSubset).
 - Returns: - universe : DimensionGraph
- A self-contained - DimensionGraphcontaining all of the elements defined in the given configuration.
 
- config : 
 - 
get(key, default=None)¶
- Return the element with the given name, or - defaultif it does not exist.- keymay also be a- Dimension, 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.
- Dimensionor- DimensionJointhat provides a unique region for this graph, or- Noneif there is no region or multiple regions.- holder.hasRegionis guaranteed to be- Trueif- holderis not- None.
 
- holder : 
 - 
intersection(*others, optional=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 both- selfand- other, and- Falseotherwise.- All graphs (including the empty graph) are disjoint with the empty graph. 
 - 
issubset(other)¶
- Return - Trueif all dimensions in- selfare also in- other.- The empty graph is a subset of all graphs (including the empty graph). 
 - 
issuperset(other)¶
- Return - Trueif all dimensions in- otherare also in- self, and- Falseotherwise.- 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 : 
 - 
union(*others, optional=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 : 
 - 
withLink(link)¶
- Return the set of - Dimensionand- DimensionJoinobjects that have the given link name in their primary or foreign keys.- Unlike most other - DimensionGraphoperations, this method does not limit its results to the elements included in- self.- Parameters: - link : str
- Primary key field name. 
 - Returns: - dimensions : DimensionSet
- Set potentially containing both - Dimensionand- DimensionJoinelements.
 
- link : 
 
- universe :