Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check dtype support of each array in resulting tuple in call_origin #1457

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion dpnp/dpnp_utils/dpnp_algo_utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ def call_origin(function, *args, **kwargs):
for res_origin in result:
res = res_origin
if isinstance(res_origin, numpy.ndarray):
res = dpnp_container.empty(res_origin.shape, dtype=res_origin.dtype, sycl_queue=exec_q)
if exec_q is not None:
result_dtype = map_dtype_to_device(res_origin.dtype, exec_q.sycl_device)
else:
result_dtype = res_origin.d_type
res = dpnp_container.empty(res_origin.shape, dtype=result_dtype, sycl_queue=exec_q)
copy_from_origin(res, res_origin)
result_list.append(res)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_histograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ def teardown(self):
def test_simple(self):
n = 100
v = dpnp.random.rand(n)
(a, b) = dpnp.histogram(v)
a, _ = dpnp.histogram(v)
# check if the sum of the bins equals the number of samples
numpy.testing.assert_equal(dpnp.sum(a, axis=0), n)
# check that the bin counts are evenly spaced when the data is from
# a linear function
(a, b) = dpnp.histogram(numpy.linspace(0, 10, 100))
a, _ = dpnp.histogram(dpnp.linspace(0, 10, 100))
numpy.testing.assert_array_equal(a, 10)

@pytest.mark.usefixtures("allow_fall_back_on_numpy")
Expand Down Expand Up @@ -67,7 +67,7 @@ def test_density(self):

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