normalize_value

function of dascore.utils.intervals source

normalize_value(
    value ,
    error: type[<class ’Exception] = <class ‘dascore.exceptions.ParameterError’>,
)

Normalize an interval’s value so its Python type survives validation.

Numpy scalars are unwrapped: pydantic’s smart union resolves every numpy scalar to float, which would turn a mask element into a numeric group.

Parameters

Parameter Description
value The value to normalize.
error The exception raised when the value is a non-finite number.

Examples

import numpy as np
from dascore.utils.intervals import normalize_value
normalize_value(np.bool_(True)) is True
True