Skip to content

Commit 6764c51

Browse files
authored
Merge 2ebda89 into 44bb068
2 parents 44bb068 + 2ebda89 commit 6764c51

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

dpnp/dpnp_array.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,12 @@ def __and__(self, other):
192192
"""Return ``self&value``."""
193193
return dpnp.bitwise_and(self, other)
194194

195-
# '__array__',
195+
def __array__(self, dtype=None, /, *, copy=None):
196+
raise TypeError(
197+
"Implicit conversion to a NumPy array is not allowed. "
198+
"Please use `.asnumpy()` to construct a NumPy array explicitly."
199+
)
200+
196201
# '__array_finalize__',
197202
# '__array_function__',
198203
# '__array_interface__',

dpnp/tests/third_party/cupy/core_tests/test_ndarray.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,6 @@ def test_format(self, xp):
691691
return format(x, ".2f")
692692

693693

694-
@pytest.mark.skip("implicit conversation to numpy does not raise an exception")
695694
class TestNdarrayImplicitConversion(unittest.TestCase):
696695

697696
def test_array(self):

dpnp/tests/third_party/cupy/random_tests/test_sample.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def test_goodness_of_fit(self):
9797
@_condition.repeat(3, 10)
9898
def test_goodness_of_fit_2(self):
9999
mx = 5
100-
vals = random.randint(mx, size=(5, 20))
100+
vals = random.randint(mx, size=(5, 20)).asnumpy()
101101
counts = numpy.histogram(vals, bins=numpy.arange(mx + 1))[0]
102102
expected = numpy.array([float(vals.size) / mx] * mx)
103103
assert _hypothesis.chi_square_test(counts, expected)
@@ -199,7 +199,7 @@ def test_goodness_of_fit(self):
199199
@_condition.repeat(3, 10)
200200
def test_goodness_of_fit_2(self):
201201
mx = 5
202-
vals = random.randint(0, mx, (5, 20))
202+
vals = random.randint(0, mx, (5, 20)).asnumpy()
203203
counts = numpy.histogram(vals, bins=numpy.arange(mx + 1))[0]
204204
expected = numpy.array([float(vals.size) / mx] * mx)
205205
assert _hypothesis.chi_square_test(counts, expected)

0 commit comments

Comments
 (0)