pyvista.DataSetAttributes.update#
- DataSetAttributes.update(
- array_dict: dict[str, NumpyArray[float]] | DataSetAttributes,
- copy: bool = True,
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_dict
dict
,DataSetAttributes
A dictionary of
(array name, :class:`numpy.ndarray`)
or apyvista.DataSetAttributes
.- copybool, default:
True
If
True
, arrays fromarray_dict
are copied to this object.
- array_dict
Examples
Add two arrays to
point_data
usingupdate
.>>> 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,)