()
| 1458 | |
| 1459 | |
| 1460 | def test_iter_copy_casts_structured2(): |
| 1461 | # Similar to the above, this is a fairly arcane test to cover internals |
| 1462 | in_dtype = np.dtype([("a", np.dtype("O,O")), |
| 1463 | ("b", np.dtype("(5)O,(3)O,(1,)O,(1,)i,(1,)O"))]) |
| 1464 | out_dtype = np.dtype([("a", np.dtype("O")), |
| 1465 | ("b", np.dtype("O,(3)i,(4)O,(4)O,(4)i"))]) |
| 1466 | |
| 1467 | arr = np.ones(1, dtype=in_dtype) |
| 1468 | it = np.nditer((arr,), ["buffered", "external_loop", "refs_ok"], |
| 1469 | op_dtypes=[out_dtype], casting="unsafe") |
| 1470 | it_copy = it.copy() |
| 1471 | |
| 1472 | res1 = next(it) |
| 1473 | del it |
| 1474 | res2 = next(it_copy) |
| 1475 | del it_copy |
| 1476 | |
| 1477 | # Array of two structured scalars: |
| 1478 | for res in res1, res2: |
| 1479 | # Cast to tuple by getitem, which may be weird and changable?: |
| 1480 | assert type(res["a"][0]) == tuple |
| 1481 | assert res["a"][0] == (1, 1) |
| 1482 | |
| 1483 | for res in res1, res2: |
| 1484 | assert_array_equal(res["b"]["f0"][0], np.ones(5, dtype=object)) |
| 1485 | assert_array_equal(res["b"]["f1"], np.ones((1, 3), dtype="i")) |
| 1486 | assert res["b"]["f2"].shape == (1, 4) |
| 1487 | assert_array_equal(res["b"]["f2"][0], np.ones(4, dtype=object)) |
| 1488 | assert_array_equal(res["b"]["f3"][0], np.ones(4, dtype=object)) |
| 1489 | assert_array_equal(res["b"]["f3"][0], np.ones(4, dtype="i")) |
| 1490 | |
| 1491 | |
| 1492 | def test_iter_allocate_output_simple(): |
nothing calls this directly
no test coverage detected