sashimi.utilities#

Classes

Enum

Generic enumeration.

SpeedyArrayBuffer

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.clean_json(d)[source]#
sashimi.utilities.gcd(x, y, /)#

greatest common divisor of x and y

sashimi.utilities.get_last_parameters(parameter_queue, timeout=0.0001)[source]#
sashimi.utilities.is_dataclass(obj)[source]#

Returns True if obj is a dataclass or an instance of a dataclass.

sashimi.utilities.lcm(a, b)[source]#

Return lowest common multiple.

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:
  • target (str) – A string for code generation target. Default to “cpu”.

  • identity (int, str, or None) – The identity (or unit) value for the element-wise function being implemented. Allowed values are None (the default), 0, 1, and “reorderable”.

  • cache (bool) – Turns on caching.

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

Empty

Exception raised by Queue.get(block=0)/get_nowait().