| 414 | @pytest.mark.parametrize("indexing", ["ij", "xy"]) |
| 415 | @pytest.mark.parametrize("sparse", [False, True]) |
| 416 | def test_meshgrid(shapes, chunks, indexing, sparse): |
| 417 | xi_a = [] |
| 418 | xi_d = [] |
| 419 | xi_dc = [] |
| 420 | for each_shape, each_chunk in zip(shapes, chunks): |
| 421 | xi_a.append(np.random.random(each_shape)) |
| 422 | xi_d_e = da.from_array(xi_a[-1], chunks=each_chunk) |
| 423 | xi_d.append(xi_d_e) |
| 424 | xi_d_ef = xi_d_e.flatten() |
| 425 | xi_dc.append(xi_d_ef.chunks[0]) |
| 426 | do = list(range(len(xi_dc))) |
| 427 | if indexing == "xy" and len(xi_dc) > 1: |
| 428 | do[0], do[1] = do[1], do[0] |
| 429 | xi_dc[0], xi_dc[1] = xi_dc[1], xi_dc[0] |
| 430 | xi_dc = tuple(xi_dc) |
| 431 | |
| 432 | r_a = np.meshgrid(*xi_a, indexing=indexing, sparse=sparse) |
| 433 | r_d = da.meshgrid(*xi_d, indexing=indexing, sparse=sparse) |
| 434 | |
| 435 | assert type(r_d) is type(r_a) |
| 436 | assert len(r_a) == len(r_d) |
| 437 | |
| 438 | for e_r_a, e_r_d, i in zip(r_a, r_d, do): |
| 439 | assert_eq(e_r_a, e_r_d) |
| 440 | if sparse: |
| 441 | assert e_r_d.chunks[i] == xi_dc[i] |
| 442 | else: |
| 443 | assert e_r_d.chunks == xi_dc |
| 444 | |
| 445 | |
| 446 | def test_meshgrid_inputcoercion(): |