Skip to content

Commit

Permalink
Merge pull request cupy#3570 from emcastillo/fix-percentile
Browse files Browse the repository at this point in the history
Fix `cupy.percentile` type assignment in `asarray`
  • Loading branch information
asi1024 authored Jul 8, 2020
2 parents 384487f + 4c64375 commit 989ef4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cupy/statistics/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ def percentile(a, q, axis=None, out=None, interpolation='linear',
.. seealso:: :func:`numpy.percentile`
"""
q = cupy.asarray(q, dtype=a.dtype)
if not isinstance(q, cupy.ndarray):
q = cupy.asarray(q, dtype='d')
if q.ndim == 0:
q = q[None]
zerod = True
Expand Down
8 changes: 8 additions & 0 deletions tests/cupy_tests/statics_tests/test_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ def test_percentile_defaults(self, xp, dtype, interpolation):
q = testing.shaped_random((3,), xp, dtype=dtype, scale=100)
return xp.percentile(a, q, interpolation=interpolation)

@for_all_interpolations()
@testing.for_all_dtypes(no_float16=True, no_bool=True, no_complex=True)
@testing.numpy_cupy_allclose()
def test_percentile_q_list(self, xp, dtype, interpolation):
a = testing.shaped_arange((1001,), xp, dtype)
q = [99, 99.9]
return xp.percentile(a, q, interpolation=interpolation)

@for_all_interpolations()
@testing.for_all_dtypes(no_float16=True, no_bool=True, no_complex=True)
@testing.numpy_cupy_allclose(rtol=1e-6)
Expand Down

0 comments on commit 989ef4c

Please sign in to comment.