-
Notifications
You must be signed in to change notification settings - Fork 89
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
Add a drop_none()
#832
Comments
This is harder than I thought it might be. I'll have to get back to it. |
You know, if your goal is plotting, you can ak.flatten the array. That will get rid of the missing values in addition to getting rid of the lists, which you'd have to do for a histogramming function, anyway. |
>>> ak.flatten(ak.Array([[1], [2, None]]))
<Array [1, 2, None] type='3 * ?int64'> |
Ah, so >>> ak.flatten(ak.Array([[[0]], None, [[1], None], [[2, None]]]), axis=1)
<Array [[0], [1], None, [2, None]] type='4 * option[var * ?int64]'>
>>> ak.flatten(ak.Array([[[0]], None, [[1], None], [[2, None]]]), axis=2)
<Array [[0], None, [1], [2, None]] type='4 * option[var * ?int64]'> Other than >>> ak.flatten(ak.Array([[[0]], None, [[1], None], [[2, None]]]), axis=0)
<Array [[[0]], [[1], None], [[2, None]]] type='3 * var * option[var * ?int64]'> It looks like >>> ak.flatten(ak.Array([[[0]], None, [[1], None], [[2, None]]]), axis=None)
<Array [0, 1, 2] type='3 * int64'> I was actually assuming that |
I'm rethinking it because you're not the first person to say they expected the default It would be hard to change—a parameter default isn't the sort of thing that can go through a deprecation cycle, unless we change the name of "flatten" (and that's already a good name). This would be a good thing to ask about as a Discussion, under the "deprecation" category: whether we should change the default |
Actually, there was an idea about that: the name |
@jpivarski weighing in here - when reading jagged branches of a tree that contain 0 or more entries, I noticed that I was always |
Completed by #1904. |
Originally mentioned in #490 (comment). Mainly all I'm looking for is a nice shortcut for
array[~ak.is_none(array, axis=-1)]
(I think this would cover any of my own use cases), although the default behavior (axis=None
?) for adrop_none
function should probably be to do this on every axis. A particularly important case for this function is that functions likenp.histogram()
andplt.hist()
do not handle masked arrays properly (numpy/numpy#10019).The text was updated successfully, but these errors were encountered: