Skip to content

Commit a1a9b14

Browse files
Check dtype support of each array in resulting tuple in call_origin (#1457)
* Check dtype support of each array in resulting tuple in call_origin * Use dpnp.linspace in test_histograms
1 parent f2a4abc commit a1a9b14

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

dpnp/dpnp_utils/dpnp_algo_utils.pyx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,11 @@ def call_origin(function, *args, **kwargs):
201201
for res_origin in result:
202202
res = res_origin
203203
if isinstance(res_origin, numpy.ndarray):
204-
res = dpnp_container.empty(res_origin.shape, dtype=res_origin.dtype, sycl_queue=exec_q)
204+
if exec_q is not None:
205+
result_dtype = map_dtype_to_device(res_origin.dtype, exec_q.sycl_device)
206+
else:
207+
result_dtype = res_origin.d_type
208+
res = dpnp_container.empty(res_origin.shape, dtype=result_dtype, sycl_queue=exec_q)
205209
copy_from_origin(res, res_origin)
206210
result_list.append(res)
207211

tests/test_histograms.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ def teardown(self):
1515
def test_simple(self):
1616
n = 100
1717
v = dpnp.random.rand(n)
18-
(a, b) = dpnp.histogram(v)
18+
a, _ = dpnp.histogram(v)
1919
# check if the sum of the bins equals the number of samples
2020
numpy.testing.assert_equal(dpnp.sum(a, axis=0), n)
2121
# check that the bin counts are evenly spaced when the data is from
2222
# a linear function
23-
(a, b) = dpnp.histogram(numpy.linspace(0, 10, 100))
23+
a, _ = dpnp.histogram(dpnp.linspace(0, 10, 100))
2424
numpy.testing.assert_array_equal(a, 10)
2525

2626
@pytest.mark.usefixtures("allow_fall_back_on_numpy")
@@ -67,7 +67,7 @@ def test_density(self):
6767

6868
# Taken from a bug report from N. Becker on the numpy-discussion
6969
# mailing list Aug. 6, 2010.
70-
counts, dmy = dpnp.histogram(
70+
counts, _ = dpnp.histogram(
7171
[1, 2, 3, 4], [0.5, 1.5, numpy.inf], density=True
7272
)
7373
numpy.testing.assert_equal(counts, [0.25, 0])

0 commit comments

Comments
 (0)