symop.modes.types

Shared type aliases and small utility helpers for mode handling.

This module centralizes common array type aliases and lightweight validation helpers used across the symop.modes subpackage.

It also provides utilities for normalizing Matplotlib Axes inputs and validating floating-point parameters.

Functions

as_float_array(x)

Convert input to a NumPy array with dtype=float.

coerce_axes_array(axes)

Normalize Axes-like inputs to a consistent array representation.

require_finite(name, x)

Validate that a float is finite.

require_pos_finite(name, x)

Validate that a float is strictly positive and finite.

Classes

HasGetFigure(*args, **kwargs)

Minimal protocol for objects exposing get_figure().

class HasGetFigure(*args, **kwargs)

Bases: Protocol

Minimal protocol for objects exposing get_figure().

_abc_impl = <_abc._abc_data object>
_is_protocol = True
get_figure() FigureBase | None

Get FigureBase.

Return type:

FigureBase | None

as_float_array(x: Any) ndarray[tuple[Any, ...], dtype[float64]]

Convert input to a NumPy array with dtype=float.

This is a small convenience used throughout symop.modes to normalize array-like inputs (lists, tuples, NumPy arrays) to a floating-point NumPy array.

Parameters:

x (Any) – Array-like input.

Returns:

NumPy array view/copy with dtype=float.

Return type:

FloatArray

coerce_axes_array(axes: HasGetFigure | Sequence[HasGetFigure] | ndarray[tuple[Any, ...], dtype[Any]]) tuple[FigureBase, ndarray[tuple[Any, ...], dtype[Any]]]

Normalize Axes-like inputs to a consistent array representation.

Parameters:

axes (HasGetFigure | Sequence[HasGetFigure] | ndarray[tuple[Any, ...], dtype[Any]])

Return type:

tuple[FigureBase, ndarray[tuple[Any, …], dtype[Any]]]

require_finite(name: str, x: float) float

Validate that a float is finite.

Parameters:
  • name (str) – Name of the parameter (used in error messages).

  • x (float) – Value to validate.

Returns:

The validated value.

Return type:

float

Raises:

ValueError – If x is not finite.

require_pos_finite(name: str, x: float) float

Validate that a float is strictly positive and finite.

Parameters:
  • name (str) – Name of the parameter (used in error messages).

  • x (float) – Value to validate.

Returns:

The validated value.

Return type:

float

Raises:

ValueError – If x is not finite or not strictly positive.