sign
compression_safeguards.safeguards.pointwise.sign
Sign-preserving safeguard.
Classes:
-
SignPreservingSafeguard–The
SignPreservingSafeguardguarantees that values have the same sign
SignPreservingSafeguard
Bases: PointwiseSafeguard
The SignPreservingSafeguard guarantees that values have the same sign
(-1, 0, +1) in the decompressed output as they have in the input data.
NaN values are preserved as NaN values with the same sign bit.
This safeguard can be configured to preserve the sign relative to a custom
offset, e.g. to preserve global minima and maxima. The sign is then
defined based on arithmetic comparison, i.e.
This safeguard should be combined with e.g. an error bound, as it by itself accepts any value with the same sign.
| Parameters: |
|
|---|
| Raises: |
|
|---|
Methods:
-
check_pointwise–Check for which elements in the
approximationarray the signs match the -
compute_safe_intervals–Compute the intervals in which the
data's sign is preserved. -
compute_footprint–Compute the footprint of the
footarray, e.g. for expanding data -
compute_inverse_footprint–Compute the inverse footprint of the
footarray, e.g. for expanding -
get_config–Returns the configuration of the safeguard.
late_bound
property
The set of late-bound parameters that this safeguard has.
Late-bound parameters are only bound when checking and applying the safeguard, in contrast to the normal early-bound parameters that are configured during safeguard initialisation.
Late-bound parameters can be used for parameters that depend on the specific data that is to be safeguarded.
check_pointwise
check_pointwise(
data: ndarray[S, dtype[T]],
approximation: ndarray[S, dtype[T]],
*,
late_bound: Bindings,
where: Literal[True] | ndarray[S, dtype[bool]] = True,
) -> ndarray[S, dtype[bool]]
Check for which elements in the approximation array the signs match the
signs of the data array elements'.
| Parameters: |
|
|---|
| Returns: |
|---|
| Raises: |
|
|---|
compute_safe_intervals
compute_safe_intervals(
data: ndarray[S, dtype[T]],
*,
late_bound: Bindings,
where: Literal[True] | ndarray[S, dtype[bool]] = True,
) -> IntervalUnion[T, int, int]
Compute the intervals in which the data's sign is preserved.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
compute_footprint
compute_footprint(
foot: ndarray[S, dtype[bool]],
*,
late_bound: Bindings,
where: Literal[True] | ndarray[S, dtype[bool]] = True,
) -> ndarray[S, dtype[bool]]
Compute the footprint of the foot array, e.g. for expanding data
points into the pointwise checks that they contribute to.
The footprint is equivalent to foot & where.
| Parameters: |
|
|---|
| Returns: |
|---|
compute_inverse_footprint
compute_inverse_footprint(
foot: ndarray[S, dtype[bool]],
*,
late_bound: Bindings,
where: Literal[True] | ndarray[S, dtype[bool]] = True,
) -> ndarray[S, dtype[bool]]
Compute the inverse footprint of the foot array, e.g. for expanding
pointwise check fails into the points that could have contributed to
the failures.
The inverse footprint is equivalent to foot & where.
| Parameters: |
|
|---|
| Returns: |
|---|