diff options
author | Joseph Fox-Rabinovitz <joseph.r.fox-rabinovitz@nasa.gov> | 2016-02-18 14:12:17 -0500 |
---|---|---|
committer | Joseph Fox-Rabinovitz <jfoxrabinovitz@gmail.com> | 2016-02-22 21:44:54 -0500 |
commit | c5e01fa725e5e7c1993b7eec401fa31be8580420 (patch) | |
tree | 2fefc699e8030078ffb7bc2d43a8442d242e04e2 /numpy/lib/tests/test_function_base.py | |
parent | e5c1ac175722bc58e74aac4e6d9138adf9260ec6 (diff) | |
download | numpy-c5e01fa725e5e7c1993b7eec401fa31be8580420.tar.gz |
TST: Fixed shuffle axis in tests.
Since shuffle only works along the first dimension, it must be done before
reshape to get reasonable looking data. Did not affect the current tests. I
noticed while working on some scipy code.
Also, made a couple of doc changes to np.random.shuffle.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 10 |
1 files changed, 5 insertions, 5 deletions
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], |