sashimi.utilities#
Classes
Generic enumeration. |
|
Buffer for large data arrays based on numpy and using ctypes for speedy copy of data |
Functions
- sashimi.utilities.asdict(obj, *, dict_factory=<class 'dict'>)[source]#
Return the fields of a dataclass instance as a new dictionary mapping field names to field values.
Example usage:
@dataclass class C:
x: int y: int
c = C(1, 2) assert asdict(c) == {‘x’: 1, ‘y’: 2}
If given, ‘dict_factory’ will be used instead of built-in dict. The function applies recursively to field values that are dataclass instances. This will also look into built-in containers: tuples, lists, and dicts.
- sashimi.utilities.gcd(x, y, /)#
greatest common divisor of x and y
- sashimi.utilities.is_dataclass(obj)[source]#
Returns True if obj is a dataclass or an instance of a dataclass.
- sashimi.utilities.vectorize(ftylist_or_function=(), target='cpu', identity=None, **kws)[source]#
A decorator that creates a NumPy ufunc object using Numba compiled code. When no arguments or only keyword arguments are given, vectorize will return a Numba dynamic ufunc (DUFunc) object, where compilation/specialization may occur at call-time.
- Parameters:
ftylist_or_function (function or iterable) –
When the first argument is a function, signatures are dealt with at call-time.
When the first argument is an iterable of type signatures, which are either function type object or a string describing the function type, signatures are finalized at decoration time.
- Keyword Arguments:
- Return type:
A NumPy universal function
Examples
- @vectorize([‘float32(float32, float32)’,
‘float64(float64, float64)’], identity=0)
- def sum(a, b):
return a + b
@vectorize def sum(a, b):
return a + b
@vectorize(identity=1) def mul(a, b):
return a * b
Exceptions
Exception raised by Queue.get(block=0)/get_nowait(). |