General Utilities

class findig.utils.DataPipe(*funcs)[source]

An object that folds data over a set of functions.

Parameters:funcs – A variable list of functions. Each function must take one parameter and return a single value.

Calling this object with data will pass the data through each one of the functions that is has collected, using the result of one function as the argument for the next function. For example, if the data pipe dpipe contains the functions [f1, f2, ..., fn], then dpipe(data) is equivalent to fn(...(f2(f1(data)))).

stage(func)[source]

Append a function to the data pipes internal list.

This returns the function that it is called with, so it can be used as a decorator.

class findig.utils.extremum(direction=1)[source]

A class whose instances are always ordered at one extreme.

Parameters:direction – If positive, always order as greater than every other object. If negative, orders as less than every other object.
findig.utils.tryeach(funcs, *args, **kwargs)[source]

Call every item in a list a functions with the same arguments, until one of them does not throw an error. If all of the functions raise an error, then the error from the last function will be re-raised.

Parameters:funcs – An iterable of callables.