BinaryOperation

class lsst.daf.relation.BinaryOperation

Bases: abc.ABC

An abstract base class for operations that act on a pair of relations.

See also

Operations

Notes

A BinaryOperation represents the operation itself; the combination of an operation and the “lhs” and “rhs” relations it acts on to form a new relation is represented by the BinaryOperationRelation class, which should always be performed via a call to the apply method (or something that calls it, like the convenience methods on the Relation class). In many cases, applying a BinaryOperation doesn’t return something involving the original operation, because of some combination of defaulted-parameter population and simplification, and there are even some BinaryOperation classes that should never actually appear in a BinaryOperationRelation.

BinaryOperation cannot be subclassed by external code.

All concrete BinaryOperation types are frozen, equality-comparable dataclasses. They also provide a very concise str representation (in addition to the dataclass-provided repr) suitable for summarizing an entire relation tree.

Methods Summary

applied_columns(lhs, rhs) Return the columns of the relation that results from applying this operation to the given targets.
applied_max_rows(lhs, rhs) Return the maximum number of rows of the relation that results from applying this operation to the given target.
applied_min_rows(lhs, rhs) Return the minimum number of rows of the relation that results from applying this operation to the given targets.
apply(lhs, rhs) Create a new relation that represents the action of this operation on a pair of existing relations.

Methods Documentation

applied_columns(lhs: lsst.daf.relation._relation.Relation, rhs: lsst.daf.relation._relation.Relation) → collections.abc.Set[lsst.daf.relation._columns._tag.ColumnTag]

Return the columns of the relation that results from applying this operation to the given targets.

Parameters:
lhs : Relation

On relation the operation will act on.

rhs : Relation

The other relation the operation will act on.

Returns:
columns : Set [ ColumnTag ]

Columns the new relation would have.

applied_max_rows(lhs: lsst.daf.relation._relation.Relation, rhs: lsst.daf.relation._relation.Relation) → int | None[int, None]

Return the maximum number of rows of the relation that results from applying this operation to the given target.

Parameters:
lhs : Relation

On relation the operation will act on.

rhs : Relation

The other relation the operation will act on.

Returns:
max_rows : int or None

Maximum number of rows the new relation would have.

applied_min_rows(lhs: lsst.daf.relation._relation.Relation, rhs: lsst.daf.relation._relation.Relation) → int

Return the minimum number of rows of the relation that results from applying this operation to the given targets.

Parameters:
lhs : Relation

On relation the operation will act on.

rhs : Relation

The other relation the operation will act on.

Returns:
min_rows : int

Minimum number of rows the new relation would have.

apply(lhs: lsst.daf.relation._relation.Relation, rhs: lsst.daf.relation._relation.Relation) → lsst.daf.relation._relation.Relation

Create a new relation that represents the action of this operation on a pair of existing relations.

Parameters:
lhs : Relation

One relation the operation will act on.

rhs : Relation

The other relation the operation will act on.

Returns:
new_relation : Relation

Relation that includes this operation. This may be self if the operation is a no-op, and it may not be a BinaryOperationRelation holding this operation (or even a similar one) if the operation was inserted earlier in the tree via commutation relations.

Raises:
ColumnError

Raised if the operation could not be applied due to problems with the target relations’ columns.

EngineError

Raised if the operation could not be applied due to problems with the target relations’ engine(s).