8000 BUG: Fixed previous attempt to fix dimension mismatch in nanpercentile by madphysicist · Pull Request #7180 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fixed previous attempt to fix dimension mismatch in nanpercentile #7180

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

Merged
merged 1 commit into from
Feb 5, 2016
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
3 changes: 2 additions & 1 deletion numpy/lib/nanfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,8 @@ def _nanpercentile(a, q, axis=None, out=None, overwrite_input=False,
# Move that axis to the beginning to match percentile's
# convention.
if q.ndim != 0:
result = np.swapaxes(result, 0, axis)
result = np.rollaxis(result, axis)

if out is not None:
out[...] = result
return result
Expand Down
5 changes: 4 additions & 1 deletion numpy/lib/tests/test_nanfunctions.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ def test_multiple_percentiles(self):
# For checking consistency in higher dimensional case
large_mat = np.ones((3, 4, 5))
large_mat[:, 0:2:4, :] = 0
large_mat[:, :, 3:] = 2*large_mat[:, :, 3:]
large_mat[:, :, 3:] *= 2
for axis in [None, 0, 1]:
for keepdim in [False, True]:
with warnings.catch_warnings(record=True) as w:
Expand All @@ -727,6 +727,9 @@ def test_multiple_percentiles(self):
keepdims=keepdim)
assert_equal(nan_val, val)

megamat = np.ones((3, 4, 5, 6))
assert_equal(np.nanpercentile(megamat, perc, axis=(1, 2)).shape, (2, 3, 6))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result before change was (2, 6, 3).



if __name__ == "__main__":
run_module_suite()
0