(self)
| 2024 | |
| 2025 | @requires_bottleneck |
| 2026 | def test_rank(self): |
| 2027 | import bottleneck as bn |
| 2028 | |
| 2029 | # floats |
| 2030 | v = Variable(["x", "y"], [[3, 4, np.nan, 1]]) |
| 2031 | expect_0 = bn.nanrankdata(v.data, axis=0) |
| 2032 | expect_1 = bn.nanrankdata(v.data, axis=1) |
| 2033 | np.testing.assert_allclose(v.rank("x").values, expect_0) |
| 2034 | np.testing.assert_allclose(v.rank("y").values, expect_1) |
| 2035 | # int |
| 2036 | v = Variable(["x"], [3, 2, 1]) |
| 2037 | expect = bn.rankdata(v.data, axis=0) |
| 2038 | np.testing.assert_allclose(v.rank("x").values, expect) |
| 2039 | # str |
| 2040 | v = Variable(["x"], ["c", "b", "a"]) |
| 2041 | expect = bn.rankdata(v.data, axis=0) |
| 2042 | np.testing.assert_allclose(v.rank("x").values, expect) |
| 2043 | # pct |
| 2044 | v = Variable(["x"], [3.0, 1.0, np.nan, 2.0, 4.0]) |
| 2045 | v_expect = Variable(["x"], [0.75, 0.25, np.nan, 0.5, 1.0]) |
| 2046 | assert_equal(v.rank("x", pct=True), v_expect) |
| 2047 | # invalid dim |
| 2048 | with pytest.raises(ValueError): |
| 2049 | # apply_ufunc error message isn't great here — `ValueError: tuple.index(x): x not in tuple` |
| 2050 | v.rank("y") |
| 2051 | |
| 2052 | def test_big_endian_reduce(self): |
| 2053 | # regression test for GH489 |
nothing calls this directly
no test coverage detected