How to remove the question mark in type after apply "ak.pad_none" to a full-value array? #3046
-
Hi developers, I want to keep a bunch of record arrays to have almost the same shape: # In a jupyter notebook
records = ak.Array([[1, 2], [], [1]])
ak.to_regular(ak.pad_none(records, 3), None)
The "3 * 3" part is the shape that I want to keep an array in. The "?int64" is also easy to understand: there maybe None type in this array. However, when the array is full of value or is exactly what I want, records = ak.Array([[1, 2, 3], [1, 2, 3], [1, 2, 3]])
ak.to_regular(ak.pad_none(records, 3), None)
Is there anyway to remove that "?" to indicate this array has exactly records of expected shape like "type: 3 * 3 * int64"? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Having If you just want to drop the option type, because you know that the array does not contain any |
Beta Was this translation helpful? Give feedback.
Having
pad_none
produce a different type according to the list-lengths of the array would introduce a data dependence on the operation result. That's not something we want to happen, as we rely on the lack of data dependence to be able to predict the result of Awkward operations ahead of time (used by https://github.com/dask-contrib/dask-awkward).If you just want to drop the option type, because you know that the array does not contain any
None
s, then you can useak.drop_none(..., axis=-1)
. If you don't know whether your array will containNone
s then you need to useak.fill_none
, and choose the appropriate fill value.