droplets.tools.misc module

Miscellaneous functions.

enable_scalar_args

Decorator that makes vectorized methods work with scalars.

enable_scalar_args(method)[source]

Decorator that makes vectorized methods work with scalars.

This decorator allows to call functions that are written to work on numpy arrays to also accept python scalars, like int and float. Essentially, this wrapper turns them into an array and unboxes the result. Note that the dtype of the returned value will always be double or cdouble even if the function is called with an integer.

Parameters:

method (TFunc) – The method being decorated

Returns:

The decorated method

Return type:

TFunc