fields.buffers.base.BufferBase.resolve#

classmethod BufferBase.resolve(array_like: Any, *args, buffer_registry: BufferRegistry | None = None, **kwargs) BufferBase[source]#

Resolve and instantiate a buffer subclass for an arbitrary array-like input.

This method delegates to buffer_from_array(), which attempts to find a compatible buffer backend and coerce the input into it. The registry dispatch system is used unless explicitly overridden.

Parameters:
  • array_like (Any) – An array-like object to be wrapped as a buffer. Supported types vary depending on the registered buffer classes (e.g., np.ndarray, unyt_array, h5py.Dataset).

  • buffer_registry (_BufferRegistry, optional) – A custom buffer registry to use for dispatch. If None (default), the global __DEFAULT_BUFFER_REGISTRY__ will be used.

  • *args (dict) – Additional arguments passed to the buffer_from_array() method of the resolved buffer class. These may include unit annotations, dtype specifications, HDF5 parameters, etc.

  • **kwargs (dict) – Additional arguments passed to the buffer_from_array() method of the resolved buffer class. These may include unit annotations, dtype specifications, HDF5 parameters, etc.

Returns:

An instance of the appropriate buffer subclass, wrapping the adapted array data.

Return type:

BufferBase

Raises:

TypeError – If no compatible buffer class is found in the registry for the given object type.

See also

buffer_from_array

General-purpose resolution utility.

BufferBase.from_array

Class-based coercion.

BufferBase.coerce

Direct array conversion method.