Skip to content

pipda.function

module

pipda.function

Classes
Functions
  • register_func(func, cls, plain, name, qualname, doc, module, dispatchable, pipeable, context, kw_context, ast_fallback) (Callable) Register a function</>
class

pipda.function.FunctionCall(func, *args, **kwargs)

A function call object that awaits for evaluation

Parameters
  • func (Union) A registered function by register_func or an expression,for example, f.col.mean
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) Representation of the function call</>
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

Representation of the function call

function

pipda.function.register_func(func=None, cls=<class 'pipda.utils.TypeHolder'>, plain=False, name=None, qualname=None, doc=None, module=None, dispatchable=False, pipeable=False, context=None, kw_context=None, ast_fallback='normal_warning')

Register a function

A function, unlike a verb, is a function that doesn't evaluate its arguments by the first argument, which is the data, it depends on the data from a verb to evaluate the arguments if they are Expression objects.

A function can also be defined as pipeable, so that the first argument can be piped in later.

A function can also be defined as dispatchable. The types of any positional arguments are used to dispatch the implementation.

Parameters
  • func (Optional, optional) The generic function.If None (not provided), this function will return a decorator.
  • cls (Type, optional) The default type to register for _default backendif TypeHolder, it is a generic function, and not counted as a real implementation. For plain or non-dispatchable functions, specify a different type than TypeHolder to indicate the func is a real implementation.
  • plain (bool, optional) If True, the function will be registered as a plain function,which means it will be called without any evaluation of the arguments. It doesn't support dispatchable and pipeable.
  • 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
  • dispatchable (str | bool, optional) If not False nor None, the function will be registered asa dispatchable function, which means it will be dispatched using the types of the arguments: "first" - Use the first argument "args" - Use all positional arguments "kwargs" - Use all keyword arguments "all" - Use all arguments If False, the function is not dispatchable.
  • pipeable (bool, optional) If True, the function will work like a verb when a data ispiping in. If dispatchable, the first argument will be used to dispatch the implementation. The rest of the arguments will be evaluated using the data from the first argument.
  • context (ContextType | None, optional) The context used to evaluate the rest arguments using thefirst argument only when the function is pipeable and the data is piping in.
  • kw_context (Dict[str, ContextType] | None, optional) The context used to evaluate the keyword arguments
  • ast_fallback (str, optional) What's the supposed way to call the func whenAST node detection fails. piping - Suppose this func is called like data >> func(...) normal - Suppose this func is called like func(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 func or a decorator to register a func