summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
Commit message (Collapse)AuthorAgeFilesLines
* MAINT: remove `NUMPY_EXPERIMENTAL_ARRAY_FUNCTION` env varRalf Gommers2023-03-121-17/+16
| | | | | | | | As discussed in https://mail.python.org/archives/list/numpy-discussion@python.org/thread/UKZJACAP5FUG7KP2AQDPE4P5ADNWLOHZ/ This flag was always meant to be temporary, and cleaning it up is long overdue.
* DOC: Fixed meshgrid docstring return type (#23310)Miki Watanabe2023-03-011-2/+2
| | | | | Meshgrid returns a list of ndarrays. Co-authored-by: 渡邉 美希 <miki.watanabe@watanabenoMacBook-Pro.local>
* MAINT: Use `np._using_numpy2_behavior()` and initialize it in CSebastian Berg2023-02-101-1/+1
|
* API: Modify `gradient` to return a tuple rather than a listSebastian Berg2023-02-101-0/+2
| | | | | This change is staged for NumPy 2.0, I assume we could get away with it otherwise, but it is a nice example and probably not pressing.
* ENH: Convert methods to vectorcall conversions (#23018)Pieter Eendebak2023-01-231-6/+2
| | | | | | | | | | | | Convert several methods to the vectorcall convention. The conversions give a performance improvement, see #20790 (comment) Some notes: * For vdot the METH_KEYWORDS was removed, as the C vdot method was positional only. * The add_docstring is converted with an additional check. It was parsed as if (!PyArg_ParseTuple(args, "OO!:add_docstring", &obj, &PyUnicode_Type, &str)), but there is no support for the ! in the npy_parse_arguments * CI was complaining about coverage of _get_ndarray_c_version. A test was added, but only to provide coverage * In function_base.py a redundant check in def place was removed Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* API: Allow SciPy to get away with assuming `trapz` is a Python functionSebastian Berg2023-01-201-0/+19
| | | | | | | | | This wraps `trapz` into a proper python function and then copies all attributes expected on a Python function over from the "fake" version to the real one. This allows SciPy to pretend `trapz` is a Python function to create their own version.
* MAINT: Fix stacklevels for the new C dispatcher not adding oneSebastian Berg2023-01-171-4/+4
|
* DOC: Add blurb about rotation direction to rot90 docstring (#22880)Matthew Muresan2022-12-291-0/+2
| | | | | | | * DOC: Add a note to the documentation of the rot90 The note added indicates that rotation is counter clockwise with the default argumemnts. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* DOC: Fix legend placement in `percentile` docsEero Vaher2022-12-121-1/+2
| | | | | | | A plot is meant to demonstrate the different methods of estimating the percentile that `numpy.percentile()` supports, but previously the legend covered a large fraction of it. Now the legend is drawn next to the plot.
* DOC: add numerical integration of x^2 to trapz (#22681)Manuchehr Aminian2022-12-081-7/+23
| | | | | | | | Examples in documentation for trapz goes straight from integrating random arrays to parametric curves. I think it's worth pointing out one can integrate something they'd see in Calculus 1 and get the answer they'd expect. Also add some more guidance text to the existing examples (and style fixes) Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net> Co-authored-by: Melissa Weber Mendonça <melissawm@gmail.com>
* BUG: Quantile function on complex number now throws an error (#22652) (#22703)Matteo Raso2022-12-081-2/+11
| | | | | | | | | | | | | | | | | Since percentile is more or less identical to quantile, I also made it throw an error if it receives a complex input. I also made nanquantile and nanpercentile throw errors as well. * Made the changes recommended by seberg * Fixed a test for PR 22703 * Fixed tests for quantile * Shortened some more lines * Fixup more lines Co-authored-by: Sebastian Berg <sebastianb@nvidia.com>
* BUG: `keepdims=True` is ignored if `out` is not `None` in `numpy.median()`, ↵Roy Smart2022-12-051-18/+33
| | | | | | `numpy.percentile()`, and `numpy.quantile()`. Closes #22714, #22544.
* MAINT: Move set_module to numpy.core to use without C importSebastian Berg2022-11-241-3/+3
|
* Merge pull request #22375 from melissawm/doc-arangeMatti Picus2022-11-081-5/+14
|\ | | | | DOC: How to partition domains
| * DOC: Improve how-to-partition contents.melissawm2022-10-111-0/+1
| | | | | | | | Also add links to this document from the functions' docstrings.
| * DOC: How to partition domainsmelissawm2022-10-031-5/+13
| |
* | DOC: Update numpy/lib/function_base.py Ross Barnowski2022-10-201-0/+1
| | | | | | | | | | Add date to deprecation in comment Co-authored-by: Matti Picus <matti.picus@gmail.com>
* | DEP: Add deprecation warning and check warning in test.Ross Barnowski2022-10-191-0/+5
| |
* | DOC: Add deprecated directive to docstring.Ross Barnowski2022-10-191-0/+4
|/
* DOC: fixed minor typo in percentile docstringGaëtan de Menten2022-09-281-1/+1
|
* STY: minor formatting touchups.Ross Barnowski2022-09-161-3/+2
|
* DOC: Add examples to msort in lib/function_base.pyShreya2022-09-161-0/+8
|
* Merge pull request #22009 from eendebakpt/fix/averageSebastian Berg2022-09-031-4/+5
|\ | | | | BUG: fix np.average for Fraction elements
| * BUG: fix np.average for Fraction elementsPieter Eendebak2022-08-101-4/+5
| |
* | DOC: Fix documentation for percentile and quantilemelissawm2022-08-121-22/+35
|/ | | | Co-authored-by: deego <deego3@gmail.com>
* 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).