Skip to content

pipda.verb

module

pipda.verb

Classes
Functions
  • register_verb(cls, func, context, kw_context, name, qualname, doc, module, dependent, ast_fallback) (Callable) Register a verb</>
class

pipda.verb.VerbCall(func, *args, **kwargs)

A verb call

Parameters
  • func (Callable) The registered verb
Methods
  • __array_ufunc__(ufunc, method, *inputs, **kwargs) (FunctionCall) Allow numpy ufunc to work on Expression objects</>
  • __getattr__(name) (ReferenceAttr) Whenever expr.attr is encountered,return a ReferenceAttr object </>
  • __getitem__(item) (ReferenceItem) Whenever expr[item] is encountered,return a ReferenceAttr object </>
  • __hash__() (int) Make it hashable</>
  • __index__() Allow Expression object to work as index or part of slice</>
  • __iter__() Forbiden iterating on Expression objects</>
  • __str__() (str) Used for stringify the whole expression</>
  • _pipda_eval(data, context) (Any) Evaluate the expression using given data</>
method

__array_ufunc__(ufunc, method, *inputs, **kwargs) → FunctionCall

Allow numpy ufunc to work on Expression objects

method

__hash__() → int

Make it hashable

method

__getattr__(name) → ReferenceAttr

Whenever expr.attr is encountered,return a ReferenceAttr object

method

__getitem__(item) → ReferenceItem

Whenever expr[item] is encountered,return a ReferenceAttr object

method

__index__()

Allow Expression object to work as index or part of slice

method

__iter__()

Forbiden iterating on Expression objects

If it is happening, probably wrong usage of functions/verbs

method

__str__() → str

Used for stringify the whole expression

method

_pipda_eval(data, context=None) → Any

Evaluate the expression using given data

function

pipda.verb.register_verb(cls=<class 'pipda.utils.TypeHolder'>, func=None, context=None, kw_context=None, name=None, qualname=None, doc=None, module=None, dependent=False, ast_fallback='piping_warning')

Register a verb

A verb is a function that takes a data as the first argument, and uses it to evaluate the rest of the arguments. So the first argument is required for a verb.

We can have multiple implementations of a verb for different types of data, or evan the same type of data with different backends.

Parameters
  • cls (Union, optional) The default type to register for _default backendif TypeHolder, it is a generic function, and not counted as a real implementation.
  • func (Optional, optional) The function works as a verb.If None (not provided), this function will return a decorator.
  • context (Union, optional) The context to evaluate the arguments
  • kw_context (Optional, optional) The context to evaluate the keyword arguments
  • name (str | none, optional) and
  • qualname (str | none, optional) and
  • doc (str | none, optional) and
  • module (str | none, optional) The meta information about the function to overwrite func'sor when it's not available from func
  • dependent (bool, optional) Whether the verb is dependent.
    @register_verb(context=Context.EVAL, dependent=True) def length(data): return len(data)

    with dependent=True

    length() -> VerbCall, waiting for data to evaluate

    with dependent=False

    length() -> TypeError, argument data is missing

  • ast_fallback (str, optional) What's the supposed way to call the verb whenAST node detection fails. piping - Suppose this verb is called like data >> verb(...) normal - Suppose this verb is called like verb(data, ...) piping_warning - Suppose piping call, but show a warning normal_warning - Suppose normal call, but show a warning raise - Raise an error
Returns (Callable)

The registered verb or a decorator to register a verb