pyvista.DataSetAttributes.update#

DataSetAttributes.update(array_dict: dict[str, NumpyArray[float]] | DataSetAttributes)[source]#

Update arrays in this object from another dictionary or dataset attributes.

For each key, value given, add the pair. If it already exists, replace it with the new array. These arrays will be copied.

Parameters:
array_dictdict, DataSetAttributes

A dictionary of (array name, :class:`numpy.ndarray`) or a pyvista.DataSetAttributes.

Examples

Add two arrays to point_data using update.

>>> import numpy as np
>>> from pyvista import examples
>>> mesh = examples.load_uniform()
>>> n = len(mesh.point_data)
>>> arrays = {
...     'foo': np.arange(mesh.n_points),
...     'rand': np.random.default_rng().random(mesh.n_points),
... }
>>> mesh.point_data.update(arrays)
>>> mesh.point_data
pyvista DataSetAttributes
Association     : POINT
Active Scalars  : Spatial Point Data
Active Vectors  : None
Active Texture  : None
Active Normals  : None
Contains arrays :
    Spatial Point Data      float64    (1000,)              SCALARS
    foo                     int64      (1000,)
    rand                    float64    (1000,)