allocator
QuantityFactory
__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 |
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
|
DataDimensions
|
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
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.
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
get_quantity_halo_spec(dims, n_halo=None, dtype=Float)
ones(dims, units, dtype=Float, *, allow_mismatch_float_precision=False)
Allocate a Quantity and fill it with the value 1.
Equivalent to numpy.ones
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
|
DataDimensions
|
Dict of name/length pairs |
required |
zeros(dims, units, dtype=Float, *, allow_mismatch_float_precision=False)
Allocate a Quantity and fill it with the value 0.
Equivalent to numpy.zeros