pyvista.convert_array

Contents

pyvista.convert_array#

convert_array(
arr: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | vtkAbstractArray | None,
name: str | None = None,
deep: bool = False,
array_type: int | None = None,
) ndarray[Any, dtype[Any]] | vtkAbstractArray | None[source]#

Convert a NumPy array to a vtkDataArray or vice versa.

Parameters:
arrnp.ndarray | vtkDataArray

A numpy array or vtkDataArry to convert.

namestr, optional

The name of the data array for VTK.

deepbool, default: False

If input is numpy array then deep copy values.

array_typeint, optional

VTK array type ID as specified in vtkType.h.

Returns:
vtkDataArray or numpy.ndarray

The converted array. If input is a numpy.ndarray then returns vtkDataArray or is input is vtkDataArray then returns NumPy ndarray.