Skip to content

Commit

Permalink
Merge pull request #1080 from IntelPython/fix_meshgrid_empty
Browse files Browse the repository at this point in the history
Fixed meshgrid() function with empty input.
  • Loading branch information
npolina4 authored Feb 22, 2023
2 parents eadc0bd + 2fb6b6c commit bdeb37d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dpctl/tensor/_ctors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,9 @@ def meshgrid(*arrays, indexing="xy"):
"Unrecognized indexing keyword value, expecting 'xy' or 'ij.'"
)
n = len(arrays)
if n == 0:
return []

sh = (-1,) + (1,) * (n - 1)

res = []
Expand Down
1 change: 1 addition & 0 deletions dpctl/tests/test_usm_ndarray_ctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,7 @@ def test_meshgrid():
assert n == len(Znp)
for i in range(n):
assert np.array_equal(dpt.asnumpy(Z[i]), Znp[i])
assert dpt.meshgrid() == []
# dimension > 1 must raise ValueError
with pytest.raises(ValueError):
dpt.meshgrid(dpt.usm_ndarray((4, 4)))
Expand Down

0 comments on commit bdeb37d

Please sign in to comment.