Skip to content

Commit 360f15a

Browse files
committed
improve coverage
1 parent 8fcd587 commit 360f15a

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

tests/test_manipulation.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def test_order(self, order):
157157

158158
@pytest.mark.parametrize(
159159
"obj",
160-
[numpy.array([2]), dpnp.array([0, 2])],
160+
[numpy.array([2]), dpnp.array([0, 2]), dpnp.asarray([1])],
161161
)
162162
@pytest.mark.parametrize(
163163
"values",
@@ -192,7 +192,7 @@ def test_1D_array(self):
192192
assert_equal(dpnp.insert(ia, 0, 1), numpy.insert(a, 0, 1))
193193
assert_equal(dpnp.insert(ia, 3, 1), numpy.insert(a, 3, 1))
194194
assert_equal(
195-
dpnp.insert(ia, 1, [1, 2, 3]), numpy.insert(a, 1, [1, 2, 3])
195+
dpnp.insert(ia, -1, [1, 2, 3]), numpy.insert(a, -1, [1, 2, 3])
196196
)
197197
assert_equal(
198198
dpnp.insert(ia, [1, -1, 3], 9), numpy.insert(a, [1, -1, 3], 9)
@@ -273,26 +273,32 @@ def test_ND_array(self):
273273
assert_raises(AxisError, dpnp.insert, ia, 1, ia[:, 2, :], axis=3)
274274
assert_raises(AxisError, dpnp.insert, ia, 1, ia[:, 2, :], axis=-4)
275275

276-
def test_0d(self):
277-
a = dpnp.array(1)
278-
with pytest.raises(AxisError):
279-
dpnp.insert(a, [], 2, axis=0)
280-
with pytest.raises(TypeError):
281-
dpnp.insert(a, [], 2, axis="nonsense")
282-
283276
def test_index_array_copied(self):
284277
a = dpnp.array([0, 1, 2])
285278
x = dpnp.array([1, 1, 1])
286279
dpnp.insert(a, x, [3, 4, 5])
287280
assert_equal(x, dpnp.array([1, 1, 1]))
288281

289-
def test_index_floats(self):
282+
def test_error(self):
290283
a = dpnp.array([0, 1, 2])
284+
285+
# index float
291286
with pytest.raises(IndexError):
292287
dpnp.insert(a, dpnp.array([1.0, 2.0]), [10, 20])
293288
with pytest.raises(IndexError):
294289
dpnp.insert(a, dpnp.array([], dtype=dpnp.float32), [])
295290

291+
# index 2d
292+
with pytest.raises(ValueError):
293+
dpnp.insert(a, dpnp.array([[1.0], [2.0]]), [10, 20])
294+
295+
# incorrect axis
296+
a = dpnp.array(1)
297+
with pytest.raises(AxisError):
298+
dpnp.insert(a, [], 2, axis=0)
299+
with pytest.raises(TypeError):
300+
dpnp.insert(a, [], 2, axis="nonsense")
301+
296302
@pytest.mark.parametrize("idx", [4, -4])
297303
def test_index_out_of_bounds(self, idx):
298304
a = dpnp.array([0, 1, 2])

0 commit comments

Comments
 (0)