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

Method test_rank_dask

xarray/tests/test_variable.py:2003–2017  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2001 @requires_dask
2002 @requires_bottleneck
2003 def test_rank_dask(self):
2004 # Instead of a single test here, we could parameterize the other tests for both
2005 # arrays. But this is sufficient.
2006 v = Variable(
2007 ["x", "y"], [[30.0, 1.0, np.nan, 20.0, 4.0], [30.0, 1.0, np.nan, 20.0, 4.0]]
2008 ).chunk(x=1)
2009 expected = Variable(
2010 ["x", "y"], [[4.0, 1.0, np.nan, 3.0, 2.0], [4.0, 1.0, np.nan, 3.0, 2.0]]
2011 )
2012 assert_equal(v.rank("y").compute(), expected)
2013
2014 with pytest.raises(
2015 ValueError, match=r" with dask='parallelized' consists of multiple chunks"
2016 ):
2017 v.rank("x")
2018
2019 def test_rank_use_bottleneck(self):
2020 v = Variable(["x"], [3.0, 1.0, np.nan, 2.0, 4.0])

Callers

nothing calls this directly

Calls 5

VariableClass · 0.90
assert_equalFunction · 0.90
chunkMethod · 0.45
computeMethod · 0.45
rankMethod · 0.45

Tested by

no test coverage detected