(*xi, sparse=False, indexing="xy", **kwargs)
| 469 | |
| 470 | @derived_from(np) |
| 471 | def meshgrid(*xi, sparse=False, indexing="xy", **kwargs): |
| 472 | sparse = bool(sparse) |
| 473 | |
| 474 | if "copy" in kwargs: |
| 475 | raise NotImplementedError("`copy` not supported") |
| 476 | |
| 477 | if kwargs: |
| 478 | raise TypeError("unsupported keyword argument(s) provided") |
| 479 | |
| 480 | if indexing not in ("ij", "xy"): |
| 481 | raise ValueError("`indexing` must be `'ij'` or `'xy'`") |
| 482 | |
| 483 | xi = [asarray(e) for e in xi] |
| 484 | xi = [e.flatten() for e in xi] |
| 485 | |
| 486 | if indexing == "xy" and len(xi) > 1: |
| 487 | xi[0], xi[1] = xi[1], xi[0] |
| 488 | |
| 489 | grid = [] |
| 490 | for i in range(len(xi)): |
| 491 | s = len(xi) * [None] |
| 492 | s[i] = slice(None) |
| 493 | s = tuple(s) |
| 494 | |
| 495 | r = xi[i][s] |
| 496 | |
| 497 | grid.append(r) |
| 498 | |
| 499 | if not sparse: |
| 500 | grid = broadcast_arrays(*grid) |
| 501 | |
| 502 | if indexing == "xy" and len(xi) > 1: |
| 503 | grid = (grid[1], grid[0], *grid[2:]) |
| 504 | |
| 505 | out_type = tuple if NUMPY_GE_200 else list |
| 506 | return out_type(grid) |
| 507 | |
| 508 | |
| 509 | def indices(dimensions, dtype=int, chunks="auto"): |
no test coverage detected
searching dependent graphs…