()
| 179 | |
| 180 | @pytest.mark.numpy |
| 181 | def test_chunked_array_getitem(): |
| 182 | data = [ |
| 183 | pa.array([1, 2, 3]), |
| 184 | pa.array([4, 5, 6]) |
| 185 | ] |
| 186 | data = pa.chunked_array(data) |
| 187 | assert data[1].as_py() == 2 |
| 188 | assert data[-1].as_py() == 6 |
| 189 | assert data[-6].as_py() == 1 |
| 190 | with pytest.raises(IndexError): |
| 191 | data[6] |
| 192 | with pytest.raises(IndexError): |
| 193 | data[-7] |
| 194 | # Ensure this works with numpy scalars |
| 195 | assert data[np.int32(1)].as_py() == 2 |
| 196 | |
| 197 | data_slice = data[2:4] |
| 198 | assert data_slice.to_pylist() == [3, 4] |
| 199 | |
| 200 | data_slice = data[4:-1] |
| 201 | assert data_slice.to_pylist() == [5] |
| 202 | |
| 203 | data_slice = data[99:99] |
| 204 | assert data_slice.type == data.type |
| 205 | assert data_slice.to_pylist() == [] |
| 206 | |
| 207 | |
| 208 | def test_chunked_array_slice(): |
nothing calls this directly
no test coverage detected