| 526 | |
| 527 | @pytest.mark.parametrize("arraylike", arraylikes()) |
| 528 | def test_nested_arraylikes(self, arraylike): |
| 529 | # We try storing an array like into an array, but the array-like |
| 530 | # will have too many dimensions. This means the shape discovery |
| 531 | # decides that the array-like must be treated as an object (a special |
| 532 | # case of ragged discovery). The result will be an array with one |
| 533 | # dimension less than the maximum dimensions, and the array being |
| 534 | # assigned to it (which does work for object or if `float(arraylike)` |
| 535 | # works). |
| 536 | initial = arraylike(np.ones((1, 1))) |
| 537 | |
| 538 | nested = initial |
| 539 | for i in range(ncu.MAXDIMS - 1): |
| 540 | nested = [nested] |
| 541 | |
| 542 | with pytest.raises(ValueError, match=".*would exceed the maximum"): |
| 543 | # It will refuse to assign the array into |
| 544 | np.array(nested, dtype="float64") |
| 545 | |
| 546 | # If this is object, we end up assigning a (1, 1) array into (1,) |
| 547 | # (due to running out of dimensions), this is currently supported but |
| 548 | # a special case which is not ideal. |
| 549 | arr = np.array(nested, dtype=object) |
| 550 | assert arr.shape == (1,) * ncu.MAXDIMS |
| 551 | assert arr.item() == np.array(initial).item() |
| 552 | |
| 553 | @pytest.mark.parametrize("arraylike", arraylikes()) |
| 554 | def test_uneven_depth_ragged(self, arraylike): |