| 114 | ) |
| 115 | |
| 116 | def test_first(self): |
| 117 | expected_results = [ |
| 118 | array([[nan, 13, 2, 15], [nan, 5, 6, nan], [8, 9, 10, nan]]), |
| 119 | array([[8, 5, 2, nan], [nan, 13, 14, 15]]), |
| 120 | array([[2, 5, 8], [13, 17, 21]]), |
| 121 | ] |
| 122 | for axis, expected in zip( |
| 123 | [0, 1, 2, -3, -2, -1], 2 * expected_results, strict=True |
| 124 | ): |
| 125 | actual = first(self.x, axis) |
| 126 | assert_array_equal(expected, actual) |
| 127 | |
| 128 | expected = self.x[0] |
| 129 | actual = first(self.x, axis=0, skipna=False) |
| 130 | assert_array_equal(expected, actual) |
| 131 | |
| 132 | expected = self.x[..., 0] |
| 133 | actual = first(self.x, axis=-1, skipna=False) |
| 134 | assert_array_equal(expected, actual) |
| 135 | |
| 136 | with pytest.raises(IndexError, match=r"out of bounds"): |
| 137 | first(self.x, 3) |
| 138 | |
| 139 | def test_last(self): |
| 140 | expected_results = [ |