summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #16348 from seberg/fromany-leakCharles Harris2020-05-231-0/+9
|\ | | | | BUG: Fix dtype leak in `PyArray_FromAny` error path
| * BUG: Fix dtype leak in `PyArray_FromAny` error pathSebastian Berg2020-05-221-0/+9
| | | | | | | | | | | | | | | | Also adds a test to bincount which will run into this path. The leak can be triggered by using a reference count checker on the test suit (e.g. pytest-leaks). Closes gh-16339
* | BUG: Indentation for docstringsEric Larson2020-05-221-5/+15
|/
* TST: Add a test for np.add_docstringSebastian Berg2020-05-201-1/+39
| | | | | Its not quite the right file, but close to newdoc seemed sensible and we do not have a "right" file right now...
* BUG: Fix default fallback in genfromtxtSebastian Berg2020-05-182-2/+9
| | | | | | | | | This affected (for example?) if the `dtype=object` was used without a converter, meaning that the default one is used. And this is currently the last one, which is `string_` (and thus bytes). Closes gh-16189
* MAINT: lib: A few changes in some vectorize tests.Warren Weckesser2020-05-021-41/+31
| | | | | | | | | Added a note to some of the tests that the order of the calls is an important part of the test, because the code is testing the caching of the ufuncs. Also reuse a couple functions in the vectorize tests by defining them at the module level.
* BUG: lib: Fix a problem with vectorize with default parameters.Warren Weckesser2020-04-301-0/+77
| | | | | | | | | | | | | | | | | | | | | | | When `otypes` is given to `vectorize` and then the instance is called, it creates a ufunc by calling numpy.core.umath.frompyfunc. The number of arguments given to this ufunc is set to the number of arguments in the call of the vectorize instance. This ufunc is cached, so frompyfunc does not have to be called on the next call. The problem is that, if the function being wrapped has parameters with default values, the number of arguments passed to the vectorize instance can change, and when that happens, a new ufunc must be created by calling frompyfunc with the correct number of arguments. This commit changes the cache of the ufunc from a simple attribute that holds the most recent ufunc to a dictionary whose keys are the number of arguments in the call. The cache is only used when the vectorized function is called with only positional arguments and there are no excluded arguments. If keywords are used, the number of arguments is no longer sufficient to uniquely identify a previously created ufunc. Closes gh-16120.
* TST: Add slow_pypy supportAnirudh Subramanian2020-04-131-0/+1
|
* TST: Run test_large_zip in a child process (#15893)Anirudh Subramanian2020-04-021-7/+12
| | | * Run test_large_zip in a child process
* MAINT: simplify code that assumes str/unicode and int/long are different ↵Eric Wieser2020-03-264-9/+4
| | | | | types (#15816) Cleanup from the dropping of python 2
* DEP: Do not cast boolean indices to integers in np.delete (#15815)Eric Wieser2020-03-251-12/+11
| | | | | | | | This expires a deprecation from 1.8. The corresponding deprecation in `np.insert` has less clear semantics, so has been left to a future patch. Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net> Co-authored-by: Warren Weckesser <warren.weckesser@gmail.com>
* Merge pull request #15802 from eric-wieser/simplify-insertEric Wieser2020-03-241-9/+8
|\ | | | | DEP: Make `np.insert` and `np.delete` on 0d arrays with an axis an error
| * DEP: Make `np.insert` and `np.delete` on 0d arrays with an axis an errorEric Wieser2020-03-221-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this change, the following code worked: ``` >>> some_0d = np.array(1) >>> np.insert(some_0d, "some nonsense", 10, axis=0) array(10) >>> np.insert(some_0d, "some nonsense", 42, axis="some nonsense") array(42) ``` Now these raise AxisError and TypeError, respectively. `delete` is exactly the same.
* | Merge pull request #15812 from eric-wieser/expire-delete-out-of-boundsSebastian Berg2020-03-231-1/+5
|\ \ | | | | | | TST: Remove code that is not supposed to warn out of warning assertion
| * | TST: Remove code that is not supposed to warn out of warning assertionEric Wieser2020-03-231-1/+5
| | |
* | | Merge pull request #15804 from eric-wieser/expire-delete-out-of-boundsSebastian Berg2020-03-231-5/+4
|\ \ \ | |/ / | | | DEP: Make np.delete on out-of-bounds indices an error
| * | DEP: Make np.delete on out-of-bounds indices an errorEric Wieser2020-03-221-5/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note that this only affects lists of indices. ```python >>> a = np.arange(3) ```` Before: ```python >>> np.delete(a, 100) IndexError >>> np.delete(a, [100]) DeprecationWarning array([0, 1, 2]) >>> np.delete(a, -1) array([0, 1]) >>> np.delete(a, [-1]) FutureWarning array([0, 1, 2]) ``` After: ```python >>> np.delete(a, 100) IndexError >>> np.delete(a, [100]) IndexError >>> np.delete(a, -1) array([0, 1]) >>> np.delete(a, [-1]) array([0, 1]) ```
* | Merge pull request #15805 from eric-wieser/expired-insert-delete-TypeErrorSebastian Berg2020-03-231-0/+12
|\ \ | | | | | | DEP: Forbid passing non-integral index arrays to `insert` and `delete`
| * | DEP: Forbid passing non-integral index arrays to `insert` and `delete`Eric Wieser2020-03-221-0/+12
| |/ | | | | | | This expires a deprecation warning from back in 1.9.
* | BUG, TST: fix f2py for PyPy, skip one test for PyPy (#15750)Matti Picus2020-03-181-8/+9
|/ | | * BUG, TST: fix f2py for PyPy, skip one test for PyPy, xfail tests for s390x
* MAINT: lib: PEP-8 clean up in test_arraysetops.py.Warren Weckesser2020-03-151-38/+41
|
* BUG: lib: Handle axes with length 0 in np.unique.Warren Weckesser2020-03-151-0/+6
| | | | | | | Tweak a few lines so that arrays with an axis with length 0 don't break the np.unique code. Closes gh-15559.
* TST: lib: Add a unit test for np.unique applied to arrays with a length 0 axis.Huon Wilson2020-03-151-0/+35
| | | | | This code is from github user huonw, from this PR: https://github.com/numpy/numpy/pull/15565
* ENH: Add `subok` parameter to np.copy function (cf. gfh6509) (gh-15685)Ross Barnowski2020-03-111-0/+7
| | | | | This is largely a re-submission of the original change proposed in #6509. Discussion was hosted in multiple forums including #3474, the numpy mailing list circa 10-2015, and the 02-26-2020 NumPy Triage meeting. This PR closes #3474 and #15570
* Merge pull request #15534 from seberg/deprecate-abstract-scalar-typesMatti Picus2020-03-062-5/+5
|\ | | | | DEP: Do not allow "abstract" dtype conversion/creation
| * DEP: Do not allow "abstract" dtype conversion/creationSebastian Berg2020-02-062-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These dtypes do not really make sense as instances. We can (somewhat) reasonably define np.dtype(np.int64) as the default (machine endianess) int64. (Arguably, it is unclear that `np.array(arr_of_>f8, dtype="f")` should return arr_of_<f8, but that would be very noisy!) However, `np.integer` as equivalent to long, is not well defined. Similarly, `dtype=Decimal` may be neat to spell `dtype=object` when you intend to put Decimal objects into the array. But it is misleading, since there is no special meaning to it at this time. The biggest issue with it, is that `arr.astype(np.floating)` looks like it will let float32 or float128 pass, but it will force a float64 output! Arguably downcasting is a bug in this case. A related issue is `np.dtype("S")` and especially "S0". The dtype "S" does make sense for most or all places where `dtype=...` can be passed. However, it is conceptionally different from other dtypes, since it will not end up being attached to the array (unlike "S2" which would be). The dtype "S" really means the type number/DType class of String, and not a specific dtype instance.
* | BUG: Fixing result of np quantile edge caseEric Mariasis2020-02-281-0/+10
|/
* BUG: np.load does not handle empty array with an empty descr (#15397)Sha Liu2020-01-271-1/+3
| | | | | | | The bug occurs since numpy 1.16. Before that empty descr corresponds to `np.dtype([])`. This fixes the problem by following numpy 1.15's behavior. Closes gh-15396
* MAINT: Remove Python2 workaroundsSeth Troisi2020-01-231-1/+0
|
* MAINT: Clean up, mostly unused imports.Warren Weckesser2020-01-233-6/+1
|
* MAINT: Python2 CleanupsSeth Troisi2020-01-211-3/+2
|
* NEP: issue deprecation warning when creating ragged array (NEP 34)Matti Picus2020-01-212-15/+20
| | | | This implements NEP 34.
* MAINT: Remove sys.version checks in testsSeth Troisi2020-01-157-96/+38
|
* DOC: fix typosBrian Wignall2020-01-141-1/+1
|
* MAINT: Implement keyword-only arguments as syntaxEric Wieser2020-01-061-6/+3
| | | | Now that 2.7 is gone, there is no need to pop manually from kwarg dictionaries.
* MAINT: Remove implicit inheritance from object class (#15236)Jon Dufresne2020-01-0519-155/+155
| | | | | | | Inheriting from object was necessary for Python 2 compatibility to use new-style classes. In Python 3, this is unnecessary as there are no old-style classes. Dropping the object is more idiomatic Python.
* MAINT: Remove unnecessary 'from __future__ import ...' statementsJon Dufresne2020-01-0324-48/+0
| | | | | As numpy is Python 3 only, these import statements are now unnecessary and don't alter runtime behavior.
* BUG: lib: Fix handling of integer arrays by gradient.Warren Weckesser2020-01-011-0/+34
| | | | | | | In numpy.gradient, convert integer array inputs to float64 to avoid unwanted modular arithmetic. Closes gh-15207.
* MAINT: lib: Clean up in tests.Warren Weckesser2020-01-013-3/+0
| | | | * Remove a few unused imports in several files.
* Merge pull request #14981 from seberg/issue-13103Matti Picus2019-12-111-7/+12
|\ | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit c088383cb290ca064d456e89d79177a0e234cb8d and uses the same kind casting rule for the additional keyword arguments ``to_end`` and ``to_begin``. This results in slightly more leniant behaviour for integers (which can now have overflows that are hidden), but fixes an issue with the handling of NaN. Generally, this behaviour seems more conistent with what NumPy does elsewhere. The Overflow issue exists similar in many other places and should be solved by integer overflow warning machinery while the actual cast takes place. Closes gh-13103
| * BUG: Make ``ediff1d`` kwarg casting consistentSebastian Berg2019-11-251-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit c088383cb290ca064d456e89d79177a0e234cb8d and uses the same kind casting rule for the additional keyword arguments ``to_end`` and ``to_begin``. This results in slightly more leniant behaviour for integers (which can now have overflows that are hidden), but fixes an issue with the handling of NaN. Generally, this behaviour seems more conistent with what NumPy does elsewhere. The Overflow issue exists similar in many other places and should be solved by integer overflow warning machinery while the actual cast takes place. Closes gh-13103
* | Revert "DEP: issue deprecation warning when creating ragged array (NEP 34)"revert-14794-nep-0034-implRalf Gommers2019-12-062-20/+15
| |
* | TST: fix up issues in requires_memory decoratorPauli Virtanen2019-12-041-1/+1
| | | | | | | | Fix wrong multiplier for /proc/meminfo, and do style cleanups.
* | Merge pull request #15023 from qwhelan/nan_perfMatti Picus2019-12-031-1/+28
|\ \ | | | | | | MAINT: Only copy input array in _replace_nan() if there are nans to replace
| * | PERF: only copy input array in _replace_nan() if there are nans to replaceChristopher Whelan2019-12-021-1/+28
| |/
* | Merge pull request #14794 from mattip/nep-0034-implRalf Gommers2019-12-022-15/+20
|\ \ | | | | | | DEP: issue deprecation warning when creating ragged array (NEP 34)
| * | TST: fix failing testmattip2019-10-311-1/+1
| | |
| * | DEP: issue deprecation warning when creating ragged array (NEP 34)mattip2019-10-311-14/+19
| | |
* | | ENH,DEP: Allow multiple axes in expand_dims (#14051)Larry Bradley2019-12-021-6/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | This PR allows the axis keyword in expand_dims to be a tuple of ints. Previously, axis could only be an int. This issue was previously discussed in gh-12290 and the changes are based on gh-12290 (comment). This PR also removes the deprecation added in v1.13 (2017-05-17), where previously axis could be outside of the range (-a.ndim - 1) <= axis <= a.ndim. Such an axis value will now raise an AxisError. Please let me know if it's too soon to remove this deprecation (I could not find any dev docs stating the length of the numpy deprecation cycle). Closes gh-12290.
* | | BUG: warn when saving dtype with metadata (#14994)Matti Picus2019-12-021-0/+30
| | | | | | | | | Address gh-14142 for the 1.18 release: warn when saving a dtype with metadata that cannot be loaded.