DataCoordinateSet¶
- class lsst.daf.butler.DataCoordinateSet(dataIds: AbstractSet[DataCoordinate], graph: DimensionGraph, *, hasFull: bool | None = None, hasRecords: bool | None = None, check: bool = True)¶
Bases:
_DataCoordinateCollectionBaseIterable iteration that is set-like.
A
DataCoordinateIterableimplementation that adds some set-like functionality, and is backed by a true set-like object.- Parameters:
- dataIds
collections.abc.Set[DataCoordinate] A set of
DataCoordinateinstances, with dimensions equal tograph. If this is a mutable object, the caller must be able to guarantee that it will not be modified by any other holders.- graph
DimensionGraph Dimensions identified by all data IDs in the set.
- hasFull
bool, optional If
True, the caller guarantees thatDataCoordinate.hasFullreturnsTruefor all given data IDs. IfFalse, no such guarantee is made, andDataCoordinateSet.hasFullwill always returnFalse. IfNone(default),DataCoordinateSet.hasFullwill be computed from the given data IDs, immediately ifcheckisTrue, or on first use ifcheckisFalse.- hasRecords
bool, optional If
True, the caller guarantees thatDataCoordinate.hasRecordsreturnsTruefor all given data IDs. IfFalse, no such guarantee is made andDataCoordinateSet.hasRecordswill always returnFalse. IfNone(default),DataCoordinateSet.hasRecordswill be computed from the given data IDs, immediately ifcheckisTrue, or on first use ifcheckisFalse.- check: `bool`, optional
If
True(default) check that all data IDs are consistent with the givengraphand state flags at construction. IfFalse, no checking will occur.
- dataIds
Notes
DataCoordinateSetdoes not formally implement thecollections.abc.Setinterface, because that requires many binary operations to accept any set-like object as the other argument (regardless of what its elements might be), and it’s much easier to ensure those operations never behave surprisingly if we restrict them toDataCoordinateSetor (sometimes)DataCoordinateIterable, and in most cases restrict that they identify the same dimensions. In particular:a
DataCoordinateSetwill compare as not equal to any object that is not aDataCoordinateSet, even native Python sets containing the exact same elements;subset/superset comparison _operators_ (
<,>,<=,>=) require both operands to beDataCoordinateSetinstances that have the same dimensions (i.e.graphattribute);issubset,issuperset, andisdisjointrequire the other argument to be aDataCoordinateIterablewith the same dimensions;operators that create new sets (
&,|,^,-) require both operands to beDataCoordinateSetinstances that have the same dimensions _and_ the samedtype;named methods that create new sets (
intersection,union,symmetric_difference,difference) require the other operand to be aDataCoordinateIterablewith the same dimensions _and_ the samedtype.
In addition, when the two operands differ in the return values of
hasFulland/orhasRecords, we make no guarantees about what those methods will return on the newDataCoordinateSet(other than that they will accurately reflect what elements are in the new set - we just don’t control which elements are contributed by each operand).Attributes Summary
Dimensions identified by these data IDs (
DimensionGraph).Universe that defines all known compatible dimensions.
Methods Summary
difference(other)Return a new set with all data IDs in this that are not in other.
fromScalar(dataId)Return a
DataCoordinateIterablecontaining the single data ID.hasFull()Indicate if all data IDs in this iterable identify all dimensions.
Return whether all data IDs in this iterable contain records.
intersection(other)Return a new set that contains all data IDs from parameters.
isdisjoint(other)Test whether there are no data IDs in both
selfandother.issubset(other)Test whether
selfcontains all data IDs inother.issuperset(other)Test whether
othercontains all data IDs inself.subset(graph)Return a set whose data IDs identify a subset.
symmetric_difference(other)Return a new set with all data IDs in either parameters, not both.
Transform this iterable into a
DataCoordinateSequence.toSet()Transform this iterable into a
DataCoordinateSet.union(other)Return a new set that contains all data IDs in either parameters.
Attributes Documentation
- graph¶
- universe¶
Universe that defines all known compatible dimensions.
Methods Documentation
- difference(other: DataCoordinateIterable) DataCoordinateSet¶
Return a new set with all data IDs in this that are not in other.
- Parameters:
- other
DataCoordinateIterable An iterable of data IDs with
other.graph == self.graph.
- other
- Returns:
- intersection
DataCoordinateSet A new
DataCoordinateSetinstance.
- intersection
- static fromScalar(dataId: DataCoordinate) _ScalarDataCoordinateIterable¶
Return a
DataCoordinateIterablecontaining the single data ID.- Parameters:
- dataId
DataCoordinate Data ID to adapt. Must be a true
DataCoordinateinstance, not an arbitrary mapping. No runtime checking is performed.
- dataId
- Returns:
- iterable
DataCoordinateIterable A
DataCoordinateIterableinstance of unspecified (i.e. implementation-detail) subclass. Guaranteed to implement thecollections.abc.Sized(i.e.__len__) andcollections.abc.Container(i.e.__contains__) interfaces as well as that ofDataCoordinateIterable.
- iterable
- hasFull() bool¶
Indicate if all data IDs in this iterable identify all dimensions.
Not just required dimensions.
- intersection(other: DataCoordinateIterable) DataCoordinateSet¶
Return a new set that contains all data IDs from parameters.
- Parameters:
- other
DataCoordinateIterable An iterable of data IDs with
other.graph == self.graph.
- other
- Returns:
- intersection
DataCoordinateSet A new
DataCoordinateSetinstance.
- intersection
- isdisjoint(other: DataCoordinateIterable) bool¶
Test whether there are no data IDs in both
selfandother.- Parameters:
- other
DataCoordinateIterable An iterable of data IDs with
other.graph == self.graph.
- other
- Returns:
- issubset(other: DataCoordinateIterable) bool¶
Test whether
selfcontains all data IDs inother.- Parameters:
- other
DataCoordinateIterable An iterable of data IDs with
other.graph == self.graph.
- other
- Returns:
- issuperset(other: DataCoordinateIterable) bool¶
Test whether
othercontains all data IDs inself.- Parameters:
- other
DataCoordinateIterable An iterable of data IDs with
other.graph == self.graph.
- other
- Returns:
- subset(graph: DimensionGraph) DataCoordinateSet¶
Return a set whose data IDs identify a subset.
- Parameters:
- graph
DimensionGraph Dimensions to be identified by the data IDs in the returned iterable. Must be a subset of
self.graph.
- graph
- Returns:
- set
DataCoordinateSet A
DataCoordinateSetwithset.graph == graph. Will beselfifgraph == self.graph. Elements are equivalent to those that would be created by callingDataCoordinate.subseton all elements inself, with deduplication but and in arbitrary order.
- set
- symmetric_difference(other: DataCoordinateIterable) DataCoordinateSet¶
Return a new set with all data IDs in either parameters, not both.
- Parameters:
- other
DataCoordinateIterable An iterable of data IDs with
other.graph == self.graph.
- other
- Returns:
- intersection
DataCoordinateSet A new
DataCoordinateSetinstance.
- intersection
- toSequence() DataCoordinateSequence¶
Transform this iterable into a
DataCoordinateSequence.- Returns:
- seq
DataCoordinateSequence A new
DatasetCoordinateSequencewith the same elements asself, in the same order. May beselfif it is already aDataCoordinateSequence.
- seq
- toSet() DataCoordinateSet¶
Transform this iterable into a
DataCoordinateSet.- Returns:
- set
DataCoordinateSet A
DatasetCoordinateSetinstance with the same elements asself, after removing any duplicates. May beselfif it is already aDataCoordinateSet.
- set
- union(other: DataCoordinateIterable) DataCoordinateSet¶
Return a new set that contains all data IDs in either parameters.
- Parameters:
- other
DataCoordinateIterable An iterable of data IDs with
other.graph == self.graph.
- other
- Returns:
- intersection
DataCoordinateSet A new
DataCoordinateSetinstance.
- intersection