| 2415 | return Variable(*args, **kwargs).chunk() |
| 2416 | |
| 2417 | def test_chunk(self): |
| 2418 | unblocked = Variable(["dim_0", "dim_1"], np.ones((3, 4))) |
| 2419 | assert unblocked.chunks is None |
| 2420 | |
| 2421 | blocked = unblocked.chunk() |
| 2422 | assert blocked.chunks == ((3,), (4,)) |
| 2423 | first_dask_name = blocked.data.name |
| 2424 | |
| 2425 | blocked = unblocked.chunk(chunks=((2, 1), (2, 2))) # type: ignore[arg-type] |
| 2426 | assert blocked.chunks == ((2, 1), (2, 2)) |
| 2427 | assert blocked.data.name != first_dask_name |
| 2428 | |
| 2429 | blocked = unblocked.chunk(chunks=(3, 3)) |
| 2430 | assert blocked.chunks == ((3,), (3, 1)) |
| 2431 | assert blocked.data.name != first_dask_name |
| 2432 | |
| 2433 | # name doesn't change when rechunking by same amount |
| 2434 | # this fails if ReprObject doesn't have __dask_tokenize__ defined |
| 2435 | assert unblocked.chunk(2).data.name == unblocked.chunk(2).data.name |
| 2436 | |
| 2437 | assert blocked.load().chunks is None |
| 2438 | |
| 2439 | # Check that kwargs are passed |
| 2440 | import dask.array as da |
| 2441 | |
| 2442 | blocked = unblocked.chunk(name="testname_") |
| 2443 | assert isinstance(blocked.data, da.Array) |
| 2444 | assert "testname_" in blocked.data.name |
| 2445 | |
| 2446 | # test kwargs form of chunks |
| 2447 | blocked = unblocked.chunk(dim_0=3, dim_1=3) |
| 2448 | assert blocked.chunks == ((3,), (3, 1)) |
| 2449 | assert blocked.data.name != first_dask_name |
| 2450 | |
| 2451 | @pytest.mark.skip |
| 2452 | def test_0d_object_array_with_list(self): |