assume_safe

compression_safeguards.safeguards.combinators.assume_safe

Always safe (logical truth) combinator safeguard.

Classes:

  • AssumeAlwaysSafeguard

    The AssumeAlwaysSafeguard assumes that all elements always meet their guarantees

AssumeAlwaysSafeguard

AssumeAlwaysSafeguard()

Bases: PointwiseSafeguard

flowchart LR compression_safeguards.safeguards.combinators.assume_safe.AssumeAlwaysSafeguard[AssumeAlwaysSafeguard] compression_safeguards.safeguards.pointwise.abc.PointwiseSafeguard[PointwiseSafeguard] compression_safeguards.safeguards.abc.Safeguard[Safeguard] compression_safeguards.safeguards.pointwise.abc.PointwiseSafeguard --> compression_safeguards.safeguards.combinators.assume_safe.AssumeAlwaysSafeguard compression_safeguards.safeguards.abc.Safeguard --> compression_safeguards.safeguards.pointwise.abc.PointwiseSafeguard click compression_safeguards.safeguards.combinators.assume_safe.AssumeAlwaysSafeguard href "" "compression_safeguards.safeguards.combinators.assume_safe.AssumeAlwaysSafeguard" click compression_safeguards.safeguards.pointwise.abc.PointwiseSafeguard href "" "compression_safeguards.safeguards.pointwise.abc.PointwiseSafeguard" click compression_safeguards.safeguards.abc.Safeguard href "" "compression_safeguards.safeguards.abc.Safeguard"

The AssumeAlwaysSafeguard assumes that all elements always meet their guarantees and are thus always safe.

This safeguards can be used with the SelectSafeguard to express regions that are not of interest, i.e. where no additional safety requirements are imposed.

Methods:

kind class-attribute

kind: str = 'assume_safe'

late_bound property

late_bound: Set[Parameter]

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]]

All elements are safe and thus always succeed the check.

Parameters:
  • data (ndarray[S, dtype[T]]) –

    Original data array, relative to which the approximation is checked.

  • approximation (ndarray[S, dtype[T]]) –

    Approximation of the data array.

  • late_bound (Bindings) –

    Bindings for late-bound parameters, including for this safeguard.

  • where (Literal[True] | ndarray[S, dtype[bool]], default: True ) –

    Only check at data points where the condition is True.

Returns:

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]

Since all values are always safe, the safe intervals for each element in the data array are full (contain all possible values).

Parameters:
  • data (ndarray[S, dtype[T]]) –

    Data for which the safe intervals should be computed.

  • late_bound (Bindings) –

    Bindings for late-bound parameters, including for this safeguard.

  • where (Literal[True] | ndarray[S, dtype[bool]], default: True ) –

    Only compute the safe intervals at pointwise checks where the condition is True.

Returns:
  • intervals( IntervalUnion[T, int, int] ) –

    Union of intervals that cover all possible values, since all are always safe.

compute_footprint

compute_footprint(
    foot: ndarray[S, dtype[bool]],
    *,
    late_bound: Bindings,
    where: Literal[True] | ndarray[S, dtype[bool]] = True,
) -> ndarray[S, dtype[bool]]

Since all values are always safe, the footprint of the foot array is False everywhere.

Parameters:
  • foot (ndarray[S, dtype[bool]]) –

    Array for which the footprint is computed.

  • late_bound (Bindings) –

    Bindings for late-bound parameters, including for this safeguard.

  • where (Literal[True] | ndarray[S, dtype[bool]], default: True ) –

    Only compute the footprint at pointwise checks where the condition is True.

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]]

Since all values are always safe, the inverse footprint of the foot array is False everywhere.

Parameters:
  • foot (ndarray[S, dtype[bool]]) –

    Array for which the inverse footprint is computed.

  • late_bound (Bindings) –

    Bindings for late-bound parameters, including for this safeguard.

  • where (Literal[True] | ndarray[S, dtype[bool]], default: True ) –

    Only compute the inverse footprint at pointwise checks where the condition is True.

Returns:

get_config

get_config() -> dict[str, JSON]

Returns the configuration of the safeguard.

Returns:
  • config( dict ) –

    Configuration of the safeguard.