pyvista_ndarray.squeeze#
- pyvista_ndarray.squeeze( ) Self#
Remove axes of length one while retaining an array view.
Changed in version 0.50: Single-element inputs return zero-dimensional array views.
- Parameters:
- Returns:
pyvista.pyvista_ndarrayView of the array with the selected axes removed. If all axes are removed, the result is a zero-dimensional array, not a scalar. If the shape is unchanged, return this array.
Examples#
Download Python source code | Download Jupyter notebook
>>> import pyvista as pv
>>> array = pv.pyvista_ndarray([[1]])
>>> squeezed = array.squeeze()
>>> squeezed.shape
()
>>> squeezed[...] = 2
>>> array
pyvista_ndarray([[2]])