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

Method test_squeeze

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

Source from the content-addressed store, hash-verified

2008
2009 @pytest.mark.parametrize("dim", ("x", "y", "z", "t", "all"))
2010 def test_squeeze(self, dim, dtype):
2011 shape = (2, 1, 3, 1, 1, 2)
2012 names = list("abcdef")
2013 dim_lengths = dict(zip(names, shape, strict=True))
2014 array = np.ones(shape=shape) * unit_registry.m
2015 variable = xr.Variable(names, array)
2016
2017 kwargs = {"dim": dim} if dim != "all" and dim_lengths.get(dim, 0) == 1 else {}
2018 expected = attach_units(
2019 strip_units(variable).squeeze(**kwargs), extract_units(variable)
2020 )
2021 actual = variable.squeeze(**kwargs)
2022
2023 assert_units_equal(expected, actual)
2024 assert_identical(expected, actual)
2025
2026 @pytest.mark.parametrize("compute_backend", ["numbagg", None], indirect=True)
2027 @pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 7

squeezeMethod · 0.95
assert_identicalFunction · 0.90
attach_unitsFunction · 0.85
strip_unitsFunction · 0.85
extract_unitsFunction · 0.85
assert_units_equalFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected