summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Taylor <juliantaylor108@gmail.com>2016-02-23 21:51:44 +0100
committerJulian Taylor <juliantaylor108@gmail.com>2016-02-23 21:51:44 +0100
commitb3aa073c02c424ee67aed7c7e36b8bdb4e82a41f (patch)
tree05325f6d7dafdec7ebc224b21cd57c6de6b26cc3
parent4b78b9025f54a6818c5ed0b6c210f0b49516686d (diff)
parentc5e01fa725e5e7c1993b7eec401fa31be8580420 (diff)
downloadnumpy-b3aa073c02c424ee67aed7c7e36b8bdb4e82a41f.tar.gz
Merge pull request #7279 from madphysicist/percentile-tests
TST: Fixed elements being shuffled
-rw-r--r--numpy/lib/function_base.py2
-rw-r--r--numpy/lib/tests/test_function_base.py10
-rw-r--r--numpy/random/mtrand/mtrand.pyx7
3 files changed, 11 insertions, 8 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 7f80e424c..12fa4049b 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -3277,7 +3277,7 @@ def _ureduce(a, func, **kwargs):
a : array_like
Input array or object that can be converted to an array.
func : callable
- Reduction function Kapable of receiving an axis argument.
+ Reduction function capable of receiving a single axis argument.
It is is called with `a` as first argument followed by `kwargs`.
kwargs : keyword arguments
additional keyword arguments to pass to `func`.
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 782c1399a..235b7f2fe 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -2389,8 +2389,8 @@ class TestPercentile(TestCase):
assert_equal(np.percentile(x, [25, 60], axis=(0,)),
np.percentile(x, [25, 60], axis=0))
- d = np.arange(3 * 5 * 7 * 11).reshape(3, 5, 7, 11)
- np.random.shuffle(d)
+ d = np.arange(3 * 5 * 7 * 11).reshape((3, 5, 7, 11))
+ np.random.shuffle(d.ravel())
assert_equal(np.percentile(d, 25, axis=(0, 1, 2))[0],
np.percentile(d[:,:,:, 0].flatten(), 25))
assert_equal(np.percentile(d, [10, 90], axis=(0, 1, 3))[:, 1],
@@ -2617,7 +2617,7 @@ class TestMedian(TestCase):
[3, 4])
a4 = np.arange(3 * 4 * 5, dtype=np.float32).reshape((3, 4, 5))
- map(np.random.shuffle, a4)
+ np.random.shuffle(a4.ravel())
assert_allclose(np.median(a4, axis=None),
np.median(a4.copy(), axis=None, overwrite_input=True))
assert_allclose(np.median(a4, axis=0),
@@ -2765,8 +2765,8 @@ class TestMedian(TestCase):
assert_equal(np.median(x, axis=(0, )), np.median(x, axis=0))
assert_equal(np.median(x, axis=(-1, )), np.median(x, axis=-1))
- d = np.arange(3 * 5 * 7 * 11).reshape(3, 5, 7, 11)
- np.random.shuffle(d)
+ d = np.arange(3 * 5 * 7 * 11).reshape((3, 5, 7, 11))
+ np.random.shuffle(d.ravel())
assert_equal(np.median(d, axis=(0, 1, 2))[0],
np.median(d[:,:,:, 0].flatten()))
assert_equal(np.median(d, axis=(0, 1, 3))[1],
diff --git a/numpy/random/mtrand/mtrand.pyx b/numpy/random/mtrand/mtrand.pyx
index 964129a8c..db4ea13e6 100644
--- a/numpy/random/mtrand/mtrand.pyx
+++ b/numpy/random/mtrand/mtrand.pyx
@@ -5021,6 +5021,10 @@ cdef class RandomState:
Modify a sequence in-place by shuffling its contents.
+ This function only shuffles the array along the first axis of a
+ multi-dimensional array. The order of sub-arrays is changed but
+ their contents remains the same.
+
Parameters
----------
x : array_like
@@ -5037,8 +5041,7 @@ cdef class RandomState:
>>> arr
[1 7 5 2 9 4 3 6 0 8]
- This function only shuffles the array along the first index of a
- multi-dimensional array:
+ Multi-dimensional arrays are only shuffled along the first axis:
>>> arr = np.arange(9).reshape((3, 3))
>>> np.random.shuffle(arr)