NDField

This class is used to represent fields of a structured NDArray.

For instance, you can create an array with two fields:

s = blosc2.empty(shape, dtype=[("a", np.float32), ("b", np.float64)])
a = blosc2.NDField(s, "a")
b = blosc2.NDField(s, "b")
class blosc2.NDField(ndarr: NDArray, field: str)[source]
Attributes:
device

Hardware device the array data resides on.

dtype

The dtype of the field of associated NDArray.

info

Get information about the Operand.

ndim

Get the number of dimensions of the Operand.

schunk

The associated SChunk.

shape

The shape of the associated NDArray.

Methods

all([axis, keepdims])

Test whether all array elements along a given axis evaluate to True.

any([axis, keepdims])

Test whether any array element along a given axis evaluates to True.

argmax([axis, keepdims])

Returns the indices of the maximum values along a specified axis.

argmin([axis, keepdims])

Returns the indices of the minimum values along a specified axis.

item()

Copy an element of an array to a standard Python scalar and return it.

max([axis, keepdims])

Return the maximum along a given axis.

mean([axis, dtype, keepdims])

Return the arithmetic mean along the specified axis.

min([axis, keepdims])

Return the minimum along a given axis.

prod([axis, dtype, keepdims])

Return the product of array elements over a given axis.

std([axis, dtype, ddof, keepdims])

Return the standard deviation along the specified axis.

sum([axis, dtype, keepdims])

Return the sum of array elements over a given axis.

to_device(device)

Copy the array from the device on which it currently resides to the specified device.

var([axis, dtype, ddof, keepdims])

Return the variance along the specified axis.

where([value1, value2])

Select value1 or value2 values based on True/False for self.

Special Methods:

__init__(ndarr, field)

Create a new NDField.

__iter__()

Iterate over the elements in the field.

__len__()

Returns the length of the first dimension of the field.

__getitem__(key)

Get a slice of self.

__setitem__(key, value)

Set a slice of self to a value.

Constructor

__init__(ndarr: NDArray, field: str)[source]

Create a new NDField.

Parameters:
  • ndarr (NDArray) – The NDArray to which assign the field.

  • field (str) – The field’s name.

Returns:

out – The corresponding NDField.

Return type:

NDField

Utility Methods

__iter__()[source]

Iterate over the elements in the field.

Returns:

out

Return type:

iterator

__len__() int[source]

Returns the length of the first dimension of the field.

__getitem__(key: int | slice | Sequence[slice]) np.ndarray[source]

Get a slice of self.

Parameters:

key (int or slice or Sequence[slice]) – The slice to be retrieved.

Returns:

out – A NumPy array with the data slice.

Return type:

NumPy.ndarray

__setitem__(key: int | slice | Sequence[slice], value: blosc2.Array) None[source]

Set a slice of self to a value.

Parameters:
  • key (int or slice or Sequence[slice]) – The slice to be set.

  • value (blosc2.Array) – The value to be set.

property dtype: dtype

The dtype of the field of associated NDArray.

property schunk: SChunk

The associated SChunk.

property shape: tuple[int]

The shape of the associated NDArray.