DataCoordinateIterable

class lsst.daf.butler.DataCoordinateIterable

Bases: collections.abc.Iterable, typing.Generic

An abstract base class for homogeneous iterables of data IDs.

All elements of a DataCoordinateIterable identify the same set of dimensions (given by the graph property) and generally have the same DataCoordinate.hasFull and DataCoordinate.hasRecords flag values.

Attributes Summary

graph The dimensions identified by these data IDs (DimensionGraph).
universe The universe that defines all known dimensions compatible with this iterable (DimensionUniverse).

Methods Summary

constrain(query, columns, …) Constrain a SQL query to include or relate to only data IDs in this iterable.
fromScalar(dataId) Return a DataCoordinateIterable containing the single data ID given.
hasFull() Return whether all data IDs in this iterable identify all dimensions, not just required dimensions.
hasRecords() Return whether all data IDs in this iterable contain DimensionRecord instances.
subset(graph) Return an iterable whose data IDs identify a subset of the dimensions that this one’s do.
toSequence() Transform this iterable into a DataCoordinateSequence.
toSet() Transform this iterable into a DataCoordinateSet.

Attributes Documentation

graph

The dimensions identified by these data IDs (DimensionGraph).

universe

The universe that defines all known dimensions compatible with this iterable (DimensionUniverse).

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 data IDs in this iterable.

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.

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 given.

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 the collections.abc.Sized (i.e. __len__) and collections.abc.Container (i.e. __contains__) interfaces as well as that of DataCoordinateIterable.

hasFull() → bool

Return whether all data IDs in this iterable identify all dimensions, not just required dimensions.

Returns:
state : bool

If True, all(d.hasFull() for d in iterable) is guaranteed. If False, no guarantees are made.

hasRecords() → bool

Return whether all data IDs in this iterable contain DimensionRecord instances.

Returns:
state : bool

If True, all(d.hasRecords() for d in iterable) is guaranteed. If False, no guarantees are made.

subset(graph: lsst.daf.butler.core.dimensions._graph.DimensionGraph) → lsst.daf.butler.core.dimensions._dataCoordinateIterable.DataCoordinateIterable

Return an iterable whose data IDs identify a subset of the dimensions that this one’s do.

Parameters:
graph : DimensionGraph

Dimensions to be identified by the data IDs in the returned iterable. Must be a subset of self.graph.

Returns:
iterable : DataCoordinateIterable

A DataCoordinateIterable with iterable.graph == graph. May be self if graph == self.graph. Elements are equivalent to those that would be created by calling DataCoordinate.subset on all elements in self, possibly with deduplication and/or reordeding (depending on the subclass, which may make more specific guarantees).

toSequence() → lsst.daf.butler.core.dimensions._dataCoordinateIterable.DataCoordinateSequence

Transform this iterable into a DataCoordinateSequence.

Returns:
seq : DataCoordinateSequence

A new DatasetCoordinateSequence with the same elements as self, in the same order. May be self if it is already a DataCoordinateSequence.

toSet() → lsst.daf.butler.core.dimensions._dataCoordinateIterable.DataCoordinateSet

Transform this iterable into a DataCoordinateSet.

Returns:
set : DataCoordinateSet

A DatasetCoordinateSet instance with the same elements as self, after removing any duplicates. May be self if it is already a DataCoordinateSet.