summaryrefslogtreecommitdiff
path: root/numpy/lib
Commit message (Collapse)AuthorAgeFilesLines
...
| | * | | 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.
| | * | | Merge pull request #23019 from seberg/finalize-non-sequence-stackCharles Harris2023-01-172-6/+6
| | |\ \ \ | | | | | | | | | | | | DEP: Finalize the non-sequence stacking deprecation
| | | * | | DEP: Finalize the non-sequence stacking deprecationSebastian Berg2023-01-172-6/+6
| | | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `__array_function__` API currently will exhaust iterators so we cannot accept sequences reasonably. Checking for `__getitem__` is presumably enough to reject that (and was what the deprecation used). Future changes could allow this again, although it is not a useful API anyway, since we have to materialize the iterable in any case.
| | * | | MAINT: Fix stacklevels for the new C dispatcher not adding oneSebastian Berg2023-01-173-13/+13
| | | | |
| | * | | ENH: Improve array function overhead by using vectorcallSebastian Berg2023-01-172-44/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This moves dispatching for `__array_function__` into a C-wrapper. This helps speed for multiple reasons: * Avoids one additional dispatching function call to C * Avoids the use of `*args, **kwargs` which is slower. * For simple NumPy calls we can stay in the faster "vectorcall" world This speeds up things generally a little, but can speed things up a lot when keyword arguments are used on lightweight functions, for example:: np.can_cast(arr, dtype, casting="same_kind") is more than twice as fast with this. There is one alternative in principle to get best speed: We could inline the "relevant argument"/dispatcher extraction. That changes behavior in an acceptable but larger way (passes default arguments). Unless the C-entry point seems unwanted, this should be a decent step in the right direction even if we want to do that eventually, though. Closes gh-20790 Closes gh-18547 (although not quite sure why)
| | * | | DOC: #22266 Add examples for tril_indices_from(), triu_indices_from() (#22562)Richie Cotton2023-01-161-2/+69
| | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * DOC: #22266 Add examples for tri[lu]_indices_from() * DOC: see also for tri[lu]_indices_from() * DOC: Fix triu_indices_from example and minor updates. * incides -> indices * Update wording surrounding . Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
| | * | ENH: Faster numpy.load (try/except _filter_header) (#22916)Michael2023-01-132-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This pull requests speeds up numpy.load. Since _filter_header is quite a bottleneck, we only run it if we must. Users will get a warning if they have a legacy Numpy file so that they can save it again for faster loading. Main discussion and benchmarks see #22898 Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
| | * | ENH: Improve loadtxt error with dtype and non-matchinig column number (#22996)Sebastian Berg2023-01-111-1/+10
| | | | | | | | | | | | | | | | The number "changed" is weird if the user fixed it, so give a different message in that case.
| | * | BUG: np.loadtxt cannot load text file with quoted fields separated by ↵dmbelov2023-01-012-0/+22
| | |/ | | | | | | | | | | | | | | | | | | whitespace (#22906) Fix issue with `delimiter=None` and quote character not working properly (not using whitespace delimiter mode). Closes gh-22899
| | * 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>
| | * BUG: Fix integer overflow in in1d for mixed integer dtypes #22877 (#22878)Miles Cranmer2022-12-252-4/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * TST: Mixed integer types for in1d * BUG: Fix mixed dtype overflows for in1d (#22877) * BUG: Type conversion for integer overflow check * MAINT: Fix linting issues in in1d * MAINT: ar1 overflow check only for non-empty array * MAINT: Expand bounds of overflow check * TST: Fix integer overflow in mixed boolean test * TST: Include test for overflow on mixed dtypes * MAINT: Less conservative overflow checks
| | * Merge pull request #22869 from seberg/issue-22835Charles Harris2022-12-221-0/+2
| | |\ | | | | | | | | TST: Ignore nan-warnings in randomized nanfunction `out=` tests
| | | * TST: Ignore nan-warnings in randomized out testsSebastian Berg2022-12-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The tests randomize the nan pattern and thus can run into these (additional) warnings, so ignore them. (Could also fix the random seed, but this should do) Closes gh-22835
| | * | MAINT: expand show_rutime, add it to issue template [skip ci]mattip2022-12-211-31/+9
| | |/
| | * BUG: Ensure correct behavior for rows ending in delimiter in loadtxt (#22836)Sebastian Berg2022-12-191-0/+12
| | | | | | | | | | | | | | | | | | | | | If a row ends in a delimiter, `add_fields` can be called twice without any field actually being parsed. This causes issues with the field buffer setup. closes gh-22833
| | * Merge pull request #22784 from eerovaher/percentile-plot-legendSebastian Berg2022-12-151-1/+2
| | |\ | | | | | | | | DOC: Fix legend placement in `numpy.percentile()` docs
| | | * 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.
| | * | TST: Remove outdated xfail from quantile testsSebastian Berg2022-12-141-1/+0
| | |/ | | | | | | | | | There should be more tests for this, but this now passes.
| | * 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-084-15/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: fix unexpected return of np.pad with mode=wrap (#22575)LU2022-12-072-13/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | np.pad with mode="wrap" returns unexpected result that original data is not strictly looped in padding. This may happen in some occassions when padding widths in the same dimension are unbalanced (see added testcase in test_arraypad.py and the related issue). The reason is the function pad makes iterative calls of _set_wrap_both() in the above situation, yet period for padding is not correctly computed in each iteration. The bug is fixed by guaranteeing that period is always a multiple of original data size, and also be the possible maximum for computation efficiency. Closes #22464 Co-authored-by: Lars Grüter <lagru+github@mailbox.org>
| | * BUG: `keepdims=True` is ignored if `out` is not `None` in `numpy.median()`, ↵Roy Smart2022-12-054-28/+145
| | | | | | | | | | | | | | | | | | `numpy.percentile()`, and `numpy.quantile()`. Closes #22714, #22544.
| | * Merge pull request #22619 from seberg/move-set_moduleMatti Picus2022-11-296-8/+9
| | |\ | | | | | | | | MAINT: Move set_module from numpy.core to numpy._utils
| | | * MAINT: Move set_module to numpy.core to use without C importSebastian Berg2022-11-246-8/+9
| | | |
| | * | MAINT: lib: A bit of flake8-driven clean up in shape_base.pywarren2022-11-241-4/+4
| | | |
| | * | DOC: lib: Use keepdims in a couple docstrings.warren2022-11-241-7/+9
| | |/
| | * BUG: Histogramdd breaks on big arrays in Windows (#22561)Navpreet Singh2022-11-182-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * BUG: Histogramdd breaks on big arrays in Windows Resolved the issue with line change from int to np.intp in numpy/numpy/lib/histograms.py * BUG: Histogramdd breaks on big arrays in Windows Resolved the issue with line change from int to np.intp in numpy/numpy/lib/histograms.py * Removed the binary files * Update test_histograms.py * Update test_histograms.py * Update test_histograms.py
| | * BLD: update OpenBLAS to 0.3.21 and clean up openblas download test (#22525)Matti Picus2022-11-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * BUILD: update OpenBLAS to 0.3.21 and clean up openblas download test * set LDFLAGS on windows64 like the openblaslib build does * use rtools compilers on windows when building wheels * fix typos * add rtools gfortran to PATH * use the openblas dll from the zip archive without rewrapping * typos * copy dll import library for 64-bit interfaces * revert many of the changes to azure-steps-windows.yaml, copy openblas better in wheels * fix wildcard copy * test OpenBLAS build worked with threadpoolctl * typos * install threadpoolctl where needed, use for loop to recursively copy * update macos OpenBLAS suffixes for newer gfortran hashes * use libgfortran5.dylib on macos * fix scripts * re-use gfortran install from MacPython/gfortran-install on macos * use pre-release version of delocate * fixes for wheel builds/tests * add debugging cruft for pypy+win, macos wheels * add DYLD_LIBRARY_PATH on macosx-x86_64 * use 32-bit openblas interfaces for ppc64le tests * skip large_archive test that sometimes segfaults on PyPy+windows
| | * DOC: Update parameter descriptions for np.pad (#22519)Miki Watanabe2022-11-151-17/+18
| | | | | | | | | | | | | | | | | | | | | | | | Some parameters like pad_width or stat_length claimed to expect tuples-of-tuples as input, but in practice they also work with single tuples. The parameter descriptions of the relevant parameters are updated in the docstring to reflect this implicit tuple wrapping behavior. Co-authored-by: 渡邉 美希 <miki.watanabe@watanabenoMacBook-Pro.local>
| | * Merge pull request #21895 from hoodmane/emscripten-ciRalf Gommers2022-11-153-3/+9
| | |\ | | | | | | | | ENH, CI: Add Emscripten to CI
| | | * TST: Skip tests that are not currently supported in wasmHood Chatham2022-11-113-3/+9
| | | |
| | * | TYP,DEP: Remove `msort` annotationsBvB932022-11-141-6/+2
| | | | | | | | | | | | | | | | Xref https://github.com/numpy/numpy/pull/22456
| | * | TYP,ENH: Add annotations for `np.show_runtime`BvB932022-11-142-0/+3
| | |/ | | | | | | | | | Xref https://github.com/numpy/numpy/pull/21468
| * | DOC: Fix example spacing and move to end of docstring.Ross Barnowski2023-01-251-11/+11
| | |
| * | Add examples for diag_indices_from()Richie Cotton2022-11-081-0/+26
| |/
| * Merge pull request #22375 from melissawm/doc-arangeMatti Picus2022-11-082-5/+18
| |\ | | | | | | DOC: How to partition domains
| | * DOC: Improve how-to-partition contents.melissawm2022-10-112-0/+3
| | | | | | | | | | | | Also add links to this document from the functions' docstrings.
| | * DOC: How to partition domainsmelissawm2022-10-032-5/+15
| | |
* | | ENH: Ensure we will transition to an error for `np.r_[int8_arr, 300]`Sebastian Berg2022-11-081-2/+3
| | | | | | | | | | | | That is, once the NEP 50 transition happens
* | | MAINT: Refactor AxisConcatenator to not use find_common_typeSebastian Berg2022-11-071-15/+16
|/ / | | | | | | | | | | | | | | | | | | | | | | | | Rather, use `result_type` instead. There are some exceedingly small theoretical changes, since `result_type` currently uses value-inspection logic. `find_common_type` did not, because it pre-dates the value inspection logic. (I.e. in theory, this switches it to value-based promotion, just to partially undo that in NEP 50; although more changes there.) The only place where it is fathomable to matter is if someone is using `np.c_[uint8_arr, -1]` to append 255 to an unsigned integer array.
* | STY: Make linter happySebastian Berg2022-10-271-0/+1
| | | | | | | | Not new things, but in touched lines...
* | TST,MAINT: Replace most `setup` with `setup_method` (also teardown)Sebastian Berg2022-10-275-24/+24
| | | | | | | | | | | | | | | | In some cases, the replacement is clearly not what is intended, in those (where setup was called explicitly), I mostly renamed `setup` to `_setup`. The `test_ccompile_opt` is a bit confusing, so left it right now (this will probably fail)
* | MAINT: remove u-prefix for former Unicode strings (#22479)Mike Taves2022-10-263-17/+17
| |
* | 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-192-5/+11
| |
* | DOC: Add deprecated directive to docstring.Ross Barnowski2022-10-191-0/+4
| |
* | ENH: unstructured_to_structured converts dtype argument (#22442)LeonaTaric2022-10-192-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | Before: >>> field = unstructured_to_structured(np.zeros((20, 2)), dtype=[('x', float), ('y', float)]) # failed >>> field = unstructured_to_structured(np.zeros((20, 2)), dtype=np.dtype([('x', float), ('y', float)])) # success After: >>> field = unstructured_to_structured(np.zeros((20, 2)), dtype=[('x', float), ('y', float)]) # success >>> field = unstructured_to_structured(np.zeros((20, 2)), dtype=np.dtype([('x', float), ('y', float)])) # success Closes gh-22428
* | MAINT: Fix typos found by codespellDimitri Papadopoulos2022-10-071-1/+1
| |
* | Merge pull request #22393 from seberg/npy_headerMatti Picus2022-10-074-18/+126
|\ \ | | | | | | MAINT: Ensure graceful handling of large header sizes