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
np.trim_zeros #5543
np.trim_zeros #5543
Conversation
Thanks very much for the PR, I've queued it for review. |
def impl(a, trim='fb'): | ||
a_ = np.asarray(a) | ||
first = 0 | ||
if 'f' in trim: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From this line it seems the numpy implementation works with upper and lower case letters for trim
>>> np.trim_zeros(np.array([0, 1, 2, 3, 0, 0]), trim="FB")
array([1, 2, 3])
numba/tests/test_np_functions.py
Outdated
yield np.zeros(1) | ||
yield np.array([1, 2, 3]) | ||
yield np.array([0, 1, 2, 3]) | ||
yield np.array([0, 1, 2, 0, 0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we test arrays that have non-zero values that are not ints (e.g. np.array([0., 1., 2., np.nan, 0.])
)?
We could also test other data types that work with the numpy version (e.g. np.array(["Hello", "world"])
).
yield np.array([0, 1, 2, 0, 0]) | ||
|
||
pyfunc = np_trim_zeros | ||
cfunc = jit(nopython=True)(pyfunc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also test when trim != "fb"
?
Nice work! You'll probably want to update the numpy supported features documentation as part of your PR as well. |
I added support for both lower and upper case arguments and some new test cases as you mentioned. |
Hi, i'm working on a project that uses trim_zeros and numba, do you know why this wasn't added? |
@ionikha Thanks for the ping, I think it just fell by the wayside and never got a review from a maintainer (even though @EPronovost very kindly gave it a review). I've added this to the agenda for the dev meeting tomorrow to see if we can kickstart it. |
Assignment from triage meeting: @gmarkall to merge |
@gmarkall, if needed, we can switch and I can merge |
@gmarkall @guilhermeleobas -- can I ask for an update here? What is the status of this? |
I'll put this on my near-term todo list so that it can get done. |
Is replaced by #9074 |
Add support for
np.trim_zeros
. It currently does not handle nested list or tuple input well.#4074