summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
Commit message (Collapse)AuthorAgeFilesLines
* MAINT: Reorganize the way windowing functions ensure float64 resultSebastian Berg2023-05-031-10/+38
| | | | | | | | | | | | | | | | | | | This roughly changes things so that we ensure a float64 working values up-front. There is a tiny chance of precision changes if the input was not float64 or error changes on bad input. I don't think this should matter in practice, precision changes (as far as I can tell) should happen rather the other way around. Since float64 has 53bits mantissa, I think the arange should give the correct result reliably for any sensible inputs. There is an argument to be made that the windowing functions could return float32 for float32 input, but I somewhat think this is OK and users can be expected to just cast manually after the fact. The result type is tested, but this ensures the tests pass also when enabling weak promotion.
* Merge pull request #23529 from lorentzenchr/doc_quantileSebastian Berg2023-04-281-6/+6
|\ | | | | DOC: quantile parameter q is a probability
| * DOC use percentage for q in percentileChristian Lorentzen2023-04-261-2/+2
| |
| * DOC quantile q is a probabilityChristian Lorentzen2023-04-041-4/+4
| |
* | Fixed failing testsMatteo Raso2023-04-011-12/+28
| |
* | Fixed edge case where pyfunc has no attribute `__doc__`Matteo Raso2023-04-011-1/+1
| | | | | | | | [skip circle] [skip azp] [skip cirrus]
* | Fixed edge case where pyfunc has no attribute `__name__`Matteo Raso2023-04-011-39/+66
| |
* | Revert "ENH: Enabled the use of numpy.vectorize as a decorator"Matti Picus2023-03-271-54/+11
| |
* | Merge pull request #23061 from MatteoRaso/vectorizeMatti Picus2023-03-261-11/+54
|\ \ | | | | | | ENH: Enabled the use of numpy.vectorize as a decorator
| * | @vectorize now requires arguments to specify keywordsMatteo Raso2023-02-091-17/+6
| | | | | | | | | | | | This reverses commit 7a2ded1522305
| * | Added a test for positional args (PR-23061)Matteo Raso2023-02-081-0/+19
| | |
| * | Changed documentation for numpy.vectorizeMatteo Raso2023-01-241-1/+1
| | | | | | | | | | | | | | | Previous definition implies that vectorize returns generalized functions, which is not true.
| * | Fixed lint errorMatteo Raso2023-01-211-1/+1
| | |
| * | ENH: Enabled use of numpy.vectorize as decorator (#9477)Matteo Raso2023-01-211-12/+46
| | | | | | | | | | | | | | | | | | | | | | | | Most of this code comes from PR-9593, but with the default value for pyfunc being numpy._NoValue instead of None, no override of __new__, and no effort to make subclassing possible. Co-Authored-By: Michael Lamparski <diagonaldevice@gmail.com>
| * | BUG: Added __name__ atribute to vectorize class (#23021)Matteo Raso2023-01-181-0/+1
| | |
* | | 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
|/