Skip to content

Commit bdeb37d

Browse files
authored
Merge pull request #1080 from IntelPython/fix_meshgrid_empty
Fixed meshgrid() function with empty input.
2 parents eadc0bd + 2fb6b6c commit bdeb37d

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

dpctl/tensor/_ctors.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,9 @@ def meshgrid(*arrays, indexing="xy"):
13751375
"Unrecognized indexing keyword value, expecting 'xy' or 'ij.'"
13761376
)
13771377
n = len(arrays)
1378+
if n == 0:
1379+
return []
1380+
13781381
sh = (-1,) + (1,) * (n - 1)
13791382

13801383
res = []

dpctl/tests/test_usm_ndarray_ctor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,7 @@ def test_meshgrid():
17351735
assert n == len(Znp)
17361736
for i in range(n):
17371737
assert np.array_equal(dpt.asnumpy(Z[i]), Znp[i])
1738+
assert dpt.meshgrid() == []
17381739
# dimension > 1 must raise ValueError
17391740
with pytest.raises(ValueError):
17401741
dpt.meshgrid(dpt.usm_ndarray((4, 4)))

0 commit comments

Comments
 (0)