dask 2021.10.0

ParametersRaisesReturns
squeeze(a, axis=None)

This docstring was copied from numpy.squeeze.

Some inconsistencies with the Dask version may exist.

Parameters

a : array_like

Input data.

axis : None or int or tuple of ints, optional
versionadded

Selects a subset of the entries of length one in the shape. If an axis is selected with shape entry greater than one, an error is raised.

Raises

ValueError

If :None:None:`axis` is not None, and an axis being squeezed is not of length 1

Returns

squeezed : ndarray

The input array, but with all or a subset of the dimensions of length 1 removed. This is always a itself or a view into a. Note that if all axes are squeezed, the result is a 0d array and not a scalar.

Remove axes of length one from a.

See Also

expand_dims

The inverse operation, adding entries of length one

reshape

Insert, remove, and combine dimensions, and resize existing ones

Examples

This example is valid syntax, but we were not able to check execution
>>> x = np.array([[[0], [1], [2]]])  # doctest: +SKIP
... x.shape # doctest: +SKIP (1, 3, 1)
This example is valid syntax, but we were not able to check execution
>>> np.squeeze(x).shape  # doctest: +SKIP
(3,)
This example is valid syntax, but we were not able to check execution
>>> np.squeeze(x, axis=0).shape  # doctest: +SKIP
(3, 1)
This example is valid syntax, but we were not able to check execution
>>> np.squeeze(x, axis=1).shape  # doctest: +SKIP
Traceback (most recent call last):
...
ValueError: cannot select an axis to squeeze out which has size not equal to one
This example is valid syntax, but we were not able to check execution
>>> np.squeeze(x, axis=2).shape  # doctest: +SKIP
(1, 3)
This example is valid syntax, but we were not able to check execution
>>> x = np.array([[1234]])  # doctest: +SKIP
... x.shape # doctest: +SKIP (1, 1)
This example is valid syntax, but we were not able to check execution
>>> np.squeeze(x)  # doctest: +SKIP
array(1234)  # 0d array
This example is valid syntax, but we were not able to check execution
>>> np.squeeze(x).shape  # doctest: +SKIP
()
This example is valid syntax, but we were not able to check execution
>>> np.squeeze(x)[()]  # doctest: +SKIP
1234
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /dask/array/routines.py#1858
type: <class 'function'>
Commit: