validation
cosmic_warp.core.validation
Host-side input validation shared by the configuration APIs.
Every check runs at configuration time on host values and raises ValueError with the offending name and value. Nothing here is called from the step loop.
scalar
scalar(
name: str,
value,
minimum: float = None,
positive: bool = False,
allow_inf: bool = False,
) -> float
Return value as a finite float (or +inf with allow_inf, for limits that can be disabled), optionally >= minimum or > 0.
Source code in cosmic_warp/core/validation.py
polar_angle
Return value as a finite angle in radians, in [0, pi]: an inclination or a cone half-angle, both defined only on that range.
Source code in cosmic_warp/core/validation.py
positive_int
Return value as an int >= 1 (step counts, horizons, episode limits), optionally <= maximum.
Source code in cosmic_warp/core/validation.py
describe
Type, shape, dtype and device of an array argument, for error messages.
Source code in cosmic_warp/core/validation.py
flag
Return value as a bool; only True/False are accepted ("false" is truthy).
Source code in cosmic_warp/core/validation.py
seed
Return value as an RNG seed, the 64-bit Philox key: an int in [0, 2**64).
Source code in cosmic_warp/core/validation.py
sequence
Return value as a list: a list, tuple or array, not a string or scalar.
Source code in cosmic_warp/core/validation.py
vec3
Return value as a tuple of three finite floats.
Source code in cosmic_warp/core/validation.py
array
Return a list of numbers ([N]) or of width-component rows ([N, width]) as a finite float64 array. Strings and booleans are rejected, not converted, and rows of another width are rejected, not reshaped.
Source code in cosmic_warp/core/validation.py
numeric_array
Return values as a float64 array of the given shape. A NumPy array must have an integer or float dtype; any other sequence is checked element by element. Booleans and strings are rejected, not converted. Finiteness is left to the caller.
Source code in cosmic_warp/core/validation.py
inertia
Check one (3, 3) or a batch (N, 3, 3) of inertia tensors: finite, symmetric, positive definite, and satisfying the triangle inequality on the principal moments (a physical rigid body). Returns a float64 array.