DataCoordinateSet¶
- class lsst.daf.butler.DataCoordinateSet(dataIds: Set[DataCoordinate], *, dimensions: Iterable[str] | DimensionGroup | None = None, hasFull: bool | None = None, hasRecords: bool | None = None, check: bool = True, universe: DimensionUniverse | None = None)¶
Bases:
_DataCoordinateCollectionBase
Iterable iteration that is set-like.
A
DataCoordinateIterable
implementation that adds some set-like functionality, and is backed by a true set-like object.- Parameters:
- dataIds
collections.abc.Set
[DataCoordinate
] A set of
DataCoordinate
instances, with dimensions equal todimensions
. If this is a mutable object, the caller must be able to guarantee that it will not be modified by any other holders.- dimensions
Iterable
[str
],DimensionGroup
Dimensions identified by all data IDs in the collection.
- hasFull
bool
, optional If
True
, the caller guarantees thatDataCoordinate.hasFull
returnsTrue
for all given data IDs. IfFalse
, no such guarantee is made, andDataCoordinateSet.hasFull
will always returnFalse
. IfNone
(default),DataCoordinateSet.hasFull
will be computed from the given data IDs, immediately ifcheck
isTrue
, or on first use ifcheck
isFalse
.- hasRecords
bool
, optional If
True
, the caller guarantees thatDataCoordinate.hasRecords
returnsTrue
for all given data IDs. IfFalse
, no such guarantee is made andDataCoordinateSet.hasRecords
will always returnFalse
. IfNone
(default),DataCoordinateSet.hasRecords
will be computed from the given data IDs, immediately ifcheck
isTrue
, or on first use ifcheck
isFalse
.- check
bool
, optional If
True
(default) check that all data IDs are consistent with the givendimensions
and state flags at construction. IfFalse
, no checking will occur.- universe
DimensionUniverse
Object that manages all dimension definitions.
- dataIds
Notes
DataCoordinateSet
does not formally implement thecollections.abc.Set
interface, 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 toDataCoordinateSet
or (sometimes)DataCoordinateIterable
, and in most cases restrict that they identify the same dimensions. In particular:a
DataCoordinateSet
will 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 beDataCoordinateSet
instances that have the same dimensions (i.e.dimensions
attribute);issubset
,issuperset
, andisdisjoint
require the other argument to be aDataCoordinateIterable
with the same dimensions;operators that create new sets (
&
,|
,^
,-
) require both operands to beDataCoordinateSet
instances 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 aDataCoordinateIterable
with the same dimensions _and_ the samedtype
.
In addition, when the two operands differ in the return values of
hasFull
and/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).Methods Summary
difference
(other)Return a new set with all data IDs in this that are not in other.
intersection
(other)Return a new set that contains all data IDs from parameters.
isdisjoint
(other)Test whether there are no data IDs in both
self
andother
.issubset
(other)Test whether
self
contains all data IDs inother
.issuperset
(other)Test whether
other
contains all data IDs inself
.subset
(dimensions)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.
toSet
()Transform this iterable into a
DataCoordinateSet
.union
(other)Return a new set that contains all data IDs in either parameters.
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.dimensions == self.dimensions
.
- other
- Returns:
- intersection
DataCoordinateSet
A new
DataCoordinateSet
instance.
- intersection
- 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.dimensions == self.dimensions
.
- other
- Returns:
- intersection
DataCoordinateSet
A new
DataCoordinateSet
instance.
- intersection
- isdisjoint(other: DataCoordinateIterable) bool ¶
Test whether there are no data IDs in both
self
andother
.- Parameters:
- other
DataCoordinateIterable
An iterable of data IDs with
other._dimensions == self._dimensions
.
- other
- Returns:
- issubset(other: DataCoordinateIterable) bool ¶
Test whether
self
contains all data IDs inother
.- Parameters:
- other
DataCoordinateIterable
An iterable of data IDs with
other.dimensions == self.dimensions
.
- other
- Returns:
- issuperset(other: DataCoordinateIterable) bool ¶
Test whether
other
contains all data IDs inself
.- Parameters:
- other
DataCoordinateIterable
An iterable of data IDs with
other.dimensions == self.dimensions
.
- other
- Returns:
- subset(dimensions: DimensionGroup | Iterable[str]) DataCoordinateSet ¶
Return a set whose data IDs identify a subset.
- Parameters:
- dimensions
DimensionGroup
orIterable
[str
] Dimensions to be identified by the data IDs in the returned iterable. Must be a subset of
self.dimensions
.
- dimensions
- Returns:
- set
DataCoordinateSet
A
DataCoordinateSet
withset.dimensions == dimensions
. Will beself
ifdimensions == self.dimensions
. Elements are equivalent to those that would be created by callingDataCoordinate.subset
on all elements inself
, with deduplication 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.dimensions == self.dimensions
.
- other
- Returns:
- intersection
DataCoordinateSet
A new
DataCoordinateSet
instance.
- intersection
- toSet() DataCoordinateSet ¶
Transform this iterable into a
DataCoordinateSet
.- Returns:
- set
DataCoordinateSet
A
DatasetCoordinateSet
instance with the same elements asself
, after removing any duplicates. May beself
if 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.dimensions == self.dimensions
.
- other
- Returns:
- intersection
DataCoordinateSet
A new
DataCoordinateSet
instance.
- intersection