superleaf.operators.base#
Functions
|
Wrap a single-argument predicate as a |
|
Wrap a single-argument function as a pipeable |
Classes
A |
|
A predicate on a single value, combinable with |
|
An |
|
|
A callable that can be piped into another callable with |
|
A |
Exceptions
Raised by a vectorized implementation to request element-wise evaluation. |
- class superleaf.operators.base.Operator[source]#
Bases:
objectA callable that can be piped into another callable with
>>.(a >> b)(x)isb(a(x)). Ifbis aBooleanOperator, the result is also aBooleanOperator.
- class superleaf.operators.base.FunctionOperator(f: Callable)[source]#
Bases:
OperatorAn
Operatorwrapping a single-argument function.
- class superleaf.operators.base.BooleanOperator[source]#
Bases:
OperatorA predicate on a single value, combinable with
|,&and~.Calling the operator evaluates one value and returns a
bool.on_series()evaluates every element of apd.Seriesand returns a booleanpd.Serieswith the same index, giving the same result per element as calling the operator on it.|and&short-circuit likeorandand: the right operand is evaluated only where the left one does not decide the result, soF.notna & F.gt(0)never compares a missing value.
- class superleaf.operators.base.BooleanFunctionOperator(f: Callable[[Any], Any])[source]#
Bases:
BooleanOperatorA
BooleanOperatorwrapping a single-argument function; its result is converted withbool.
- class superleaf.operators.base.VectorizedBooleanOperator(f: Callable[[Any], Any], vf: Callable[[Series], Any], vectorize_missing: bool = False)[source]#
Bases:
BooleanFunctionOperatorA
BooleanFunctionOperatorwith a vectorized implementation for Series.- Parameters:
f (callable) – Scalar predicate.
vf (callable) – Function from a Series to a boolean array-like of the same length, matching
felement-wise. It may raiseTypeErrororValueError(orNotVectorizable) to fall back to evaluatingfon each element.vectorize_missing (bool, optional) – If True, use
vfresults for missing values too. Otherwise they are replaced withfresults.
- exception superleaf.operators.base.NotVectorizable[source]#
Bases:
ExceptionRaised by a vectorized implementation to request element-wise evaluation.
- superleaf.operators.base.operator(f: Callable, exceptions=None, fallback=None) FunctionOperator[source]#
Wrap a single-argument function as a pipeable
Operator.- Parameters:
f (callable) – The function to wrap.
exceptions (type, tuple of types, or str, optional) – Exceptions to catch, returning
fallbackinstead (seewith_fallback()). Not caught if None.fallback (Any, optional) – Value returned when one of
exceptionsis raised.
- Returns:
The wrapped function.
- Return type:
- superleaf.operators.base.bool_operator(f: Callable, exceptions=None, fallback=False) BooleanFunctionOperator[source]#
Wrap a single-argument predicate as a
BooleanOperator.- Parameters:
f (callable) – The predicate; its result is converted with
bool.exceptions (type, tuple of types, or str, optional) – Exceptions to catch, returning
fallbackinstead (seewith_fallback()). Not caught if None.fallback (bool, optional) – Value returned when one of
exceptionsis raised. Default is False.
- Returns:
The wrapped predicate.
- Return type:
- Raises:
TypeError – If
fallbackis not abool.