DataCoordinateIterable

class lsst.daf.butler.DataCoordinateIterable

Bases: Iterable[DataCoordinate]

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

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.

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.

subset(graph)

Return a subset iterable.

toSequence()

Transform this iterable into a DataCoordinateSequence.

toSet()

Transform this iterable into a DataCoordinateSet.

Attributes Documentation

graph

Dimensions identified by these data IDs (DimensionGraph).

universe

Universe that defines all known compatible dimensions.

(DimensionUniverse).

Methods Documentation

constrain(query: SimpleQuery, columns: Callable[[str], ColumnElement]) None

Constrain a SQL query to include or relate to only known data IDs.

Parameters:
querySimpleQuery

Struct that represents the SQL query to constrain, either by appending to its WHERE clause, joining a new table or subquery, or both.

columnsCallable

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: DataCoordinate) _ScalarDataCoordinateIterable

Return a DataCoordinateIterable containing the single data ID.

Parameters:
dataIdDataCoordinate

Data ID to adapt. Must be a true DataCoordinate instance, not an arbitrary mapping. No runtime checking is performed.

Returns:
iterableDataCoordinateIterable

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.

abstract hasFull() bool

Indicate if all data IDs in this iterable identify all dimensions.

Not just required dimensions.

Returns:
statebool

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

abstract hasRecords() bool

Return whether all data IDs in this iterable contain records.

Returns:
statebool

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

abstract subset(graph: DimensionGraph) DataCoordinateIterable

Return a subset iterable.

This subset iterable returns data IDs that identify a subset of the dimensions that this one’s do.

Parameters:
graphDimensionGraph

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

Returns:
iterableDataCoordinateIterable

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 reordering (depending on the subclass, which may make more specific guarantees).

toSequence() DataCoordinateSequence

Transform this iterable into a DataCoordinateSequence.

Returns:
seqDataCoordinateSequence

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

toSet() DataCoordinateSet

Transform this iterable into a DataCoordinateSet.

Returns:
setDataCoordinateSet

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