Prevent builtins.any from being shadowed in dask.array.reductions#11988
Prevent builtins.any from being shadowed in dask.array.reductions#11988jrbourbeau merged 5 commits intodask:mainfrom
builtins.any from being shadowed in dask.array.reductions#11988Conversation
TomAugspurger
left a comment
There was a problem hiding this comment.
Thanks @m-albert. A request for one more test and then I think we're good.
Unit Test ResultsSee test report for an extended history of previous test failures. This is useful for diagnosing flaky tests. 9 files ± 0 9 suites ±0 3h 19m 28s ⏱️ + 3m 28s Results for commit 44a467c. ± Comparison against base commit c37e613. ♻️ This comment has been updated with latest results. |
…sting which behaves differently.
|
Thanks for reviewing @TomAugspurger and good catch! I added the test you suggested and needed to take out While doing this I found the following: import dask.array as da
import numpy as np
x_np = np.ones(3)
x_da = da.from_array(x_np)
np_percentile_result = np.percentile(x_np, 50) # np.array(1.)
np_nanpercentile_result = np.nanpercentile(x_np, 50) # np.array(1.)
da_percentile_result = da.percentile(x_da, 50).compute() # np.array(1.)
da_nanpercentile_result = da.nanpercentile(x_da, 50).compute() # np.array([1.])
# ok
assert np_percentile_result.shape == np_nanpercentile_result.shape
# ok
assert np_percentile_result.shape == da_nanpercentile_result.shape
# fails
assert np_percentile_result.shape == da.percentile_result.shapeI.e. |
jrbourbeau
left a comment
There was a problem hiding this comment.
Thanks for the fix @m-albert and for reviewing @TomAugspurger
Also @m-albert I noticed this is your first code contribution to this repository. Welcome!
builtins.any from being shadowed in dask.array.reductions
|
Thanks @jrbourbeau ! |
Fixes #11986.
As @TomAugspurger commented, the shadowing of
builtins.anyindask.array.reductionsleads to an error when callingda.quantileda.percentileda.nanquantileda.nanpercentiletogether with
..., axis=None.This PR explicitly calls
builtins.anywhere required and adds a minimal test checking that the functions above yield aNotImplementedErrorin the case of axis=None.pre-commit run --all-files