Skip to content

allocator

QuantityFactory

sizer = sizer instance-attribute

backend = backend instance-attribute

__init__(sizer, *, backend)

Initialize a QuantityFactory from a GridSizer and a NDSL backend name.

Parameters:

Name Type Description Default
sizer GridSizer

GridSizer object that determines the array sizes.

required
backend Backend

NDSL backend name used for performance-optimized allocation.

required

update_data_dimensions(data_dimension_descriptions)

Update the length of data (non-x/y/z) dimensions, unknown data dimensions will be added, existing ones updated.

Parameters:

Name Type Description Default
data_dimension_descriptions dict[str, int]

Dict of name/length pairs

required

add_data_dimensions(data_dimension_descriptions)

Add new data (non-x/y/z) dimensions via a key-length pair. If the dimension already exists, it will error out.

Parameters:

Name Type Description Default
data_dimension_descriptions dict[str, int]

Dict of name/length pairs

required

empty(dims, units, dtype=Float, *, allow_mismatch_float_precision=False)

Allocate a Quantity and fill it with uninitialized (undefined) values.

Equivalent to numpy.empty

zeros(dims, units, dtype=Float, *, allow_mismatch_float_precision=False)

Allocate a Quantity and fill it with the value 0.

Equivalent to numpy.zeros

ones(dims, units, dtype=Float, *, allow_mismatch_float_precision=False)

Allocate a Quantity and fill it with the value 1.

Equivalent to numpy.ones

full(dims, units, value, dtype=Float, *, allow_mismatch_float_precision=False)

Allocate a Quantity and fill it with the given value.

Equivalent to numpy.full

from_array(data, dims, units, *, allow_mismatch_float_precision=False)

Create a Quantity from values in the data array.

This copies the values of data into the resulting Quantity. The data array thus must correspond to the correct shape and extent for the given dims.

from_compute_array(data, dims, units, *, allow_mismatch_float_precision=False)

Create a Quantity from values of the compute domain.

This function will allocate the full Quantity (including potential halo points) to zero. The values of data are then copied into the compute domain. That numpy array must correspond to the correct shape and extent of the compute domain for the given dims.

get_quantity_halo_spec(dims, n_halo=None, dtype=Float)

Build memory specifications for the halo update.

Parameters:

Name Type Description Default
dims Sequence[str]

dimensionality of the data

required
n_halo int | None

number of halo points to update, defaults to self.n_halo

None
dtype type

data type of the data

Float