Skip to content

PR: Add meshgrid #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 19, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions spec/API_specification/creation_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,49 @@ Returns evenly spaced numbers over a specified interval.

- a one-dimensional array containing evenly spaced values.

(function-meshgrid)=
### meshgrid(*arrays, /, indexing='xy')

Returns coordinate matrices from coordinate vectors.

### Special cases

- For `n` one dimensional arrays `x1, x2, ..., xn` with lengths `Ni = len(xi)`, this function returns `(N1, N2, N3, ..., Nn)` shaped arrays if the indexing is 'ij' or `(N2, N1, N3, ..., Nn)` shaped arrays if indexing 'xy'.

- The 0-D and 1-D case, the indexing keyword has no effect.

### Parameters

- **\*arrays**: _<array>_

- One dimensional arrays representing the coordinates of the grid.

- **indexing**: _Optional\[ str ]_

- Cartesian 'xy' by default or 'ij' for matrix indexing of the output.

### Returns

- **out**: _Tuple\[ <array>, ... ]_

- List of N arrays with rank `max(2, N)`.

### Notes

This function supports indexing conventions using the `indexing` keyword. In the case of `xy` the function will return a meshgrid with cartesian indexing, while `ij` will use matrix indexing. The difference is illustrated by the following code snippet:

```
xv, yv = meshgrid(x, y, indexing='xy')
for i in range(nx):
for j in range(ny):
# treat xv[j, i], yv[j, i]

xv, yv = meshgrid(x, y, indexing='ij')
for i in range(nx):
for j in range(ny):
# treat xv[i, j], yv[i, j]
```

(function-ones)=
### ones(shape, /, *, dtype=None, device=None)

Expand Down