(self)
| 272 | self.assertTupleEqual(np.array(single_arr).shape, (first_dim, *fixed_shape)) |
| 273 | |
| 274 | def test_to_numpy(self): |
| 275 | fixed_shape = (2, 2) |
| 276 | |
| 277 | # ragged |
| 278 | first_dim_list = [1, 3, 10] |
| 279 | dataset = self.get_one_col_dataset(first_dim_list, fixed_shape) |
| 280 | arr_xd = SimpleArrowExtractor().extract_column(dataset._data) |
| 281 | self.assertIsInstance(arr_xd.type, Array3DExtensionType) |
| 282 | # replace with arr_xd = arr_xd.combine_chunks() when 12.0.0 will be the minimal required PyArrow version |
| 283 | arr_xd = arr_xd.type.wrap_array(pa.concat_arrays([chunk.storage for chunk in arr_xd.chunks])) |
| 284 | numpy_arr = arr_xd.to_numpy() |
| 285 | |
| 286 | self.assertIsInstance(numpy_arr, np.ndarray) |
| 287 | self.assertEqual(numpy_arr.dtype, object) |
| 288 | for first_dim, single_arr in zip(first_dim_list, numpy_arr): |
| 289 | self.assertIsInstance(single_arr, np.ndarray) |
| 290 | self.assertTupleEqual(single_arr.shape, (first_dim, *fixed_shape)) |
| 291 | |
| 292 | # non-ragged |
| 293 | first_dim_list = [4, 4, 4] |
| 294 | dataset = self.get_one_col_dataset(first_dim_list, fixed_shape) |
| 295 | arr_xd = SimpleArrowExtractor().extract_column(dataset._data) |
| 296 | self.assertIsInstance(arr_xd.type, Array3DExtensionType) |
| 297 | # replace with arr_xd = arr_xd.combine_chunks() when 12.0.0 will be the minimal required PyArrow version |
| 298 | arr_xd = arr_xd.type.wrap_array(pa.concat_arrays([chunk.storage for chunk in arr_xd.chunks])) |
| 299 | numpy_arr = arr_xd.to_numpy() |
| 300 | |
| 301 | self.assertIsInstance(numpy_arr, np.ndarray) |
| 302 | self.assertNotEqual(numpy_arr.dtype, object) |
| 303 | for first_dim, single_arr in zip(first_dim_list, numpy_arr): |
| 304 | self.assertIsInstance(single_arr, np.ndarray) |
| 305 | self.assertTupleEqual(single_arr.shape, (first_dim, *fixed_shape)) |
| 306 | |
| 307 | def test_iter_dataset(self): |
| 308 | fixed_shape = (2, 2) |
nothing calls this directly
no test coverage detected