vtkmodules.numpy_interface.vtk_composite_array#

VTKCompositeArray — numpy-compatible mixin for vtkCompositeArray.

This module provides the VTKCompositeArray mixin class and registers overrides for all vtkCompositeArray instantiations so that composite arrays coming from VTK automatically have numpy-compatible operations.

A vtkCompositeArray concatenates multiple sub-arrays into a single virtual array. Each sub-array already has its own numpy mixin, so operations are delegated per-sub-array and combined, minimizing materialization. Reductions (sum, min, max, mean, std, var) operate in O(n_arrays) rather than O(n_elements).

Module Contents#

Classes#

VTKCompositeArray

A numpy-compatible mixin for composite (concatenated) implicit arrays.

Functions#

API#

class vtkmodules.numpy_interface.vtk_composite_array.VTKCompositeArray(arrays=None, **kwargs)#

Bases: vtkmodules.numpy_interface._vtk_array_mixin.VTKDataArrayMixin

A numpy-compatible mixin for composite (concatenated) implicit arrays.

vtkCompositeArray stores multiple sub-arrays and presents them as a single virtual array using O(log n) binary search for element access. This Python mixin adds numpy integration: arithmetic, reductions, indexing, and to_numpy() — delegating to per-sub-array operations to minimize materialization.

Initialization

Create a composite array.

Parameters

arrays : iterable of vtkDataArray, optional Sub-arrays to concatenate. All must have the same number of components. When omitted, creates an empty composite that can be populated later via the C++ API. **kwargs Forwarded to the VTK base-class initializer.

property arrays#

Return the list of original sub-arrays (with their own mixins).

Each sub-array is the original vtkDataArray passed to the backend, enhanced with whatever mixin it has (VTKAOSArray, VTKConstantArray, etc.).

property _offsets#

Return the list of tuple offsets for each sub-array.

property dtype#
property nbytes#
to_numpy(dtype=None)#

Materialize the full array as a numpy ndarray.

__array__(dtype=None, copy=None)#

Materialize the full array by concatenating sub-arrays.

__buffer__(flags)#

Override C-level buffer protocol to materialize via concatenation.

__array_ufunc__(ufunc, method, *inputs, **kwargs)#

Handle numpy ufuncs by applying per-sub-array.

__array_function__(func, types, args, kwargs)#

Dispatch numpy functions with per-sub-array overrides where possible.

__getitem__(key)#

Index into the composite array.

Scalar index delegates to the appropriate sub-array. Slices map to sub-array ranges and concatenate. Fancy/boolean indexing materializes.

__setitem__(key, value)#
__add__(other)#
__radd__(other)#
__sub__(other)#
__rsub__(other)#
__mul__(other)#
__rmul__(other)#
__truediv__(other)#
__rtruediv__(other)#
__floordiv__(other)#
__rfloordiv__(other)#
__pow__(other)#
__rpow__(other)#
__mod__(other)#
__rmod__(other)#
__lt__(other)#
__le__(other)#
__eq__(other)#
__ne__(other)#
__ge__(other)#
__gt__(other)#
__neg__()#
__pos__()#
__abs__()#
sum(axis=None, **kwargs)#
min(axis=None, **kwargs)#
max(axis=None, **kwargs)#
mean(axis=None, **kwargs)#
std(axis=None, **kwargs)#
var(axis=None, **kwargs)#
any(axis=None, **kwargs)#
all(axis=None, **kwargs)#
prod(axis=None, **kwargs)#
__iter__()#
__repr__()#
__str__()#
vtkmodules.numpy_interface.vtk_composite_array._composite_sum(a, axis=None, **kwargs)#
vtkmodules.numpy_interface.vtk_composite_array._composite_mean(a, axis=None, **kwargs)#
vtkmodules.numpy_interface.vtk_composite_array._composite_min(a, axis=None, **kwargs)#
vtkmodules.numpy_interface.vtk_composite_array._composite_max(a, axis=None, **kwargs)#
vtkmodules.numpy_interface.vtk_composite_array._composite_std(a, axis=None, **kwargs)#
vtkmodules.numpy_interface.vtk_composite_array._composite_var(a, axis=None, **kwargs)#
vtkmodules.numpy_interface.vtk_composite_array._composite_any(a, axis=None, **kwargs)#
vtkmodules.numpy_interface.vtk_composite_array._composite_all(a, axis=None, **kwargs)#
vtkmodules.numpy_interface.vtk_composite_array._composite_prod(a, axis=None, **kwargs)#
vtkmodules.numpy_interface.vtk_composite_array._composite_concatenate(arrays, axis=0, **kwargs)#
vtkmodules.numpy_interface.vtk_composite_array._register_composite_overrides()#

Register VTKCompositeArray mixin as override for all vtkCompositeArray template types.