MCPcopy
hub / github.com/pydata/xarray / test_squeeze

Method test_squeeze

xarray/tests/test_units.py:3442–3457  ·  view source on GitHub ↗
(self, shape, dim, dtype)

Source from the content-addressed store, hash-verified

3440 ),
3441 )
3442 def test_squeeze(self, shape, dim, dtype):
3443 names = "xyzt"
3444 dim_lengths = dict(zip(names, shape, strict=False))
3445 names = "xyzt"
3446 array = np.arange(10 * 20).astype(dtype).reshape(shape) * unit_registry.J
3447 data_array = xr.DataArray(data=array, dims=tuple(names[: len(shape)]))
3448
3449 kwargs = {"dim": dim} if dim != "all" and dim_lengths.get(dim, 0) == 1 else {}
3450
3451 expected = attach_units(
3452 strip_units(data_array).squeeze(**kwargs), extract_units(data_array)
3453 )
3454 actual = data_array.squeeze(**kwargs)
3455
3456 assert_units_equal(expected, actual)
3457 assert_identical(expected, actual)
3458
3459 @pytest.mark.parametrize(
3460 "func",

Callers

nothing calls this directly

Calls 9

assert_identicalFunction · 0.90
attach_unitsFunction · 0.85
strip_unitsFunction · 0.85
extract_unitsFunction · 0.85
assert_units_equalFunction · 0.85
arangeMethod · 0.80
astypeMethod · 0.45
getMethod · 0.45
squeezeMethod · 0.45

Tested by

no test coverage detected