Skip to content

Commit 183462f

Browse files
author
Vahid Tavanashad
committed
update to fix issue for 0-d arrays
1 parent da9b949 commit 183462f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

dpnp/dpnp_iface_arraycreation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ def array(
421421
return result
422422

423423
num_axes = ndmin - res_ndim
424-
return result[(dpnp.newaxis,) * num_axes + (slice(None),)]
424+
new_shape = (1,) * num_axes + result.shape
425+
return result.reshape(new_shape)
425426

426427

427428
def asanyarray(

tests/test_arraycreation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525
class TestArray:
2626
@pytest.mark.parametrize(
27-
"x", [numpy.ones((3, 4)), numpy.ones((0, 4)), [1, 2, 3], []]
27+
"x",
28+
[numpy.ones(5), numpy.ones((3, 4)), numpy.ones((0, 4)), [1, 2, 3], []],
2829
)
2930
@pytest.mark.parametrize("ndmin", [-5, -1, 0, 1, 2, 3, 4, 9, 21])
3031
def test_ndmin(self, x, ndmin):

0 commit comments

Comments
 (0)