summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
Commit message (Collapse)AuthorAgeFilesLines
* Fix the interpolation formulae which led to absurd results. For quantile() ↵deego2022-07-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | and percentile(). Fix the interpolation formulae in the docs which led to absurd results. For quantile() and percentile(). Example, for median of a = [1,2,10,11], you expect to obtain i+g=2.5 for method = linear (or weibull, or hazen, or median_unbiased or normal_unbiased). Instead, you obtain a /negative/ index. The correted formula is: i + g = q * (n - alpha - beta + 1 ) + alpha Notice among other things that n belongs in the numerator, not the denominator! As a check, the corrected formula does lead to the correct index 2.5 for each of the cases above. MYSTERY: Surely the original formula was the result of a small typo/thinko? Then, why does the correction look so completely different? RESOLUTION OF MYSTERY: Take our formula, massage it, and swap q with (i+g), and you end up with the original formula. In other words, the original author of the doc. simply confused their percentile with their index halfway through the creation of the doc. Then, they massaged it to isolate (i+g) on the left.
* BUG: Reject non integer array-likes with size 1 in delete (#21857)Sebastian Berg2022-06-281-2/+6
| | | | | | | | Non integer array-likes were not correctly rejected when a new fast-path was added to `np.delete` in gh-16895. This includes the _explicitly_ added `dtype=object` which should not be allowed since it is not allowed in normal indexing either. Closes gh-21840
* BUG: Use `keepdims` during normalization in `np.average` and `np.ma.average` ↵Srimukh Sripada2022-06-261-1/+1
| | | | | | | | | (#21851) The keepdims flag needs to be applied during the calculation of the sum of the weights in np.average and np.ma.average. Not passing it causes weights to broadcast incorrectly. Fixes #21850
* DOC: Update numpy/lib/function_base.pySebastian Berg2022-05-191-1/+1
| | | Co-authored-by: Robert Kern <robert.kern@gmail.com>
* DOC: improve the docstring of numpy.sinc to explain behavior at zero.Jesús Carrete Montaña2022-05-191-4/+4
| | | | | | | | | | | | | | | The first lines of the sinc docstring did not mention the behavior when the argument is zero, and gave the impression that the function is defined as the quotient between a sine and its argument everywhere. That information was instead relegated to the "Notes" section. I found this issue while navigating the documentation for jax.numpy.sinc, which inherits those few lines. I think it is important to document not only the value of the function at zero, but also that it make sinc a smooth function. This connects better with some of the other routes used to introduce sinc (e.g. as a Taylor series). I have tried to implement the conclusions of the discussion around Issue #21538, keeping the description close to the actual implementation and avoiding my original suggestion of introducing the function as a limit.
* ENH: Add 'keepdims' to 'average()' and 'ma.average()'.warren2022-05-091-5/+29
|
* Merge pull request #21291 from oscargus/spaceandcosCharles Harris2022-04-071-24/+23
|\ | | | | DOC: Add space after argument name
| * STY: Whitespace fixes.Charles Harris2022-04-071-3/+3
| |
| * Add space after argument nameOscar Gustafsson2022-04-031-24/+23
| |
* | Improve documentation formattingOscar Gustafsson2022-04-031-2/+20
|/
* Merge pull request #16895 from DevinShanahan/delete-speedupMatti Picus2022-02-271-5/+12
|\ | | | | MAINT: extend delete single value optimization
| * MAINT: single value identification and testDevin Shanahan2022-01-161-3/+2
| |
| * MAINT: Merge branch 'main' into delete-speedupDevin Shanahan2022-01-161-289/+1014
| |\
| * | Update numpy/lib/function_base.pyDevin Shanahan2020-07-191-1/+1
| | | | | | | | | Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
| * | ENH: extend delete single value optimizationDevinShanahan2020-07-181-5/+13
| | | | | | | | | | | | | | | Allow arrays of shape (1,) for delete's obj parameter to utilize the optimization for a single value. See #16685.
* | | DOC: Fix spelling and grammar in documentation for quantile(). (#21068)Don Kirkby2022-02-151-12/+12
| | |
* | | MAINT: Add missing word to warning messageSadie Louise Bartholomew2022-02-071-1/+1
| | |
* | | DOC: Fix typo in meshgrid exampleEmma Simon2022-01-181-1/+1
| |/ |/| | | | | | | coordinate was misspelled in a comment in the example code [ci skip]
* | MAINT, DOC: discard repeated wordsDimitri Papadopoulos2022-01-131-2/+2
| |
* | DOC: Fixups for interpolation rename comments from reviewSebastian Berg2021-11-151-1/+1
| | | | | | | | Co-authored-by: Charles Harris <charlesr.harris@gmail.com>
* | DOC: Update percentile/quantile docsSebastian Berg2021-11-121-30/+30
| | | | | | | | | | | | | | Mainly fixes the method list slightly, tones down the warning a bit and fixes the link to the paper (I did not realize that the link failed to work due only because the reference was missing from nanquantile/nanpercentile).
* | DOC: Add ticks to quantile interpolation/method errorSebastian Berg2021-11-121-1/+1
| | | | | | | | Co-authored-by: abel <aoun@cerfacs.fr>
* | DOC: Remove reference to paper from quantile `method` kwargSebastian Berg2021-11-121-2/+2
| | | | | | | | | | Apparently, sphinx does not resolve references to footnotes from parameter descriptions.
* | DOC: Fixup the percentile methods plotSebastian Berg2021-11-121-12/+19
| |
* | BUG: quantile discrete methods ended up using -1 as index sometimesSebastian Berg2021-11-121-6/+9
| | | | | | | | | | Also, the closest-observation did not correctly support multiple quantiles calculated at the same time (broadcasting error).
* | API,DEP: Rename percentile/quantile `interpolation=` to `method=`Sebastian Berg2021-11-121-73/+110
| |
* | MTH: Update quantile default lerp methodabel2021-11-091-5/+7
| | | | | | | | | | | | For method 7 of H&F, using `(n - 1) * quantiles` instead of the usual method gives a more accurate result.
* | DOC: Remove non-existent aliasabel2021-11-081-8/+6
| |
* | PERF: Speedup np.quantile.Antony Lee2021-11-051-1/+2
| | | | | | | | | | | | Avoiding the unnecessary calls to moveaxis() speed up `np.quantile(x, .5)` (`x = np.random.rand(1000)`) by ~10% (although there's a lot of variability) for me.
* | DOC: Refer to the quantile/percentile notes for nan versionsSebastian Berg2021-11-041-1/+1
| |
* | MAINT: Clean following PR commentsabel2021-11-041-6/+3
| |
* | Fix issue with nan scalarabel2021-11-041-2/+2
| | | | | | | | Also added unit test for it.
* | DOC: Improve quantile documentationabel2021-11-041-20/+67
| | | | | | | | Also removed unused imports
* | Fix _lerpabel2021-11-041-23/+19
| | | | | | | | | | - some changes were unrelated to the PR and have been reverted, including, renaming and moving the logic around. - Also renamed _quantile_ureduce_func to its original name
* | DOC: fix docstrings.Charles Harris2021-11-041-169/+255
| | | | | | | | | | Hopefully fix the docstrings of percentile, nanpercentile, quantile, and nanquantile so that CircleCI passes.
* | MAINT, ENH [#10736] Add interpolation methods to quantileabel2021-11-041-124/+469
| | | | | | | | | | | | | | | | | | | | - Added the missing linear interpolation methods. - Updated the existing unit tests. - Added pytest.mark.xfail for boolean arrays See - https://github.com/numpy/numpy/pull/19857#issuecomment-919258693 - https://github.com/numpy/numpy/issues/19154
* | Merge remote-tracking branch 'upstream/main' into better-select-exampleJonas Liechti2021-10-251-13/+36
|\ \
| * | BUG: lib: Fix error raised by insert.warren2021-10-201-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When `insert` is given a single out-of-bounds index in a list, e.g. np.insert([0, 1, 2], [99], [3, 4]) # 99 is out of bounds a TypeError was being raised because of a bug in the formatting of the message. Before this change, the error is TypeError: %i format: a number is required, not list After, we get the expected IndexError: index [99] is out of bounds for axis 0 with size 3
| * | Add note to iterable docstring about 0d arrays.Ross Barnowski2021-10-151-0/+13
| | | | | | | | | | | | Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
| * | Merge pull request #20059 from DimitriPapadopoulos/lgtm_recommendationsCharles Harris2021-10-101-1/+1
| |\ \ | | | | | | | | MAINT: LGTM.com recommendations
| | * | MAINT: LGTM.com recommendation: Unused importDimitri Papadopoulos2021-10-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Import of 'histogram' is not used. Import of 'histogramdd' is not used. Import of 'textwrap' is not used.
| * | | added-suggestion-to#20047Sista Seetaram2021-10-061-1/+4
| | | |
| * | | DOC:add an example to show flag writeable cleared upon copySista Seetaram2021-10-061-0/+8
| |/ /
| * | STY: Directly use a float rather than the `float64` constructorBas van Beek2021-10-041-1/+1
| | |
| * | BUG: Fix the `lib.function_base` window functions ignoring extended ↵Bas van Beek2021-09-301-9/+9
| | | | | | | | | | | | precision float dtypes
* | | incorporated suggested editJonas I. Liechti2021-10-241-1/+0
| | | | | | | | | Co-authored-by: Mukulika <60316606+Mukulikaa@users.noreply.github.com>
* | | removed redundant commentJonas Liechti2021-10-221-3/+0
| | |
* | | type-o: used element instead of arrayJonas Liechti2021-10-051-3/+3
| | |
* | | adding example: also highlight priority in multiple matchesJonas Liechti2021-10-051-2/+11
| | |
* | | use an example that also shows default valueJonas Liechti2021-10-011-3/+3
|/ /