MCPcopy Index your code
hub / github.com/pydata/xarray / test_last

Method test_last

xarray/tests/test_duck_array_ops.py:139–160  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

137 first(self.x, 3)
138
139 def test_last(self):
140 expected_results = [
141 array([[nan, 13, 14, 15], [nan, 17, 18, nan], [8, 21, 10, nan]]),
142 array([[8, 9, 10, nan], [nan, 21, 18, 15]]),
143 array([[2, 6, 10], [15, 18, 21]]),
144 ]
145 for axis, expected in zip(
146 [0, 1, 2, -3, -2, -1], 2 * expected_results, strict=True
147 ):
148 actual = last(self.x, axis)
149 assert_array_equal(expected, actual)
150
151 expected = self.x[-1]
152 actual = last(self.x, axis=0, skipna=False)
153 assert_array_equal(expected, actual)
154
155 expected = self.x[..., -1]
156 actual = last(self.x, axis=-1, skipna=False)
157 assert_array_equal(expected, actual)
158
159 with pytest.raises(IndexError, match=r"out of bounds"):
160 last(self.x, 3)
161
162 def test_count(self):
163 assert 12 == count(self.x)

Callers

nothing calls this directly

Calls 2

lastFunction · 0.90
arrayFunction · 0.85

Tested by

no test coverage detected