summaryrefslogtreecommitdiff
path: root/numpy
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #18652 from timhoffm/doc-plotRalf Gommers2021-03-212-4/+7
|\ | | | | DOC: Update some plotting code to current Matplotlib idioms
| * DOC: Update some plotting code to current Matplotlib idiomsTim Hoffmann2021-03-212-4/+7
| | | | | | | | | | | | | | | | | | - 3D Axes are created via add_subplot(projection='3d') - There is now a `stairs()` function that's specifically designed for showing histogram curves - Labels should be passed as keyword arguments to the plot functions instead of to `legend()`, which reduces the risk of mixing them up. - ensure equal axis scaling in the meshgrid example
* | BLD: remove /usr/include from default include dirsRalf Gommers2021-03-211-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Including this directory is painful for cross-compiling, see gh-14980 and gh-13280. Removing this directory fixes the following build failure: ``` gcc: numpy/core/src/common/numpyos.c In file included from numpy/core/src/common/numpyos.c:23: /usr/include/xlocale.h:27:16: error: redefinition of ‘struct __locale_struct’ 27 | typedef struct __locale_struct ``` This error also shows up in various other build issues outside of the NumPy issue tracker. Compilers normally always include this path, so this shouldn't break anything. The default include paths for the compiler can be checked, e.g. for gcc with `cpp -v`. That will typically have /usr/include last. In case this breaks something for a nonstandard compiler, that can be worked around via a site.cfg file in the root of the repo (or equivalently, `~/numpy-site.cfg`) containing: ``` [DEFAULT] include_dirs = /usr/include ``` The same principle should apply to `/usr/lib`. I will make that change in a separate commit, because the failure mode for that will be different (and I'm not running into it right now).
* | Merge pull request #18579 from mwtoews/refactor-dictRalf Gommers2021-03-213-42/+15
|\ \ | | | | | | MAINT: OrderedDict is no longer necessary from Python 3.7
| * | MAINT: OrderedDict is no longer necessary from Python 3.7Mike Taves2021-03-083-42/+15
| | |
* | | Merge pull request #18593 from seberg/stop-lying-about-binop-inputsMatti Picus2021-03-217-54/+68
|\ \ \ | | | | | | | | MAINT: Do not claim input to binops is `self` (array object)
| * | | TST: Add minimal test for passing an out argument to arr.conjugate()Sebastian Berg2021-03-181-0/+9
| | | | | | | | | | | | | | | | | | | | This can currently only be passed positionally, and this is undocumented.
| * | | Update numpy/core/src/multiarray/calculation.cSebastian Berg2021-03-181-1/+2
| | | | | | | | | | | | Co-authored-by: Matti Picus <matti.picus@gmail.com>
| * | | MAINT: Do not claim input to binops is `self` (array object)Sebastian Berg2021-03-106-54/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | On the C-side binops only guarantee that one of the operands is an instance of `PyArrayObject *`, but we do not know which one. Typing the first as `PyArrayObject *` is just misleading for almost no actual payoff
* | | | Merge pull request #18642 from seberg/splitup-faster-argparsing-optimize-asarrayMatti Picus2021-03-2119-545/+694
|\ \ \ \ | | | | | | | | | | ENH: Use new argument parsing for array creation functions
| * | | | DOC: Update the docs to match how they changed in masterSebastian Berg2021-03-181-14/+45
| | | | | | | | | | | | | | | | | | | | | | | | | I had forgotten that the docs for these functions where updated when rebasing.
| * | | | BUG,TST: Fix error path and argument name (and add test coverage)Sebastian Berg2021-03-183-4/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The argument name for the python side defined function was always `a` and not `object` so fix it and add a test. Also add a test to ensure the error paths are taken for all of the function. The missing NULL returns cannot be tested easily (but thanks to code coverage its nice to look at the uncovered stuff closer...)
| * | | | DOC: Add TODO comment that `asarray` stubs will need movingSebastian Berg2021-03-181-0/+4
| | | | |
| * | | | BUG: import `asanyarray` to `_asarray.py` as its used in `np.require`Sebastian Berg2021-03-181-1/+1
| | | | |
| * | | | ENH: Use new argument parsing for array creation functionsSebastian Berg2021-03-1817-544/+629
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The array creation functions have the most to gain: 1. np.asarray is 4 times faster and commonly used. 2. Other functions are wrapped using __array_function__ in Python making it more difficult This commit (unfortunatly) has to do a few things: * Modify __array_function__ C-side dispatching to accomodate the fastcall argument convention. * Move asarray, etc. to C after removing all "fast paths" from np.array (simplifying the code) * Fixup imports, since asarray was imported directly in a few places * Replace some places where `np.array` was probably used for speed instead of np.asarray or similar. (or by accident in 1 or 2 places)
* | | | | Merge pull request #18648 from mwtoews/pep-3135Sebastian Berg2021-03-2016-59/+56
|\ \ \ \ \ | | | | | | | | | | | | MAINT: use super() as described by PEP 3135
| * | | | | MAINT: use super() as described by PEP 3135Mike Taves2021-03-1916-59/+56
| | | | | |
* | | | | | BUG: Fix small valgrind-found issues (#18651)Sebastian Berg2021-03-195-1/+6
| |_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * BUG: Fix small valgrind-found issues This should be backportable. There was at least one that I could not reproduce when running the tests again. And the new random-shuffle tests give false-positives (which is just slightly annoying, considering that we are very close to almost only "longdouble" related false-positives) * BUG: Add missing decref in user-dtype fallback paths The missing decref here only leaks references and can never leak actual memory fortunately. * MAINT,TST: Simplify the "refcount logic" in the dispatch tests again Using SETREF can be nice, but was just overcomplicating thing here...
* | | | | MAINT: Add mising type to cdef statementKevin Sheppard2021-03-193-4/+4
|/ / / / | | | | | | | | | | | | | | | | Add missing type to cdef statement Small spelling fix
* | | | MAINT: Added Chain exceptions where appropriate (#18400)Abhay Raghuvanshi2021-03-183-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Added chain exception in _pocketfft.py * Added chain exception in format.py * Added chain exception in make_lite.py * Added chain exception in mrecords.py * added from e for exceptions * Minor update for _read_array_header exception msg * Removed \n from excp msg and e from msg format. Co-authored-by: Eric Wieser <wieser.eric@gmail.com> * Update numpy/linalg/lapack_lite/make_lite.py Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Charles Harris <charlesr.harris@gmail.com>
* | | | Merge pull request #17492 from aitikgupta/unwanted-mode-depMatti Picus2021-03-186-20/+120
|\ \ \ \ | |/ / / |/| | | DEP: Shift correlate mode parsing to C and deprecate inexact matches
| * | | A few whitespace cleanupsAitik Gupta2021-03-181-5/+6
| | | |
| * | | The same test for np.correlateAitik Gupta2021-03-181-0/+5
| | | |
| * | | Add one more test for illegal argumentsAitik Gupta2021-03-181-0/+3
| | | | | | | | | | | | Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
| * | | Update numpy/core/src/multiarray/conversion_utils.cEric Wieser2021-03-181-0/+1
| | | |
| * | | TST: Added test for inexact matches of modeAitik Gupta2021-03-181-0/+23
| | | |
| * | | DEP: Deprecate inexact matches of mode, shift parameter parsing to CAitik Gupta2021-03-185-15/+82
| | | |
* | | | MAINT: Added Chain exceptions where appropriate (#18394)Abhay Raghuvanshi2021-03-187-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Added chain exception in _bits_of func * Added chain exception * Added chain exception in unixccompiler.py * Added chain exception in config.py * Added chain exception in fcompiler __init__.py * Added chain exception in compaq.py * Added chain exception in format.py * Updated raise chain exception * STY: Break long line. Co-authored-by: Charles Harris <charlesr.harris@gmail.com>
* | | | Merge pull request #18398 from seberg/casting-loop-signatureMatti Picus2021-03-1823-2255/+1765
|\ \ \ \ | |/ / / |/| | | MAINT: Fix casting signatures to align with NEP 43 signature
| * | | MAINT: Add comment to unused func, silence linter and avoid non-contig errorSebastian Berg2021-03-183-12/+18
| | | |
| * | | TST: Expend write-mask buffered nditer tests for high dim arraysSebastian Berg2021-03-171-7/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is utterly confusing, but adds coverage to another uncovered pass. I honestly do not really understand right now, why "writemasked" and "buffered" combination can bypass the buffering here. I guess there some special logic about that in the `where=` ufunc code that uses the masked versions here?
| * | | TST: Add tests for datetime byteswaps and unicode byteswap castsSebastian Berg2021-03-172-0/+40
| | | | | | | | | | | | | | | | It seemst he unicode didn't actually help coverage, but here we go.
| * | | TST: Add test for datetime and datetime->string byte order castsSebastian Berg2021-02-171-1/+39
| | | | | | | | | | | | | | | | | | | | | | | | Not the prettiest tests, but should ensure that casts involving byteorder changes within datetime/timedelta and between datetimes or timedeltas and strings are handled correctly.
| * | | DOC: Fix commentsSebastian Berg2021-02-174-14/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | As noted by Matti and Ross, these comments were incorrect. Co-authored-by: Matti Picus <matti.picus@gmail.com> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
| * | | TST: test_sparse_field_assignment now succeeds now (was xfail)Sebastian Berg2021-02-121-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | There were some paths that manipulated the unused data. This was fixed in the big refactor (or earlier), I expect there were some fast paths for equal sized dtypes that kicked in before
| * | | BUG: Fix cleanup on `get_loop` failureSebastian Berg2021-02-121-4/+20
| | | | | | | | | | | | | | | | | | | | This could maybe be done a bit nicer, for now a small (local) helper seemed convenient. This is only needed here.
| * | | BUG: string->datetime64 does not support byte swappingSebastian Berg2021-02-111-7/+8
| | | |
| * | | ENH: Micro-optimize within dtype castsSebastian Berg2021-02-112-1/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These is probably fairly common, so optimize the lookup in this extremely simple case. More optimizations should probably done eventually, e.g. we could add a fast-list for all builtin ones, or have an "intern" mechanism so that casts for any interned dtype will be stored in a list, with the assumption that an interned dtype can e.g. never be deleted and that there should not be too many of them.
| * | | MAINT: Fix casting signatures to align with NEP 43Sebastian Berg2021-02-1118-2231/+1588
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes all casting loops to get passed in a new `context` which holds some data such as the descriptors (and methods). For the most part, this is unnecessary information, but it allows us to pass additional information to ufuncs while also aligning ufunc and casting signatures (and definition). To achieve this, we have to fill and store this context everywhere, which leads to some rework. That means that this PR changes some of the chained loops to use fewer specialized loops. There should be no typical speed effect for larger arrays aside possibly a small one for rarer cases such as byteswapped or unaligned arrays (although we currently consider strings unaligned much too often). However, there will be a small increase in overheads, timing it, it appears to be <10% in the most extreme cases. While not neglible there are bigger optimizations possible (even moving the buffer-info data to the array struct was a bigger speedup in most cases!). Below are individual (squashed) commit while working on this, since the change had to be mostly complete to compile/test its fairly long (leaving it just for fun) Individual commit ----------------- Further changes Fixup the main multi-step cast functions Restructure field transfers (partially?) continuation WIP: This is tricky, need to redo some stuff (this is the start of that redo) WIP: more small changes And more work... Clean out/simplify legacy multi-step casts (mainly datetime) Fixup strided one to n field transfer (and decref partially) Fixup n-to-n cast for new methods Fix subarray casts for the new calling convention Finish fixing up the structured transfers and decref start with cleaning up masked casts BUG: Fixup struct access typo Fixup any-to-object Finish all/most of masked casting, this brings me to debugging... Fixup object copy and move functions Code now compiles without errors (of course segfaults immediately :)) Finish fixup of array_assign_* Pass pointer to cast_info_xfree (to be able to NULL func and error check) Also silence a few warnings Bug: Make sure datetime casts have copy/copyswap only path This is necessary to ensure the recursive calls don't recurse forever :). Small fixes, mostly make sure we use PyMem_* for all allocations/frees BUG: Fix memset in multistep cast Seems that code was little enough tested, that most test runs would simply not notice the issue (i.e. requires debug mode usually probably). Now it is used a lot and things came down hard. Bug: Fix stride order typo affecting strided masked indexing BUG: Finish npy-iter copy fixup (apparently it was not...) BUG: Fix scalar assignment mixup Fix bug in field bookkeeping and rename decsrcref to decref Its called "decref" everywhere, the "src" is just confusing especially since now we don't have the `func(dst, src)` calling convention anymore. Final fixes and cleanup of comments e.g. removed some comments alluring to a future that is unlikely to ever come... DOC: Change casting error message to be closer to other messages Fixup rebase: masked transfer function initialize got lost Fixup: remove print added for debugging into recfunctions
* | | | Merge pull request #18438 from seberg/shuffle-objectsCharles Harris2021-03-183-3/+41
|\ \ \ \ | | | | | | | | | | BUG: Correct shuffling of objects in 1-d array likes
| * | | | STY: Fix hanging indentation.Charles Harris2021-03-171-3/+3
| | | | |
| * | | | STY: Break long line.Charles Harris2021-03-171-1/+3
| | | | |
| * | | | BUG: Correct shuffling of objects in 1-d array likesSebastian Berg2021-02-223-3/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While introducing the buffer fixed the in-place problem years ago, running valgrind (and masked arrays) pointed out to me that without the additional `...` NumPy will unpack and repack objects leading to slightly incorrect results. MAINT: Warn about shuffle bug instead of fixing it in old random API
* | | | | Merge pull request #15269 from seberg/splitup-faster-argparsing-infrastructureMatti Picus2021-03-187-184/+845
|\ \ \ \ \ | | | | | | | | | | | | ENH: Implement faster keyword argument parsing capable of ``METH_FASTCALL``
| * | | | | ENH: Use fast parsing for methods and undispatched functionsSebastian Berg2021-03-172-183/+238
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Array methods are the easiest target for the new parser. They do not require any larger improvements and most functions in multiarray are wrapped. Similarly the printing functions are not dispatched through `__array_function__` and thus have the most to gain.
| * | | | | TST: Add specific argument parsing testsSebastian Berg2021-03-173-1/+88
| | | | | |
| * | | | | ENH: Add vectorcall/fastcall argument parsing capabilitiesSebastian Berg2021-03-173-0/+519
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a fast argument parser (an original version also supported dictionary unpacking (for args, kwargs call style) which supports the new FASTCALL and VECTORCALL convention of CPython. Fastcall is supported by all Python versions we support. This allows todrastically reduces the overhead of methods when keyword arguments are passed.
* | | | | | Merge pull request #18320 from madphysicist/patch-4Ralf Gommers2021-03-181-18/+17
|\ \ \ \ \ \ | | | | | | | | | | | | | | DOC: add links to polynomial function/class listing
| * | | | | | DOC: Added links to text and tableJoseph Fox-Rabinovitz2021-03-051-18/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | I found these convenient to have on hand while reading
* | | | | | | Merge pull request #18635 from bashtage/random-integer-exception-defaultMatti Picus2021-03-182-10/+32
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | ENH: Improve the exception for default low in Generator.integers