Skip to content

sift_client.util.test_results.bounds

FUNCTION DESCRIPTION
all_within_bounds

Return True when every element of arr is within bounds.

assign_value_to_measurement

Resolve value type from a given value and assign it to a measurement.

evaluate_measurement_bounds

Update a measurement with the resolved bounds type and result of evaluating the given value against those bounds.

out_of_bounds_mask

Return a boolean mask selecting elements of arr that violate bounds.

to_numpy_array

Normalize a list / ndarray / pandas Series into a numpy array.

value_passes_bounds

Evaluate a value against bounds without recording a measurement.

all_within_bounds

all_within_bounds(
    arr: NDArray[float64],
    bounds: dict[str, float] | NumericBounds,
) -> bool

Return True when every element of arr is within bounds.

assign_value_to_measurement

assign_value_to_measurement(
    measurement: TestMeasurement
    | TestMeasurementCreate
    | TestMeasurementUpdate,
    value: float | str | bool,
) -> None

Resolve value type from a given value and assign it to a measurement.

PARAMETER DESCRIPTION
measurement

The measurement to assign the value to.

TYPE: TestMeasurement | TestMeasurementCreate | TestMeasurementUpdate

value

The value to resolve and assign to the measurement.

TYPE: float | str | bool

evaluate_measurement_bounds

evaluate_measurement_bounds(
    measurement: TestMeasurement
    | TestMeasurementCreate
    | TestMeasurementUpdate,
    value: float | str | bool,
    bounds: dict[str, float]
    | NumericBounds
    | str
    | bool
    | None,
) -> bool

Update a measurement with the resolved bounds type and result of evaluating the given value against those bounds.

PARAMETER DESCRIPTION
measurement

The measurement to update.

TYPE: TestMeasurement | TestMeasurementCreate | TestMeasurementUpdate

value

The value to evaluate the bounds of.

TYPE: float | str | bool

bounds

The bounds to evaluate the value against. Either a dictionary with "min" and "max" keys, a NumericBounds object, a string, a boolean, or None.

TYPE: dict[str, float] | NumericBounds | str | bool | None

RETURNS DESCRIPTION
bool

True if the value is within the bounds, False otherwise.

out_of_bounds_mask

out_of_bounds_mask(
    arr: NDArray[float64],
    bounds: dict[str, float] | NumericBounds,
) -> NDArray[bool_]

Return a boolean mask selecting elements of arr that violate bounds.

Raises ValueError when bounds has neither min nor max set.

to_numpy_array

to_numpy_array(
    values: list[float | int] | NDArray[float64] | Series,
) -> NDArray[float64]

Normalize a list / ndarray / pandas Series into a numpy array.

Shared by measure_avg and measure_all in both the real and stub step implementations so the accepted input types stay in sync.

value_passes_bounds

value_passes_bounds(
    value: float | str | bool,
    bounds: dict[str, float]
    | NumericBounds
    | str
    | bool
    | None,
) -> bool

Evaluate a value against bounds without recording a measurement.

Used by consumers that need pass/fail semantics matching the real plugin but do not transmit a measurement (e.g. --sift-disabled mode in the pytest plugin).