diff options
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/function_base.py | 5 | ||||
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 10 |
2 files changed, 13 insertions, 2 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 9475c2edf..472d7eecc 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -2803,8 +2803,9 @@ def percentile(a, q, interpolation='linear', axis=None, out=None, the contents of the input array. In this case you should not make any assumptions about the content of the passed in array `a` after this function completes -- treat it as undefined. Default is False. - Note that, if `overwrite_input` is True and the input is not - already an array, an error will be raised. + Note that, if the `a` input is not already an array this parameter + will have no effect, `a` will be converted to an array internally + regardless of the value of this parameter. Returns ------- diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index a69c82e18..dd0b6e0ee 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1530,9 +1530,19 @@ class TestScoreatpercentile(TestCase): np.percentile(a, [50], overwrite_input=False) assert_equal(a, np.array([2, 3, 4, 1])) + a = np.array([2, 3, 4, 1]) np.percentile(a, [50]) assert_equal(a, np.array([2, 3, 4, 1])) + def test_percentile_overwrite(self): + a = np.array([2, 3, 4, 1]) + b = np.percentile(a, [50], overwrite_input=True) + assert_equal(b, np.array([2.5])) + + b = np.percentile([2, 3, 4, 1], [50], overwrite_input=True) + assert_equal(b, np.array([2.5])) + + class TestMedian(TestCase): def test_basic(self): |