Predicate

class lsst.daf.relation.Predicate

Bases: ABC

An abstract base class and factory for boolean column expressions.

Predicate inheritance is closed to the types already provided by this package, but considerable custom behavior can still be provided via the PredicateFunction class and an Engine that knows how to interpret its name value. These concrete types can all be constructed via factory methods on Predicate itself, ColumnExpression, or ColumnContainer, so the derived types themselves only need to be referenced when writing match expressions that process an expression tree. See Extensibility for rationale and details.

Attributes Summary

columns_required

Columns required by this expression (Set [ ColumnTag ]).

Methods Summary

as_trivial()

Attempt to simplify this expression into a constant boolean.

is_supported_by(engine)

Test whether the given engine is capable of evaluating this expression.

literal(value)

Construct a boolean expression that is a constant True or False.

logical_and()

Return a boolean expression that is the logical AND of the given ones.

logical_not()

Return a boolean expression that is the logical NOT of this one.

logical_or()

Return a boolean expression that is the logical OR of the given ones.

reference(tag)

Construct an expression that refers to a boolean column in a relation.

Attributes Documentation

columns_required

Columns required by this expression (Set [ ColumnTag ]).

This includes columns required by expressions nested within this one.

Methods Documentation

abstract as_trivial() bool | None

Attempt to simplify this expression into a constant boolean.

Returns:
trivialbool or None

If True or False, the expression always evaluates to exactly that constant value. If None, the expression is nontrivial (or at least could not easily be simplified into a trivial expression).

abstract is_supported_by(engine: Engine) bool

Test whether the given engine is capable of evaluating this expression.

Parameters:
engineEngine

Engine to test.

Returns:
supportedbool

Whether the engine supports this expression and all expressions nested within it.

classmethod literal(value: bool) PredicateLiteral

Construct a boolean expression that is a constant True or False.

Parameters:
valuebool

Value for the expression.

Returns:
literalPredicateLiteral

A boolean column expression set to the given value.

logical_and() Predicate

Return a boolean expression that is the logical AND of the given ones.

Parameters:
*operandsPredicate

Existing boolean expressions to AND together.

Returns:
logical_andPredicate

Logical AND expression. If no operands are provided, a PredicateLiteral for True is returned. If one operand is provided, it is returned directly.

logical_not() LogicalNot

Return a boolean expression that is the logical NOT of this one.

Returns:
logical_notPredicate

Logical NOT expression.

logical_or() Predicate

Return a boolean expression that is the logical OR of the given ones.

Parameters:
*operandsPredicate

Existing boolean expressions to OR together.

Returns:
logical_andPredicate

Logical OR expression. If no operands are provided, a PredicateLiteral for False is returned. If one operand is provided, it is returned directly.

classmethod reference(tag: ColumnTag) PredicateReference

Construct an expression that refers to a boolean column in a relation.

Parameters:
tagColumnTag

Identifier for the column to reference.

Returns:
referencePredicateReference

A column expression that refers the given relation column.