Skip to content

Core

SelectionExpression

Bases: ABC

Abstract base class for all selection criteria and logical operations.

This class defines the interface for expressions that can be evaluated to produce a boolean mask for atoms within an Ensemble microstate. It also provides dunder methods for convenient logical operations (AND, OR, NOT) using Python's &, |, and ~ operators.

evaluate(ensemble, run_id=None, micro_id=None)

Evaluates this expression for specified microstates.

This method generates an atom-level boolean mask for each requested microstate. The mask indicates which atoms meet the criteria defined by the expression.

PARAMETER DESCRIPTION

ensemble

The Ensemble object containing the data to be evaluated.

TYPE: Ensemble

run_id

The ID of the specific run within the ensemble to evaluate. If None, the expression might apply across all runs or use a default.

TYPE: str | None DEFAULT: None

micro_id

Specifies the microstate IDs for which to evaluate the expression. If None, the expression is evaluated for every single possible microstate available for the given run. This can be an integer, a slice object, or an iterable of integers.

TYPE: OptionalSliceSpec DEFAULT: None

YIELDS DESCRIPTION
NDArray[bool_]

A 1D boolean NumPy array (npt.NDArray[np.bool_]). Each element in the array corresponds to an atom in the specified microstate, with True indicating that the atom meets the selection criteria and False otherwise. Each yielded array corresponds to one microstate.

init_mask()