-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
meta-issue: All NumPy functions with no implementation #4074
Comments
Great that you've prepared this list, it still seems rather long :) I'm not sure that each of the functions in this list is worthy of attention, and I think some of them need to be weeded out. For example all I also had a feeling that the majority of numpy core developers would be happy to see financially-related functions outside of numpy. Perhaps this is my very subjective opinion. |
Yes, this is a good point. By definition, this list will mostly have rarely used NumPy functions otherwise they would have likely been contributed already. Before picking one up, it is worth doing some web searching to see if people use it. |
@godaygo thanks for your feedback. Indeed some of these functions are less critical than others. This list is written in part for the purposes of encouraging users to have a go at contributing functions to Numba and are a good gateway to being able to help out with more complicated issues. |
As someone currently on extending a Numpy function for Numba (my second), I can say that it is a great exercise to learn more about how Numba works. I encourage everyone wanting to understand Numba, anyone looking to be a power user or dev, to try to implement a function or two. |
Broadly, it is something that would be nice to figure out, but it is a hard problem since NumPy's implementations were never designed to be consumed by something like Numba. They are a mixture of Python code (frequently written in a style that Numba has difficulty statically typing) and private C code (which Numba should not call since they aren't public, stable APIs). Numba has the same problem with CPython, where we have to basically duplicate functionality because there is no C API to the thing we need to access (like Unicode character tables, or random number generators). This is the pragmatic cost of making Numba work today, but it is not ideal. Understandably, most projects would view providing direct C access to these various algorithms as being out of scope for their project. I'm not sure what can be done here, but it is something we think about. A few years ago at SciPy, there was discussion of whether more low-level NumPy operations could be implemented in a way that could be consumed by JITs (like Numba and PyPy), but no progress has been made since then, AFAIK. |
It looks like |
@guilhermeleobas thanks, done |
Hi @stuartarchibald, can you cross |
Hi @stuartarchibald, I do not think one needs to write code for numpy constants. They work just fine on jitted functions: from numba import njit
import numpy as np
@njit
def foo():
return (np.pi, np.infty, np.euler_gamma)
foo() |
Thanks @guilhermeleobas, updated. |
Adding |
Hi, I guess that implementing >>> import numpy as np
>>> import numba
>>> np.newaxis is None
True
>>> @numba.njit
>>> def f(x):
>>> return x[:, None]
>>> a = np.arange(4)
>>> f(a)
No implementation of function Function(<built-in function getitem>) found for signature:
>>> getitem(array(int64, 1d, C), Tuple(slice<a:b>, none))
There are 22 candidate implementations:
- Of which 20 did not match due to:
Overload of function 'getitem': File: <numerous>: Line N/A.
With argument(s): '(array(int64, 1d, C), Tuple(slice<a:b>, none))':
No match.
- Of which 2 did not match due to:
Overload in function 'GetItemBuffer.generic': File: numba/core/typing/arraydecl.py: Line 162.
With argument(s): '(array(int64, 1d, C), Tuple(slice<a:b>, none))':
Rejected as the implementation raised a specific error:
TypeError: unsupported array index type none in Tuple(slice<a:b>, none)
raised from /home/braniii/anaconda3/lib/python3.8/site-packages/numba/core/typing/arraydecl.py:68
During: typing of intrinsic-call at <stdin> (3)
During: typing of static-get-item at <stdin> (3) |
np.allclose, np.argwhere, np.cumprod (I guess that is meant by np.cumproduct?), np.isclose, np.prod (I guess it's meant by np.product?) are all implemented in arraymath.py |
Thanks @Tobi995, I've updated the list. |
I think |
|
Thank you for the update. I have edited the issue accordingly and |
|
Thanks, @KrisMinchev. I have edited the list accordingly |
Is there an alternative to |
|
I hope I have not missed, but I think there no mention of |
@kmaitreys, thanks. I've updated the list to include |
I'd like to add support for |
Hi @jaredjeya, feel free to fork #4677 and create a new PR. |
Below are lists of feasible but not yet implemented NumPy functions... ideal for first time contributors. If you would like to contribute a function, please first check the open "Pull Requests" to make sure someone else isn't already working on the one you chose! If the check-box next to the function is checked it means the function is already done...
As a new contributor, some instructions for getting set up for development are here and are a great place to start.
It should be possible to write these functions using the
numba.extending.overload
functionality, they are of varying difficulty. A guide to using@overload
is here:[ ]deprecated, see Isnp.alen
np.alen
in use/needed? numpy/numpy#14155np.allclose
np.alltrue
np.append
np.argpartition
np.argwhere
np.around
np.array_equal
np.array_split
np.asanyarray
np.asarray_chkfinite
np.asfarray
[ ]deprecated, see DEP: remove deprecatednp.asscalar
alen
andasscalar
functions numpy/numpy#20414np.atleast_1d
np.atleast_2d
np.atleast_3d
np.bartlett
np.binary_repr
np.bincount
np.blackman
np.compress
np.count_nonzero
np.cross
np.cumproduct
(just needs wiring)np.diag_indices
np.diag_indices_from
np.diagflat
np.euler_gamma
(constant)deprecated, see DEP: Deprecate fastCopyAndTranspose numpy/numpy#22313np.fastCopyAndTranspose
np.floatnonzero
np.fliplr
np.flipud
[ ]deprecated see NumPy's NEP-0032.np.fv
np.geomspace
np.hamming
np.hanning
np.hsplit
np.i0
np.in1d
np.indices
np.infty
(constant)np.inner
np.intersect1d
[ ]deprecated see NumPy's NEP-0032.np.ipmt
[ ]deprecated see NumPy's NEP-0032.np.irr
np.isclose
np.iscomplex
np.iscomplexobj
np.isfortran
np.isin
np.isnat
np.isneginf
np.isposinf
np.isreal
np.isrealobj
np.isscalar
np.kaiser
np.little_endian
np.logspace
np.meshgrid
[ ]deprecated see NumPy's NEP-0032.np.mirr
[ ]deprecated, see DEP: Proposal to deprecate thenp.msort
(largely wiring!)msort
convenience function numpy/numpy#22456np.nan_to_num
np.nanargmax
np.nanargmin
np.ndim
(just needs wiring)np.newaxis
(just needs wiring)[ ]deprecated see NumPy's NEP-0032.np.nper
[ ]deprecated see NumPy's NEP-0032.np.npv
np.place
[ ]deprecated see NumPy's NEP-0032.np.pmt
np.poly
np.polyadd
np.polyder
np.polydiv
np.polyint
np.polymul
np.polysub
np.polyval
[ ]deprecated see NumPy's NEP-0032.np.ppmt
np.product
(just needs wiring)np.put
np.putmask
[ ]deprecated see NumPy's NEP-0032.np.pv
[ ]deprecated see NumPy's NEP-0032.np.rate
np.resize
np.rot90
np.row_stack
np.select
np.setdiff1d
np.setxor1d
np.size
(mostly wiring)(deprecated with 1.25np.sometrue
(just needs wiring)np.sortcomplex
np.split
np.tril_indices
np.tril_indices_from
np.triu_indices
np.triu_indices_from
np.trim_zeros
np.union1d
np.unravel_index
np.unwrap
np.vsplit
It is also seemingly possible to write these functions with
numba.extending.overload
but they are harder/it is less easy to determined difficultly in implementing these:np.choose
np.common_type
np.copyto
np.dsplit
np.dstack
np.fix
np.gradient
np.histogram2d
np.histogramdd
np.insert
np.ix_
np.lexsort
np.mask_indices
np.maximum_sctype
np.nested_iters
np.pad
np.piecewise
np.polyfit
np.put_along_axis
np.squeeze
np.swapaxis
np.tensordor
These are likely to need lower level work:
np.broadcast_to
np.broadcast_arrays
np.byte_bounds
np.packbits
np.unpackbits
The text was updated successfully, but these errors were encountered: