fields.buffers.base.BufferBase.__init__#
- BufferBase.__init__(array_object: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])[source]#
Initialize a buffer from a validated array-like object.
This constructor assumes that the input is already fully compatible with the expected core array type for this buffer class (e.g.,
numpy.ndarray
,unyt.unyt_array
, etc.). No validation or coercion of the data is performed beyond checking its type.Warning
This method does not attempt to coerce or sanitize the input array. If you pass an incompatible or incorrect array-like object, a
TypeError
will be raised. For flexible or user-facing buffer construction, usefrom_array()
orcoerce()
instead.- Parameters:
array_object (
ArrayLike
) – A pre-validated, backend-specific array object that will be wrapped by this buffer. Must be an instance of the class’s__core_array_types__
, if that attribute is defined.- Raises:
TypeError – If the array does not match the expected core type(s).
See also
BufferBase.from_array
Preferred interface for safe buffer construction.
BufferBase.coerce
Coerces arbitrary array-like objects into valid buffers.