summaryrefslogtreecommitdiff
path: root/numpy
Commit message (Collapse)AuthorAgeFilesLines
* BUG: add check if pvals is 1d array in numpy.random.*.multinomialPan Jan2020-03-312-0/+4
|
* DOC: Fix docstring for _hist_bin_auto.Ross Barnowski2020-03-271-5/+5
| | | | | * "bandwidth" -> "bin width" * Minor grammatical fixes
* Merge pull request #15836 from sgasse/axis_np_meanMatti Picus2020-03-272-1/+13
|\ | | | | BUG: Fix IndexError for illegal axis in np.mean
| * BUG: Fix IndexError for illegal axis in np.meansgasse2020-03-262-1/+13
| | | | | | | | | | Catch IndexError in _count_reduce_items used in np.mean and np.var for illegal axis and reraise as AxisError, see gh-15817.
* | MAINT: simplify code that assumes str/unicode and int/long are different ↵Eric Wieser2020-03-2630-110/+41
| | | | | | | | | | types (#15816) Cleanup from the dropping of python 2
* | Merge pull request #15781 from dcaliste/publicMatti Picus2020-03-262-4/+59
|\ \ | | | | | | BUG: don't add 'public' or 'private' if the other one exists
| * | BUG: don't add 'public' or 'private' if the other one existsDamien Caliste2020-03-262-4/+59
| | | | | | | | | | | | | | | | | | Currently, setting 'public' or 'private' attribute is adding one even if the other one already exists because of the else: part that is always appending.
* | | ENH: improved error message `IndexError: too many indices for array` (#15832)Yilin LI2020-03-262-3/+18
| |/ |/| | | | | | | * ENH: improved error message when the dimension of index is larger than the dimension of array, fixed issue #15321 Author: Yilin Li <yilin.lasia@gmail.com> Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
* | ENH: Use TypeError in `np.array` for python consistency (#15784)Maxwell Bileschi2020-03-252-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, when writing something like ``` pd.DataFrame({'arr': np.array(1., 2., 3.)}) ``` ``` ValueError Traceback (most recent call last) <ipython-input-1-ffdb00ae9b74> in <module>() 1 import numpy as np 2 import pandas as pd ----> 3 pd.DataFrame({'arr': np.array(1., 2., 3.)}) ValueError: only 2 non-keyword arguments accepted ``` This stack trace that doesn't include a frame for the np constructor, because the constructor is generated python code. This may lead users to look elsewhere for the issuer of the ValueError, which may create red-herrings in that folks may look elsewhere. This changes makes it more obvious where the error is coming from. * reflects eric-wieser's suggestion about common error messages * Documents required non-keyword args for np.array * Update numpy/core/src/multiarray/multiarraymodule.c Co-Authored-By: Eric Wieser <wieser.eric@gmail.com> * Update numpy/core/src/multiarray/multiarraymodule.c Co-Authored-By: Eric Wieser <wieser.eric@gmail.com> * Update numpy/core/src/multiarray/multiarraymodule.c Co-Authored-By: Eric Wieser <wieser.eric@gmail.com> * Update multiarraymodule.c Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
* | DEP: Do not cast boolean indices to integers in np.delete (#15815)Eric Wieser2020-03-252-30/+35
| | | | | | | | | | | | | | | | 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 #15797 from sgasse/add_einsum_testSebastian Berg2020-03-241-0/+4
|\ \ | | | | | | TST: Add unit test for out=None of np.einsum
| * | TST: Add unit test for kwarg of np.einsumsgasse2020-03-221-0/+4
| | | | | | | | | | | | | | | Ensure that explicitly stating out=None does not raise an error in np.einsum, see #15776 and #15256.
* | | BUG: Break on all errors when performing strided casts. (gh-15827)Brandt Bucher2020-03-242-3/+11
| | | | | | | | | | | | Errors raised when casting some strided arrays are not caught. See gh-15790.
* | | Merge pull request #15830 from rth/import-fixes-mypyEric Wieser2020-03-243-18/+3
|\ \ \ | | | | | | | | MAINT: pathlib and hashlib are in stdlib in Python 3.5+
| * | | md5 module is deprecated since python 2.5Roman Yurchak2020-03-242-8/+2
| | | |
| * | | pathlib is in the standard libraryRoman Yurchak2020-03-241-10/+1
| | | |
* | | | BUG: Add basic __format__ for masked element to fix incorrect print (#15794)Warren Weckesser2020-03-242-0/+30
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix and test conversion of masked element to string in fstring / string interpolation. See PEP 498 for string interpolation (aka fstrings) in Python 3.6 and above. Fixes #15409. Original PR gh-15410 by: Stefan Codrescu <ssmmcc1@gmail.com> Co-authored-by: Stefan Codrescu <ssmmcc1@gmail.com> Co-authored-by: Stefan <5tefan@users.noreply.github.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* | | Merge pull request #15800 from brandtbucher/unsafe-castEric Wieser2020-03-242-53/+28
|\ \ \ | | | | | | | | BUG: Add error-checking versions of strided casts.
| * | | BUG: Break on errors when performing strided casts.Brandt Bucher2020-03-231-2/+12
| | | | | | | | | | | | | | | | Closed gh-15790.
| * | | TST: Add failing regression test for unsafe casts.Brandt Bucher2020-03-231-1/+5
| | | | | | | | | | | | | | | | | | | | Errors raised when casting some strided arrays are not caught. See gh-15790.
| * | | MAINT: Break out duplicated logic for strided casts.Brandt Bucher2020-03-231-52/+13
| | |/ | |/|
* | | Merge pull request #15802 from eric-wieser/simplify-insertEric Wieser2020-03-242-29/+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-222-29/+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-232-22/+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-222-22/+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-232-15/+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-222-15/+12
| |/ / / | | | | | | | | | | | | This expires a deprecation warning from back in 1.9.
* | | | Merge pull request #15799 from eric-wieser/simplify-insertSebastian Berg2020-03-221-7/+11
|\ \ \ \ | |/ / / | | | / | |_|/ |/| | MAINT: Cleanups to np.insert and np.delete
| * | MAINT: Make the axis logic for delete match insert.Eric Wieser2020-03-221-5/+4
| | | | | | | | | | | | No behavior change here unless someone implements a subclass where `arr.ravel().ndim == 0`, which no sane person would do anyway.
| * | MAINT: Add missing deprecation dates and versionsEric Wieser2020-03-221-1/+4
| | |
| * | MAINT: Remove some weird syntax for kwargsEric Wieser2020-03-221-1/+1
| | |
| * | MAINT: Add an explanatory comment for some weird codeEric Wieser2020-03-221-0/+2
| | |
* | | DEP: Make issubdtype consistent for types and dtypes (#15773)Sebastian Berg2020-03-222-28/+29
| |/ |/| | | | | | | | | | | | | | | | | This finishes the deprecation started in gh-9505 removing behaviour that allowed strings/types representing specific dtypes to behave like their more generic supertypes (e.g. the python float would map to floating instead of float64 which it typically maps to). Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
* | BUG, TST: fix f2py for PyPy, skip one test for PyPy (#15750)Matti Picus2020-03-1810-43/+45
| | | | | | * BUG, TST: fix f2py for PyPy, skip one test for PyPy, xfail tests for s390x
* | BUG: Guarantee array is in valid state after memory error occurs in getset.c ↵Mibu2872020-03-181-7/+13
|/ | | | | | | | | | | (#15736) Currently, in function array_shape_set, ndarray's pointers to dimensions and strides are freed before new array is allocated (Line 71). In case memory error occur, the array is left with dangling pointers. Therefore, we can not recover from such error. * To guarantee array in valid state when memory error occur * Fix: Free cache when nd == 0 to avoid memory leak * Update numpy/core/src/multiarray/getset.c Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
* MAINT: remove useless `global` statementsEric Wieser2020-03-186-9/+2
| | | | | | | `global` is only needed if a variable appears on the left of an assignment. These variables do not. Most suffer from the misconception that `var[x] = y` requires `var` to be global, but it does not.
* Merge pull request #15766 from seberg/simplify-specialized-castsMatti Picus2020-03-183-75/+30
|\ | | | | BUG,MAINT: Remove incorrect special case in string to number casts
| * BUG: Increase default string cast size of longdouble/clongdoubleSebastian Berg2020-03-161-2/+6
| |
| * BUG,MAINT: Remove incorrect special case in string to number castsSebastian Berg2020-03-162-73/+24
| | | | | | | | | | | | | | | | | | The string to number casts fall back to using the scalars and the type setitem function to do the cast. However, before calling setitem, they sometimes already called the Python function for string coercion. This is unnecessary. Closes gh-15608
* | BUG: add missing c_distributions.pxd, enables cython use of random C-API ↵Matti Picus2020-03-1612-149/+245
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (gh-15463) xref gh-14778 As pointed out in the comment by @jamesthomasgriffin, we did not include a pxd file to expose the distribution functions documented in the random c-api. This PR adds a c_distributions.pxd file that exposes them. Squashed commits: * BUG: add missing c_distributions.pxd to enable cython use of random C-API * ENH, TST: add npyrandom library like npymath, test cython use of it * BUG: actually prefix f-string with f * MAINT: fixes from review, add _bit_generato_bit_generator.pxd * STY: fixes from review * BLD: don't use nprandom library for mtrand legacy build * TST: WindowsPath cannot be used in subprocess's list2cmdline * MAINT, API: move _bit_generator to bit_generator * DOC: add release note about moving bit_generator * DOC, MAINT: fixes from review * MAINT: redo dtype determination from review
* | MAINT: Test during import to detect bugs with Accelerate(MacOS) LAPACK (#15695)Rakesh Vasudevan2020-03-151-0/+32
| | | | | | | | | | | | | | * TST: Test during import to detect bugs with Accelerate(MacOS) LAPACK fixes #15647 * Pipeline update for Accelerate(MacOS) testing
* | 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-152-4/+22
| | | | | | | | | | | | | | 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
* | MAINT: Add better error handling in linalg.norm for vectors and clarify it ↵Jim2020-03-123-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | in documentation (#15740) * Clarify `fro` and `nuc` usage in linalg.norm documentation (see #15533). * Add improved error handling when getting Frobenius norm from a vector (see #15533). * Fix comment in linalg norm test. Closes gh-15533.
* | DOC: Do not complain about contiguity when mutating `ndarray.shape` (gh-10600)John Han2020-03-123-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | There are multiple conditions that `_attempt_nocopy_reshape` checks for when ndarray.shape is mutated directly. Discussion of #10146 indicated that an error message referencing any type of contiguity would not be correct for all cases, so the error message has been changed to be more general. * ENH: shorten message and use "in-place" * MAINT: typo from review Co-authored-by: hanjohn <hanjohn@users.noreply.github.com> Co-authored-by: mattip <matti.picus@gmail.com>
* | DOC: Refactor `np.polynomial` docs using `automodule` (#15662)Ross Barnowski2020-03-126-220/+306
| | | | | | * DOC: Refactor polynomial docs using automodule.
* | ENH: Add `subok` parameter to np.copy function (cf. gfh6509) (gh-15685)Ross Barnowski2020-03-112-3/+19
| | | | | | | | | | 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