BufferBase#
- class fields.buffers.base.BufferBase(array_object: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])[source]#
Abstract base class for Pisces Geometry-compatible field buffers.
This interface abstracts data storage details so that field operations can be performed uniformly regardless of whether the underlying data is NumPy, unyt, HDF5, etc.
Methods
__init__
(array_object)Initialize a buffer from a validated array-like object.
as_array
()Return the buffer as a NumPy array.
as_core
()Return the raw backend array object stored in this buffer.
as_repr
()Return a NumPy-compatible array for use in NumPy operations.
Convert the buffer contents into a unyt_array with attached units.
astype
(dtype, *args, **kwargs)Return a copy of this buffer with a different data type.
broadcast_to
(shape, *args, **kwargs)Broadcast an array to a new shape.
can_handle
(obj)Return
True
if obj can be wrapped by this buffer class.Return a list of type names that this buffer can wrap.
convert_to_base
([unit_system, equivalence])Convert this buffer in-place to base units for the given unit system.
convert_to_units
(units[, equivalence])Convert this buffer's data to the specified physical units (in-place).
copy
(*args, **kwargs)Return a deep copy of this buffer.
empty
(shape, *args, **kwargs)Create a new buffer with a window into unaltered memory.
empty_like
(other, *args, **kwargs)Create a new buffer allocation matching the shape of another buffer.
expand_dims
(axis, *args, **kwargs)Expand the shape of an array.
flatten
(*args[, order])Return a flattened 1D view of this buffer.
from_array
(obj, *args[, dtype])Attempt to construct a new buffer instance from an array-like object.
full
(shape, *args[, fill_value])Create a new buffer filled with a constant value.
full_like
(other[, fill_value])Create a new buffer filled with a constant value and matching the shape of another buffer.
in_units
(units, *args[, equivalence, ...])Return a new copy of this buffer cast to the specified physical units.
ones
(shape, *args, **kwargs)Create a new buffer filled with ones.
ones_like
(other, *args, **kwargs)Create a new buffer filled with ones and matching the shape of another buffer.
reshape
(shape, *args, **kwargs)Return a reshaped copy of this buffer.
resolve
(array_like, *args[, buffer_registry])Resolve and instantiate a buffer subclass for an arbitrary array-like input.
squeeze
(*args[, axis])Remove axes of length one from self.
to
(units, *args[, equivalence, ...])Return a new buffer (or array) with values cast to the specified units.
to_value
(units[, equivalence])Return a NumPy array of values converted to the specified physical units.
transpose
([axes])Return this buffer with axes transposed.
zeros
(shape, *args, **kwargs)Create a new buffer filled with zeros.
zeros_like
(other, *args, **kwargs)Create a new buffer filled with zeros and matching the shape of another buffer.
Attributes
Shorthand for as_core().
Shorthand for as_array().
Data type of the array.
Whether the buffer carries unit metadata.
Number of dimensions.
Shape of the underlying array.
Total number of elements.
Physical units attached to the buffer data.
Shorthand for as_unyt_array().