| 2459 | np.array([T()]) |
| 2460 | |
| 2461 | def test_2d__array__shape(self): |
| 2462 | class T: |
| 2463 | def __array__(self): |
| 2464 | return np.ndarray(shape=(0,0)) |
| 2465 | |
| 2466 | # Make sure __array__ is used instead of Sequence methods. |
| 2467 | def __iter__(self): |
| 2468 | return iter([]) |
| 2469 | |
| 2470 | def __getitem__(self, idx): |
| 2471 | raise AssertionError("__getitem__ was called") |
| 2472 | |
| 2473 | def __len__(self): |
| 2474 | return 0 |
| 2475 | |
| 2476 | |
| 2477 | t = T() |
| 2478 | # gh-13659, would raise in broadcasting [x=t for x in result] |
| 2479 | arr = np.array([t]) |
| 2480 | assert arr.shape == (1, 0, 0) |
| 2481 | |
| 2482 | @pytest.mark.skipif(sys.maxsize < 2 ** 31 + 1, reason='overflows 32-bit python') |
| 2483 | def test_to_ctypes(self): |