stencil

compression_safeguards.safeguards.stencil

Implementations for the provided StencilSafeguards.

Modules:

  • abc

    Abstract base class for the stencil safeguards.

  • qoi

    Implementations for the provided stencil quantity of interest (QoI) safeguards.

Classes:

BoundaryCondition

Bases: Enum

flowchart LR compression_safeguards.safeguards.stencil.BoundaryCondition[BoundaryCondition] click compression_safeguards.safeguards.stencil.BoundaryCondition href "" "compression_safeguards.safeguards.stencil.BoundaryCondition"

Different types of boundary conditions that can be applied to the data array domain boundaries for StencilSafeguards.

Since stencil safeguards operate over small neighbourhoods of data points, points at the boundary, where part of the neighbourhood may not exist, need to be treated specially.

valid class-attribute instance-attribute

valid = auto()

constant class-attribute instance-attribute

constant = auto()

The boundary is extended by a constant value.

edge class-attribute instance-attribute

edge = auto()

The boundary is extended by the edge value.

reflect class-attribute instance-attribute

reflect = auto()

The boundary is extended by reflecting along the edge value. The edge value itself is not repeated.

symmetric class-attribute instance-attribute

symmetric = auto()

The boundary is extended by reflecting after the edge value. The edge value itself is repeated as well.

wrap class-attribute instance-attribute

wrap = auto()

The boundary is extended by wrapping the domain around, as if the domain was on a torus (Pac-Man style).

NeighbourhoodAxis

NeighbourhoodAxis(before: int, after: int)

Specification of the shape of the data neighbourhood along a single axis.

Parameters:
  • before (int) –

    The non-negative number of values to include before the centre of a data neighbourhood.

    e.g. setting before=1 means that the neighbourhood contains the previous value.

  • after (int) –

    The non-negative number of values to include after the centre of a data neighbourhood.

    e.g. setting after=2 means that the neighbourhood contains the two next values.

Raises:

before property

before: int

The non-negative number of values to include before the centre of a data neighbourhood.

after property

after: int

The non-negative number of values to include after the centre of a data neighbourhood.

NeighbourhoodBoundaryAxis

NeighbourhoodBoundaryAxis(
    axis: int,
    before: int,
    after: int,
    boundary: str | BoundaryCondition,
    constant_boundary: None
    | int
    | float
    | str
    | Parameter = None,
)

Specification of the shape of the data neighbourhood and its boundary condition along a single axis.

Parameters:
  • axis (int) –

    The axis along which the boundary condition is applied.

  • before (int) –

    The non-negative number of values to include before the centre of a data neighbourhood.

    e.g. setting before=1 means that the neighbourhood contains the previous value.

  • after (int) –

    The non-negative number of values to include after the centre of a data neighbourhood.

    e.g. setting after=2 means that the neighbourhood contains the two next values.

  • boundary (str | BoundaryCondition) –

    The boundary condition that is applied to this axis near the data array domain boundary to fill the data neighbourhood, e.g. by extending values.

  • constant_boundary (None | int | float | str | Parameter, default: None ) –

    The optional value of or the late-bound parameter name for the constant value with which the data array domain is extended for a constant boundary. The value must be losslessly convertible to the data dtype.

Raises:
  • TypeCheckError

    if any parameter has the wrong type.

  • ValueError

    if before or after is negative.

  • ValueError

    if boundary does not name a valid boundary condition variant.

  • ValueError

    if constant_boundary is, not, provided if and only if the boundary is constant.

  • ValueError

    if constant_boundary uses the non-scalar $x or $X late-bound parameters.

Methods:

  • get_config

    Returns the configuration of the data neighbourhood.

  • from_config

    Instantiate the data neighbourhood from a configuration dict.

axis property

axis: int

The axis along which the boundary condition is applied.

before property

before: int

The non-negative number of values to include before the centre of a data neighbourhood.

after property

after: int

The non-negative number of values to include after the centre of a data neighbourhood.

shape property

The shape of the data neighbourhood.

boundary property

The boundary condition that is applied to this axis near the data array domain boundary to fill the data neighbourhood, e.g. by extending values.

constant_boundary property

constant_boundary: None | int | float | Parameter

The optional value of or the late-bound parameter name for the constant value with which the data array domain is extended for a constant boundary.

get_config

get_config() -> dict[str, JSON]

Returns the configuration of the data neighbourhood.

Returns:
  • config( dict[str, JSON] ) –

    Configuration of the data neighbourhood.

from_config classmethod

from_config(config: dict[str, JSON]) -> Self

Instantiate the data neighbourhood from a configuration dict.

Parameters:
  • config (dict[str, JSON]) –

    Configuration of the data neighbourhood.

Returns:
  • neighbourhood( Self ) –

    Instantiated data neighbourhood.