import dascore as dc
import numpy as np
patch = dc.get_example_patch()
# Create a patch with a length-1 dimension by selecting time slice
time_array = patch.coords.get_array("time")
single_time = patch.select(time=(time_array[0], time_array[0]))
# Squeeze the length-1 time dimension
squeezed = single_time.squeeze(dim="time")Squeeze
Squeeze(
*args ,
dim: Any = None,
)-> None
Return a new object with len one dimensions flattened.
Parameters
| Parameter | Description |
|---|---|
| dim |
Selects a subset of the length one dimensions. If a dimension is selected with length greater than one, an error is raised. If None, all length one dimensions are squeezed. |
Raises
CoordError If a selected dimension does not exist or has more than one sample. ParameterError If squeezing would remove every dimension from the patch.
Examples
Methods
| Name | Description |
|---|---|
| check | Refuse a patch which does not carry what the operation needs. |
| get_metadata | Return the shorter coordinates, and the axes which go with them. |
| kernel | Return the data without the axes which were squeezed out. |
| model_copy | Copy the model, dropping cached values the update invalidates. |
| new | Create new instance with some attributed updated. |
| squeeze | Return a new object with len one dimensions flattened. |
| reconcile | Return metadata or a patch holding the final data; default as is. |
| run | Run the operation: check, get_metadata, kernel, reconcile, record. |