| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
As noted by Kyle Sunden, this was deprecated and has been removed,
using the method is the correct way of doing it in newer matplotlib.
Closes gh-23209
Co-authored-by: Kyle Sunden <ksunden@users.noreply.github.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This moves dispatching for `__array_function__` into a C-wrapper. This
helps speed for multiple reasons:
* Avoids one additional dispatching function call to C
* Avoids the use of `*args, **kwargs` which is slower.
* For simple NumPy calls we can stay in the faster "vectorcall" world
This speeds up things generally a little, but can speed things up a lot
when keyword arguments are used on lightweight functions, for example::
np.can_cast(arr, dtype, casting="same_kind")
is more than twice as fast with this.
There is one alternative in principle to get best speed: We could inline
the "relevant argument"/dispatcher extraction. That changes behavior in
an acceptable but larger way (passes default arguments).
Unless the C-entry point seems unwanted, this should be a decent step
in the right direction even if we want to do that eventually, though.
Closes gh-20790
Closes gh-18547 (although not quite sure why)
|
|
|
|
|
|
|
|
|
|
|
| |
* DOC: #22266 Add examples for tri[lu]_indices_from()
* DOC: see also for tri[lu]_indices_from()
* DOC: Fix triu_indices_from example and minor updates.
* incides -> indices
* Update wording surrounding .
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
|
|
|
|
|
|
| |
The normed keyword argument has been deprecated for a long time.
This removes it, replacing its position with the new density
argument.
|
|
|
|
|
|
| |
Closes gh-9982.
(Plus a few small PEP 8 fixes.)
|
|
|
|
|
|
|
| |
Improves exception message when inputs have different shapes.
Closes gh-20050
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
|
| |
|
|
|
|
|
| |
* DOC: added explanation about tril/triu n-dimensional functionality.
Additional examples are also provided. Closes gh-10310
|
| |
|
|
|
|
|
|
| |
Clarify necessity of H.T in code example. Resolves issue #18929
Co-authored-by: Laura Kopf <60775505+lkopf@users.noreply.github.com>>
|
| |
|
|
|
|
| |
platforms
|
| |
|
| |
|
|
|
| |
nonzero is slow. Use np.indices and np.broadcast_to to speed it up.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
| |
Invalide kwarg to imshow causes failures in the plot directive
for docs builds using MPL > v3.3
|
|
|
|
|
| |
Replace "matrix" with "array" to avoid confusion
re: np.matrix. Consistent with other np.tri\* functions.
|
|
|
|
|
| |
As numpy is Python 3 only, these import statements are now unnecessary
and don't alter runtime behavior.
|
|
|
|
| |
* Remove unused imports.
|
| |
|
|
|
|
| |
Now with tests....
|
| |
|
|
|
|
| |
fixes GH-13728
|
|
|
|
|
|
| |
* as requested by review in gh-12634,
the vast majority of docstring matplotlib
imports can be simplified to a single line
|
|
|
|
|
|
|
| |
* there is no longer any usage of "agg"
backend switching in our docstrings because
this backend is already activated in
the refguide_check machinery
|
|
|
|
|
|
|
|
| |
* ported the refguide_check module from SciPy for usage
in NumPy docstring execution/ verification; added the
refguide_check run to Azure Mac OS CI
* adjusted NumPy docstrings such that refguide_check passes
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes GH-12271
Tests verify that everything in ``dir(numpy)`` either has ``__module__`` set to
``'numpy'``, or appears in an explicit whitelist of undocumented functions and
exported bulitins. These should eventually be documented or removed.
I also identified a handful of functions for which I had accidentally not setup
dispatch for with ``__array_function__`` before, because they were listed under
"ndarray methods" in ``_add_newdocs.py``. I guess that should be a lesson in
trusting code comments :).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ENH: __array_function__ support for np.lib, part 2
xref GH12028
np.lib.npyio through np.lib.ufunclike
* Fix failures in numpy/core/tests/test_overrides.py
* CLN: handle depreaction in dispatchers for np.lib.ufunclike
* CLN: fewer dispatchers in lib.twodim_base
* CLN: fewer dispatchers in lib.shape_base
* CLN: more dispatcher consolidation
* BUG: fix test failure
* Use all method instead of function in assert_equal
* DOC: indicate n is array_like in scimath.logn
* MAINT: updates per review
* MAINT: more conservative changes in assert_array_equal
* MAINT: add back in comment
* MAINT: casting tweaks in assert_array_equal
* MAINT: fixes and tests for assert_array_equal on subclasses
|
|
|
|
| |
Fixes gh-4371
|
|
|
|
|
|
|
|
|
|
| |
Previously a fuzzy rounded comparison was used for the rightmost bin of histogramdd.
It's not clear why this was done, and it resulted in surprising behavior.
This also removes the restriction that bin edges must be floats, and allows integer arrays to be passed (and returned)
Fixes gh-10864
|
|
|
| |
Fixes #9995
|
|
|
|
| |
nonzero is a clearer spelling
|
|
|
|
|
| |
If nx and ny are the bin counts (as stated in the bins argument's text), then the return H has indeed shape (nx, ny). However, the returned xedges and yedges will then have shape (nx+1,) and (ny+1,) respectively.
Fixes #8979
|
|
|
|
| |
Closes #8115.
|
| |
|
| |
|
| |
|
|
|
|
| |
Closes gh-6863.
|
|
|
|
| |
Also, added unittest for [int, array] combination arguments
|
|
|
|
|
|
|
|
| |
This is an ugly hack to preserve backwards compatibility for code
that uses matrices. It is needed since both diag and diagonal have
been changed to preserve subtypes otherwise.
Note that a.diagonal() still returns matrices when a is a matrix.
|
| |
|
|
|
|
|
|
|
| |
If x is a matrix, np.diag(x) and np.diagonal(x) now return matrices
instead of arrays. Both of these cause x.diagonal() to be called.
That means they return row vectors (just like x.flatten(), x.ravel(),
x.cumprod(), etc.)
|
|\
| |
| | |
Charris pep8 numpy lib
|
| |
| |
| |
| |
| |
| | |
Some of those problems look like potential coding errors. In those
cases a Fixme comment was made and the offending code, usually an
unused variable, was commented out.
|
| | |
|
|/
|
|
|
| |
Replaces the current method to zero items, from multiplication to
using `np.where`.
|
|
|
|
| |
Replace an explicit type check with setting `copy=False` in call to `astype`.
|
|
|
|
|
| |
Speeds calculation up by ~3x for 100x100 matrices, and by ~45x for
1000x1000
|