DataCoordinateSet¶
-
class
lsst.daf.butler.
DataCoordinateSet
(dataIds: AbstractSet[lsst.daf.butler.core.dimensions._coordinate.DataCoordinate], graph: lsst.daf.butler.core.dimensions._graph.DimensionGraph, *, hasFull: Optional[bool] = None, hasRecords: Optional[bool] = None, check: bool = True)¶ Bases:
lsst.daf.butler.core.dimensions._dataCoordinateIterable._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 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.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 givengraph
and state flags at construction. IfFalse
, no checking will occur.
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.graph
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).Attributes Summary
graph
Dimensions identified by these data IDs ( DimensionGraph
).universe
Universe that defines all known compatible dimensions. Methods Summary
constrain
(query, columns, …)Constrain a SQL query to include or relate to only known data IDs. difference
(other)Return a new set with all data IDs in this that are not in other. fromScalar
(dataId)Return a DataCoordinateIterable
containing the single data ID.hasFull
()Indicate if all data IDs in this iterable identify all dimensions. hasRecords
()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 self
andother
.issubset
(other)Test whether self
contains all data IDs inother
.issuperset
(other)Test whether other
contains 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. toSequence
()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
¶ Dimensions identified by these data IDs (
DimensionGraph
).
-
universe
¶ Universe that defines all known compatible dimensions.
Methods Documentation
-
constrain
(query: lsst.daf.butler.core.simpleQuery.SimpleQuery, columns: Callable[[str], sqlalchemy.sql.elements.ColumnElement]) → None¶ Constrain a SQL query to include or relate to only known data IDs.
Parameters: - query :
SimpleQuery
Struct that represents the SQL query to constrain, either by appending to its WHERE clause, joining a new table or subquery, or both.
- columns :
Callable
A callable that accepts
str
dimension names and returns SQLAlchemy objects representing a column for that dimension’s primary key value in the query.
- query :
-
difference
(other: lsst.daf.butler.core.dimensions._dataCoordinateIterable.DataCoordinateIterable) → lsst.daf.butler.core.dimensions._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
.
Returns: - intersection :
DataCoordinateSet
A new
DataCoordinateSet
instance.
- other :
-
static
fromScalar
(dataId: lsst.daf.butler.core.dimensions._coordinate.DataCoordinate) → lsst.daf.butler.core.dimensions._dataCoordinateIterable._ScalarDataCoordinateIterable¶ Return a
DataCoordinateIterable
containing the single data ID.Parameters: - dataId :
DataCoordinate
Data ID to adapt. Must be a true
DataCoordinate
instance, not an arbitrary mapping. No runtime checking is performed.
Returns: - iterable :
DataCoordinateIterable
A
DataCoordinateIterable
instance 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
.
- dataId :
-
hasFull
() → bool¶ Indicate if all data IDs in this iterable identify all dimensions.
Not just required dimensions.
Returns:
-
hasRecords
() → bool¶ Return whether all data IDs in this iterable contain records.
Returns:
-
intersection
(other: lsst.daf.butler.core.dimensions._dataCoordinateIterable.DataCoordinateIterable) → lsst.daf.butler.core.dimensions._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
.
Returns: - intersection :
DataCoordinateSet
A new
DataCoordinateSet
instance.
- other :
-
isdisjoint
(other: lsst.daf.butler.core.dimensions._dataCoordinateIterable.DataCoordinateIterable) → bool¶ Test whether there are no data IDs in both
self
andother
.Parameters: - other :
DataCoordinateIterable
An iterable of data IDs with
other.graph == self.graph
.
Returns: - other :
-
issubset
(other: lsst.daf.butler.core.dimensions._dataCoordinateIterable.DataCoordinateIterable) → bool¶ Test whether
self
contains all data IDs inother
.Parameters: - other :
DataCoordinateIterable
An iterable of data IDs with
other.graph == self.graph
.
Returns: - other :
-
issuperset
(other: lsst.daf.butler.core.dimensions._dataCoordinateIterable.DataCoordinateIterable) → bool¶ Test whether
other
contains all data IDs inself
.Parameters: - other :
DataCoordinateIterable
An iterable of data IDs with
other.graph == self.graph
.
Returns: - other :
-
subset
(graph: lsst.daf.butler.core.dimensions._graph.DimensionGraph) → lsst.daf.butler.core.dimensions._dataCoordinateIterable.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
.
Returns: - set :
DataCoordinateSet
A
DataCoordinateSet
withset.graph == graph
. Will beself
ifgraph == self.graph
. Elements are equivalent to those that would be created by callingDataCoordinate.subset
on all elements inself
, with deduplication but and in arbitrary order.
- graph :
-
symmetric_difference
(other: lsst.daf.butler.core.dimensions._dataCoordinateIterable.DataCoordinateIterable) → lsst.daf.butler.core.dimensions._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
.
Returns: - intersection :
DataCoordinateSet
A new
DataCoordinateSet
instance.
- other :
-
toSequence
() → lsst.daf.butler.core.dimensions._dataCoordinateIterable.DataCoordinateSequence¶ Transform this iterable into a
DataCoordinateSequence
.Returns: - seq :
DataCoordinateSequence
A new
DatasetCoordinateSequence
with the same elements asself
, in the same order. May beself
if it is already aDataCoordinateSequence
.
- seq :
-
toSet
() → lsst.daf.butler.core.dimensions._dataCoordinateIterable.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: lsst.daf.butler.core.dimensions._dataCoordinateIterable.DataCoordinateIterable) → lsst.daf.butler.core.dimensions._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
.
Returns: - intersection :
DataCoordinateSet
A new
DataCoordinateSet
instance.
- other :
- dataIds :