summaryrefslogtreecommitdiff
path: root/numpy/core/tests
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #23763 from seberg/nep50-fixes-part2Charles Harris2023-05-161-0/+44
|\ | | | | BUG: Fix weak scalar logic for large ints in ufuncs
| * MAINT: Address Marten's reviewSebastian Berg2023-05-151-1/+13
| |
| * BUG: Fix weak scalar logic for large ints in ufuncsSebastian Berg2023-05-151-0/+32
| | | | | | | | | | This fixes it, breaks warnings (partially), but most or all of those paths should be errors anyway.
* | Merge pull request #23659 from seberg/issue-23029Charles Harris2023-05-161-1/+18
|\ \ | |/ |/| ENH: Restore TypeError cleanup in array function dispatching
| * TST: Skip test on older Python versions which use `__name__`Sebastian Berg2023-04-251-0/+6
| |
| * ENH: Restore TypeError cleanup in array function dispatchingSebastian Berg2023-04-251-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | When the dispathcer raises a TypeError and it starts with the dispatchers name (or actually __qualname__ not that it normally matters), then it is nicer for users if we just raise a new error with the public symbol name. Python does not seem to normalize exception and goes down the unicode path, but I assume that e.g. PyPy may not do that. And there might be other weirder reason why we go down the full path. I have manually tested it by forcing Normalization. Closes gh-23029
* | Merge branch 'main' into deprecate-find-common-typeCharles Harris2023-05-1347-1095/+2944
|\ \
| * | BUG: typo, lintingmattip2023-05-111-1/+0
| | |
| * | add fast path for str(scalar_int)mattip2023-05-101-1/+3
| | |
| * | Merge pull request #23713 from seberg/uint-int-comparisonsCharles Harris2023-05-061-0/+58
| |\ \ | | | | | | | | ENH: Make signed/unsigned integer comparisons exact
| | * | ENH: Make signed/unsigned integer comparisons exactSebastian Berg2023-05-041-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes comparisons between signed and unsigned integers exact by special-casing promotion in comparison to never promote integers to floats, but rather promote them to uint64 or int64 and use a specific loop for that purpose. This is a bit lazy, it doesn't make the scalar paths fast (they never were though) nor does it try to vectorize the loop. Thus, for cases that are not int64/uint64 already and require a cast in either case, it should be a bit slower. OTOH, it was never really fast and the int64/uint64 mix is probably faster since it avoids casting. --- Now... the reason I was looking into this was, that I had hoped it would help with NEP 50/weak scalar typing to allow: uint64(1) < -1 # annoying that it fails with NEP 50 but, it doesn't actually, because if I use int64 for the -1 then very large numbers would be a problem... I could probably(?) add a *specific* "Python integer" ArrayMethod for comparisons and that could pick `object` dtype and thus get the original Python object (the loop could then in practice assume a scalar value). --- In either case, this works, and unless we worry about keeping the behavior we probably might as well do this. (Potentially with follow-ups to speed it up.)
| * | | Merge pull request #23699 from ngoldbaum/repeat-remove-array-increfSebastian Berg2023-05-031-2/+3
| |\ \ \ | | |/ / | |/| | MAINT: refactor PyArray_Repeat to avoid PyArray_INCREF
| | * | TST: test object dtype in test_repeatNathan Goldbaum2023-05-031-2/+3
| | | |
| * | | Merge pull request #22137 from Micky774/enable_simdMatti Picus2023-05-031-2/+216
| |\ \ \ | | | | | | | | | | ENH allow for specifying CPU features to enable via `NPY_ENABLE_CPU_FEATURES` environment variable
| | * | | ENH: add NPY_ENABLE_CPU_FEATURES to allow limiting set of enabled featuresMeekail Zain2023-04-081-2/+216
| | | | |
| * | | | xfail underflowing scalar sinChris Sidebottom2023-05-021-0/+4
| | | | |
| * | | | Add test case for underflow exceptionChris Sidebottom2023-05-021-0/+10
| | |/ / | |/| | | | | | | | | | Co-authored-by: Pierre Blanchard <Pierre.Blanchard@arm.com>
| * | | Merge pull request #23528 from seberg/allow-backcomp-buildsMatti Picus2023-04-281-0/+1
| |\ \ \ | | | | | | | | | | ENH: Allow, and default to, downstream building with old API
| | * | | TST,DOC: Avoid spaces to hopefully ensure more info on error and fix memtestsSebastian Berg2023-04-041-0/+1
| | | | |
| * | | | Merge pull request #18053 from Iamsoto/adding_object_to_einsumSebastian Berg2023-04-282-27/+119
| |\ \ \ \ | | | | | | | | | | | | ENH: Adding Object dtype to einsum
| | * | | | fixes from reviewmattip2023-04-271-0/+15
| | | | | |
| | * | | | TST: add test for 5e6e5863 (issue gh-23492)mattip2023-03-301-1/+4
| | | | | |
| | * | | | TST: fix tests for einsum returning a python objectmattip2023-03-301-2/+6
| | | | | |
| | * | | | PR_fixes_1iamsoto2023-03-292-333/+94
| | | | | |
| | * | | | WIP: Adding Object dtype to einsumiamsoto2023-03-291-0/+309
| | |/ / /
| * | | | Merge pull request #22493 from mwtoews/maint-openSebastian Berg2023-04-282-14/+14
| |\ \ \ \ | | | | | | | | | | | | MAINT: remove redundant open() modes and io.open() alias
| | * | | | MAINT: remove redundant open() modes and io.open() aliasMike Taves2022-10-292-14/+14
| | | | | |
| * | | | | Merge pull request #23666 from seberg/subarray-cleanupMatti Picus2023-04-273-45/+28
| |\ \ \ \ \ | | | | | | | | | | | | | | DEP,BUG: Finalize subarray dtype FutureWarning and fix its assignment
| | * | | | | DEP: Finalize subarray from non-subarray creation futurewarningSebastian Berg2023-04-262-42/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This unfortunately switches over the C-only path when FromArray is called with a subarray dtype. Together with the previous commit (which is very simple but in a sense does the heavy lifting): Closes gh-23083
| | * | | | | MAINT: Fixup handling of subarray dtype in ufunc.resolve_dtypesSebastian Berg2023-04-261-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is now OK to just support, we won't replace things and things should work out for the most part (probably).
| * | | | | | Merge pull request #23358 from seberg/dtype-class-in-typesMatti Picus2023-04-271-2/+30
| |\ \ \ \ \ \ | | |/ / / / / | |/| | | | | API: Add DType classes into new `numpy.dtypes` module
| | * | | | | MAINT: Move module to be `np.dtypes` and add release noteSebastian Berg2023-04-121-5/+5
| | | | | | |
| | * | | | | TST: Update test due to windows Int vs intc name differenceSebastian Berg2023-04-121-2/+6
| | | | | | |
| | * | | | | API: Add `numpy.types` module and fill it with DType classesSebastian Berg2023-04-121-2/+26
| | | | | | |
| * | | | | | Merge pull request #23660 from seberg/finalize-sequence-array-likeCharles Harris2023-04-252-91/+13
| |\ \ \ \ \ \ | | | | | | | | | | | | | | | | DEP: Finalize checking for sequence-like if something is array-like
| | * | | | | | DEP: Finalize checking for sequence-like if something is array-likeSebastian Berg2023-04-252-91/+13
| | | |_|_|_|/ | | |/| | | | | | | | | | | | | | | | | | | | | | | | | This was always just a stop-gap for shapely basically, so there is no harm finalizing things.
| * | | | | | ENH: float64 sin/cos using Numpy intrinsics (#23399)Christopher Sidebottom2023-04-251-12/+25
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This takes the [sin](https://github.com/ARM-software/optimized-routines/blob/master/math/v_sin.c) and [cos](https://github.com/ARM-software/optimized-routines/blob/master/math/v_cos.c) algorithms from Optimized Routines under MIT license, and converts them to Numpy intrinsics. The routines are within the ULP boundaries of other vectorised math routines (<4ULP). The routines reduce performance in some special cases but improves normal cases. Comparing to the SVML implementation, these routines are more performant in special cases, we're therefore safe to assume the performance is acceptable for AArch64 as well. | performance ratio (lower is better) | benchmark | | ---- | ---- | | 1.8 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'cos'> 4 2 'd') | | 1.79 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'cos'> 4 4 'd') | | 1.77 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'cos'> 4 1 'd') | | 1.74 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'cos'> 2 2 'd') | | 1.74 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'cos'> 2 4 'd') | | 1.72 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'cos'> 2 1 'd') | | 1.6 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'cos'> 1 2 'd') | | 1.6 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'cos'> 1 4 'd') | | 1.56 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'cos'> 1 1 'd') | | 1.42 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'sin'> 2 2 'd') | | 1.41 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'sin'> 2 4 'd') | | 1.37 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'sin'> 2 1 'd') | | 1.26 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'sin'> 4 2 'd') | | 1.26 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'sin'> 4 4 'd') | | 1.2 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'sin'> 4 1 'd') | | 1.18 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'sin'> 1 2 'd') | | 1.18 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'sin'> 1 4 'd') | | 1.12 | bench_ufunc_strides.UnaryFPSpecial.time_unary(<ufunc 'sin'> 1 1 'd') | | 0.65 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'cos'> 4 2 'd') | | 0.64 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'cos'> 2 4 'd') | | 0.64 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'cos'> 4 4 'd') | | 0.64 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'cos'> 2 2 'd') | | 0.61 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'cos'> 1 4 'd') | | 0.61 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'cos'> 1 2 'd') | | 0.6 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'cos'> 2 1 'd') | | 0.6 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'cos'> 4 1 'd') | | 0.56 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'cos'> 1 1 'd') | | 0.52 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'sin'> 4 2 'd') | | 0.52 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'sin'> 4 4 'd') | | 0.52 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'sin'> 2 4 'd') | | 0.52 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'sin'> 2 2 'd') | | 0.47 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'sin'> 1 4 'd') | | 0.47 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'sin'> 1 2 'd') | | 0.46 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'sin'> 4 1 'd') | | 0.46 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'sin'> 2 1 'd') | | 0.42 | bench_ufunc_strides.UnaryFP.time_unary(<ufunc 'sin'> 1 1 'd') | Co-authored-by: Pierre Blanchard <Pierre.Blanchard@arm.com>
| * | | | | DEP: deprecate scalar conversions for arrays with ndim > 0 (#10615)Nico Schlömer2023-04-202-8/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR reflects some of the progress achieved in issue #10404 and is used to asses the impact of the changes. With the changes in this PR, `float(numpy.array([1.0])` now gives a warning; likewise some other things: ```python import numpy a = numpy.random.rand(10, 1) a[0] = numpy.array([1.0]) # okay a[0] = numpy.array(1.0) # okay a[0] = 1.0 # okay b = numpy.random.rand(10) b[0] = numpy.array([1.0]) # ValueError: setting an array element with a sequence. b[0, ...] = numpy.array([1.0]) # okay b[0] = numpy.array(1.0) # okay b[0] = 1.0 # okay ``` This aligns the behavior of numpy arrays with that of lists: ```python float([3.14]) ``` ``` TypeError: float() argument must be a string or a number, not 'list' ``` ```python import numpy as np a = np.random.rand(5) a[0] = [3.14] ``` ``` ValueError: setting an array element with a sequence. ``` Fixes #10404.
| * | | | | Merge pull request #23557 from mhvk/arrayprint-subformat-use-thresholdMarten van Kerkwijk2023-04-191-1/+38
| |\ \ \ \ \ | | | | | | | | | | | | | | ENH: Use threshold also inside SubArrayFormat.
| | * | | | | ENH: Use threshold also inside SubArrayFormat.Marten van Kerkwijk2023-04-071-1/+38
| | | |_|_|/ | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, for structured arrays that contain a lot of elements, those are always all shown, independent of the threshold print option. This PR ensures that threshold and edgeitems are respected. Note that multidimensional items are typeset without line breaks, to avoid breaking up the structure. Hence, this does not solve the issue that structured array elements can easily overfill a line on the console.
| * | | | | Merge pull request #23275 from byrdie/bugfix/logspace-base-broadcastSebastian Berg2023-04-121-0/+28
| |\ \ \ \ \ | | |_|/ / / | |/| | | | ENH: Modify `np.logspace` so that the `base` argument broadcasts against `start` and `stop`
| | * | | | ENH: Modify `numpy.logspace` so that the `base` argument broadcasts ↵Roy Smart2023-03-061-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | correctly against `start` and `stop`.
| * | | | | TST: try readding test_new_policy on muslAndrew Nelson2023-04-111-2/+1
| | | | | |
| * | | | | Merge pull request #23555 from ngoldbaum/deprecate-np-mathRalf Gommers2023-04-081-0/+9
| |\ \ \ \ \ | | |_|/ / / | |/| | | | | | | | | | | | | | | | DEP: deprecate np.math and np.lib.math [skip ci]
| | * | | | DEP: deprecate np.math and np.lib.mathNathan Goldbaum2023-04-071-0/+9
| | | |_|/ | | |/| |
| * | | | BUG: fix loading and storing big arrays on s390xAleksei Nikiforov2023-03-301-0/+7
| |/ / /
| * | | BUG: Use output when given on numpy.dot C-API branch (#23459)Pedro Lameiras2023-03-281-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Updated the dot function C-API so that it now calls `np.multiply` with `out=` and returns it on branch of the function where the correct behaviour was not in place. Added two tests regarding this issue. Closes #21081. Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
| * | | BUG: in the fastest path form ufunc.at, properly increment args[2]mattip2023-03-271-0/+11
| | | |
| * | | TST: Fix failing test (introduced deprecation after written)Sebastian Berg2023-03-261-2/+2
| | | |
| * | | Merge pull request #21120 from BvB93/matmulMatti Picus2023-03-261-11/+66
| |\ \ \ | | | | | | | | | | ENH: Add support for inplace matrix multiplication