Skip to content
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

Support the array_equals / array_equiv numpy function #4503

Open
antonincms opened this issue Aug 30, 2019 · 1 comment
Open

Support the array_equals / array_equiv numpy function #4503

antonincms opened this issue Aug 30, 2019 · 1 comment

Comments

@antonincms
Copy link

Feature request

Hello,

I'm trying to use numba inside of a personnal project, since I does a lot of numpy on very big arrays and python doesn't like that at all, even with numpy arrays. But I'm surprised and annoyed by the lack of several basic functions : array_equals, array_equiv.

For example :

def _get_color_bitmask2(color: np.ndarray, image: np.ndarray) -> np.ndarray:
    bitmask = []
    for line_idx in range(image.size):
        linemask = []
        for pixel_idx in range(image[line_idx].size):
            linemask.append(np.array_equal(image[line_idx,pixel_idx],color))
        bitmask.append(linemask)
    return np.array(bitmask)

won't work, Use of unsupported NumPy function 'numpy.array_equal' or unsupported use of the function. where this

def _get_color_bitmask2(color: np.ndarray, image: np.ndarray) -> np.ndarray:
    bitmask = []
    for line_idx in range(image.size):
        linemask = []
        for pixel_idx in range(image[line_idx].size):
            linemask.append(np.all(image[line_idx,pixel_idx]==color))
        bitmask.append(linemask)
    return np.array(bitmask)

will, even if the latest is a lot less safer. You should maybe consider binding or implementing them.

Thank you 👍

@stuartarchibald
Copy link
Contributor

Thanks for the report. Numba supports a large number of commonly used NumPy functions, http://numba.pydata.org/numba-doc/dev/reference/numpysupported.html, and this set is continuously growing. The unsupported function list is in this issue: #4074 and indeed array_equals and array_equiv are on there. If these functions are important to you, contributions are very welcome.

The use of Numba's extension API @overload decorator is strongly recommended for this task. A guide to using @overload is here and API documentation is here.

It may be useful to take a look at examples of pull requests adding support for a NumPy function that have already been done if guidance is needed... here's a couple:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants