mvpy.utilities package#

Submodules#

mvpy.utilities.compile module#

Exposes decorators for compilation.

mvpy.utilities.compile.numpy(*args: List[Any], nopython: bool = True, nogil: bool = True, fastmath: bool = True, cache: bool = True, disable: bool = False, **kwargs: Dict[str, Any]) Callable[source]#

Decorator that compiles a function with numba.jit, if available.

Parameters:
*argsList[Any]

Arguments to pass.

nopythonbool, default=True

Default to pass to jit.

nogilbool, default=True

Default to pass to jit.

fastmathbool, default=True

Default to pass to jit.

cachebool, default=True

Default to pass to jit.

disablebool, default=False

Flag to allow disabling compilation (for debugging).

**kwargsDict[str, Any]

Keyword arguments to pass.

Returns:
compiledCallable

Compiled function.

Examples

Let’s look at a very silly toy example: >>> import numpy as np >>> from mvpy.utilities import compile >>> @compile.numpy >>> def maths_a(x: np.ndarray, y: np.ndarray) -> np.ndarray: >>> return x @ y.t() >>> @compile.numpy(disable = True) >>> def maths_b(x: np.ndarray, y: np.ndarray) -> np.ndarray: >>> return x @ y.t()

OS routines for NT or Posix depending on what system we’re on.

mvpy.utilities.compile.torch(*args: List[Any], **kwargs: Dict[str, Any]) Callable[source]#

Decorator that compiles a function with torch.compile, if available.

Parameters:
*argsList[Any]

Arguments to pass.

**kwargsDict[str, Any]

Keyword arguments to pass.

Returns:
compiledCallable

Compiled function.

Examples

Let’s look at a very silly toy example: >>> import torch >>> from mvpy.utilities import compile >>> @compile.torch >>> def maths_a(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor: >>> return x @ y.t() >>> @compile.torch(disable = True) >>> def maths_b(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor: >>> return x @ y.t()

Python part of the warnings subsystem.

mvpy.utilities.env module#

Exposes checks for environment variables.

mvpy.utilities.env.get_var(var: str, default: str | None = None, flag: str | None = None) str[source]#

Grab var from environment, respecting defaults and flag.

Parameters:
varstr

The environment variable to get.

defaultOptional[str], default=None

If var is None, what default to return (if any)?

flagOptional[str], default=None

If supplied, this will override var for this call.

Returns:
valuestr

Value of environment variable (or flag or default).

mvpy.utilities.env.is_enabled(var: str, default: bool = False, flag: bool | None = None) bool[source]#

Check if var is enabled in environment variables.

Parameters:
varstr

The environment variable to get.

defaultbool, default=False

If variable is not set, return default.

flagOptional[Union[int, bool]], default=None

If supplied, this will override var for this call.

Returns:
is_enabledbool

True if var is set to true (or was overriden, or default).

OS routines for NT or Posix depending on what system we’re on.

mvpy.utilities.progressbar module#

class mvpy.utilities.progressbar.Progressbar(enabled: bool | int = True, **kwargs)[source]#

Bases: object

Simple class for progress bars that can be enabled or disabled.

Parameters:
enabledbool | int, default=True

Either whether to enable the progressbar or, if int, at which position to place it for tqdm.

**kwargsAny

Additional arguments for tqdm.

Utilities for with-statement contexts. See PEP 343.

Joblib is a set of tools to provide **lightweight pipelining in

mvpy.utilities.progressbar.tqdm_joblib(tqdm_object)[source]#

Context manager to patch joblib to report into tqdm progress bar given as argument

mvpy.utilities.version module#

Exposes version methods.

mvpy.utilities.version.compare(v_a: str, op: str, v_b: str) bool[source]#

Compare two version strings.

Parameters:
v_astr

Version a.

opstr

Comparison operator (<, <=, ==, !=, >=, >).

v_bstr

Version b

Returns:
resultbool

Result of the version comparison.

Operator interface.

Python part of the warnings subsystem.

Module contents#

Exposes decorators for compilation.

Exposes checks for environment variables.

Exposes version methods.