| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| | |/ /
| |/| |
| | | |
| | | | |
The "do not use" comment has been here since bb0e4f356cce2f199d9c08ffe572fbabadc846d1.
|
|/ / /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
counterparts (#17222)
* DOC: redistribute docstring-only content from numpy/doc
* DOC: post-transition clean-up
* DOC, MAINT: reskip doctests, fix a few easy ones
|
|/ /
| |
| |
| |
| |
| | |
This relies on the fact that `cos` is exactly symmetric around zero, but not around the floating-point approximation of `pi`.
Closes gh-17169.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This PR adds the implementation of NEP-35's like= argument, allowing dispatch of array creation functions with __array_function__ based on a reference array.
* ENH: Add like= kwarg via __array_function__ dispatcher to asarray
* ENH: Add new function for __array_function__ dispatching from C
This new function allows dispatching from C directly, while also
implementing the new `like=` argument, requiring only minimal
changes to existing array creation functions that need to add
support for that argument.
* ENH: Add like= support to numpy.array
The implementation uses array_implement_c_array_function, thus
introducing minimal complexity to the original _array_fromobject
code.
* BUG: Fix like= dispatcher for np.full
* ENH: Remove np.asarray like= dispatcher via Python
np.asarray can rely on np.array's C dispatcher instead.
* TST: Add some tests for like= argument
Tests comprise some of the functions that have been implemented already:
* np.array (C dispatcher)
* np.asarray (indirect C dispatcher via np.array)
* np.full (Python dispatcher)
* np.ones (Python dispatcher)
* ENH: Remove like= argument during array_implement_array_function
* ENH: Add like= kwarg to ones and full
* BUG: prevent duplicate removal of `like=` argument
* ENH: Make `like=` a keyword-only argument
* ENH: Use PyUnicode_InternFromString in arrayfunction_override
Replace PyUnicode_FromString by PyUnicode_InternFromString to cache
"like" string.
* ENH: Check for arrayfunction_override import errors
Check and handle errors on importing NumPy's Python functions
* BUG: Fix array_implement_c_array_function error handling
* ENH: Handle exceptions with C implementation of `like=`
* ENH: Add `like=` dispatch for all asarray functions
Using Python dispatcher for all of them. Using the C dispatcher
directly on the `np.array` call can result in incorrect behavior.
Incorrect behavior may happen if the downstream library's
implementation is different or if not all keyword arguments are
supported.
* ENH: Simplify handling of exceptions with `like=`
* TST: Add test for exception handling with `like=`
* ENH: Add support for `like=` to `np.empty` and `np.zeros`
* TST: Add `like=` tests for `np.empty` and `np.zeros`
* ENH: Add `like=` to remaining multiarraymodule.c functions
Functions are:
* np.arange
* np.frombuffer
* np.fromfile
* np.fromiter
* np.fromstring
* TST: Add tests for multiarraymodule.c functions with like=
Functions are:
* np.arange
* np.frombuffer
* np.fromfile
* np.fromiter
* np.fromstring
* ENH: Add `like=` support to more creation functions
Support for the following functions is added:
* np.eye
* np.fromfunction
* np.genfromtxt
* np.identity
* np.loadtxt
* np.tri
* TST: Add `like=` tests for multiple functions
Tests for the following functions are added:
* np.eye
* np.fromfunction
* np.genfromtxt
* np.identity
* np.loadtxt
* np.tri
* TST: Reduce code duplication in `like=` tests
* DOC: Document `like=` in functions that support it
Add documentations for the following functions:
* np.array
* np.arange
* np.asarray
* np.asanyarray
* np.ascontiguousarray
* np.asfortranarray
* np.require
* np.empty
* np.full
* np.ones
* np.zeros
* np.identity
* np.eye
* np.tri
* np.frombuffer
* np.fromfile
* np.fromiter
* np.fromstring
* np.loadtxt
* np.genfromtxt
* ENH: Add `like=` to numpy/__init__.pyi stubs
* BUG: Remove duplicate `like=` dispatching in as*array
Functions `np.asanyarray`, `np.contiguousarray` and `np.fortranarray`
were dispatching both via their definitions and `np.array` calls,
the latter should be avoided.
* BUG: Fix missing check in array_implement_array_function
* BUG: Add missing keyword-only markers in stubs
* BUG: Fix duplicate keyword-only marker in array stub
* BUG: Fix syntax error in numpy/__init__.pyi
* BUG: Fix more syntax errors in numpy/__init__.pyi
* ENH: Intern arrayfunction_override strings in multiarraymodule
* STY: Add missing brackets to arrayfunction_override.c
* MAINT: Remove arrayfunction_override dict check for kwarg
* TST: Assert that 'like' is not in TestArrayLike kwargs
* MAINT: Rename array_implement_c_array_function(_creation)
This is done to be more explicit as to its usage being intended for
array creation functions only.
* MAINT: Use NotImplemented to indicate fallback to default
* TST: Test that results with `like=np.array` are correct
* TST: Avoid duplicating MyArray code in TestArrayLike
* TST: Don't delete temp file, it may cause issues with Windows
* TST: Don't rely on eval in TestArrayLike
* TST: Use lambda with StringIO in TestArrayLike
* ENH: Avoid unnecessary Py_XDECREF in arrayfunction_override
* TST: Make TestArrayLike more readable
* ENH: Cleaner error handling in arrayfunction_override
* ENH: Simplify array_implement_c_array_function_creation
* STY: Add missing spaces to multiarraymodule.c
* STY: C99 declaration style in arrayfunction_override.c
* ENH: Simplify arrayfunction_override.c further
Remove cleanup label from array_implementation_c_array_function,
simplifying the code. Fix unitialized variable warning in
array_implementation_array_function_internal.
* DOC: Use string replacement for `like=` documentation
Avoid repeating the full text for the `like=` argument by storing it as
a variable and using `replace` on each docstring.
* DOC: Update `like=` docstring
* TST: Test like= with array not implementing __array_function__
* TST: Add missing asanyarray to TestArrayLike
* ENH: Use helper function for like= dispatching
Avoid dispatching like= from Python implementation functions to improve
their performance. This is achieved by only calling a dispatcher
function when like is passed by the users.
* ENH: Rename array_function_dispatch kwarg to public_api
* BUG: Add accidentally removed decorator for np.eye back
* DOC: Add set_array_function_like_doc function
The function keeps Python files cleaner and resolve errors when __doc__
is not defined due to PYTHONOPTIMIZE or -OO .
* DOC: Add mention to like= kwarg being experimental
* TST: Test like= with not implemented downstream function
* DOC: Fix like= docstring reference to NEP 35.
* ENH: Prevent silent errors if public_api is not callable
* ENH: Make set_array_function_like_doc a decorator
* ENH: Simplify `_*_with_like` functions
* BUG: Fix multiple `like=` dispatching in `require`
* MAINT: Remove now unused public_api from array_function_dispatch
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
|
| | |
|
|\ \
| | |
| | | |
MAINT: Change handling of the expired financial functions.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
In a previous commit, the expired financial functions were removed
from NumPy, and code was added to __init__.py using the module
__getattr__ to raise a customized AttributeError on any attempt to
reference the expired names in the numpy namespace.
That change broke released versions astropy, which has code that
imports the financial functions. astropy never calls the functions,
so they never saw the deprecation warnings that have been in place
since numpy 1.18. This means that attempting to use a released
version of astropy with numpy 1.20 will cause astropy to crash
with the custom AttributeError.
In this commit, instead of raising an exception when one of the
expired names is referenced, a warning is generated. If the
function is *called*, an exception is raised.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* MAINT: chain type error line 303 arraysetops.py
* MAINT: chain axis error line 281 arraysetops.py
* Revert "MAINT: chain axis error line 281 arraysetops.py"
This reverts commit f6e1f544bebb7e5346cb83bdac9756be6ee9f4f6.
* MAINT: chain axis error line 281 arraysetops.py to be from None
|
|/
|
|
| |
Fix spacing that produced incorrect rendering
|
|\
| |
| | |
MAINT: Revert boolean casting back to elementwise comparisons in `trim_zeros`
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| | |
Fix bug caused by typo and added tests
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As explained in NEP 32, the financial functions are to be removed
from version 1.20.
They are now replaced with module level `__getattr__` to give a useful
error message for those surprised by the `AttributeError`.
This only works for Python 3.7+, but it is expected that by the 1.20 release
Python 3.6 will not be supported.
|
|/
|
|
| |
* BUG, API: Raise error on complex input to np.i0
|
|
|
| |
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
|
|
|
| |
Follow up to [this commit](https://github.com/numpy/numpy/commit/36f71788620bb17d123669cf03f086fb2b87b3a8), which missed the second pronoun in this sentence.
|
|
|
|
|
|
| |
The docstring now says what to expect if you call
intersect1d(assume_unique=True) but pass in non-unique data.
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Added a benchmark for `trim_zeros()`
* Improve the performance of `np.trim_zeros()`
* Increase the variety of the tests
Fall back to the old `np.trim_zeros()` implementation if an exception is encountered.
Emit a `DeprecationWarning` in such case.
* DEP,REL: Added a deprecation release note
|
|
|
|
|
| |
* DOC: update val to be scalar or array like optional closes #16901
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
|
|\
| |
| | |
TST: Add pypy win32 CI testing.
|
| | |
|
| | |
|
|/
|
|
|
| |
* update numpy/lib/arraypad.py with appropriate chain exception
Co-authored-by: Noman Arshad <noman.arshad@northbaysolutions.com>
|
|\
| |
| | |
BUG: fix mgrid output for lower precision float inputs
|
| | |
|
| |
| |
| | |
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
|
| | |
|
| |
| |
| |
| |
| |
| | |
Floats besides float64 were being coerced to integers
and complex step sizes for the index trick classes
would fail for complex64 input. Fixes #16466
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| | |
ENH: added edge keyword argument to digitize
added test
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
BadZipFile (#15604)
Previously if you gave an invalid zip file to NpzFile, zipfile_factory would raise BadZipFile and NpzFile.__exit__ would be called, which accessed members which had not yet been set, leading to a confusing second exception like this:
zipfile.BadZipFile: File is not a zip file
Exception ignored in: <function NpzFile.__del__ at 0x9b8ef0>
Traceback (most recent call last):
File "numpy/lib/npyio.py", line 230, in __del__
self.close()
File "numpy/lib/npyio.py", line 221, in close
if self.zip is not None:
AttributeError: 'NpzFile' object has no attribute 'zip'
This change makes __exit__ safe even when __init__ did not complete.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Since #15893, test_large_zip's actual test is run in a child process,
so when this test raises a MemoryError exception, the exception is
lost and the @requires_memory decorator can't catch it to return
an xfail.
This commit uses a boolean variable in shared memory to flag if
the exception was raised, and in that case, re-raise it in the
parent process.
Fixes #16889
|
| |
| |
| |
| |
| | |
* MAINT: Remove Duplicated Code (function extract rmap)
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
|
| |
| |
| |
| |
| | |
Invalide kwarg to imshow causes failures in the plot directive
for docs builds using MPL > v3.3
|
| |
| |
| |
| |
| | |
Edited the documentation of polyfit.
The scaling factor of the covariance matrix in the description was erroneous, the correct form is chi2/dof.
The code already used this correct scaling, just the description needed to be updated.
|
| |
| |
| |
| |
| |
| |
| | |
(#16811)
* DOC: update parameter choices for asarray, asarray_contiguous, asarray_chkfinite converters
Co-authored-by: sun <sun@vosdbt.org>
|
|/ |
|
| |
|
|
|
|
|
|
| |
* adding documentation on passing dimensions to
ndindex as a tuple
Co-authored-by: sun <sun@vosdbt.org>
|
|\
| |
| | |
DOC: Add transition note to all lib/poly functions
|
| |
| |
| |
| |
| |
| | |
Adds a `.. note::` right after the description to all functions/classes
from the numpy.lib.polynomial module notifying the user that the
numpy.polynomial package is preferred.
|
| |
| |
| | |
DOC: fixes to capitalization and header lines
|