Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Nov 21, 2022
1 parent f4b52da commit db3a86f
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 69 deletions.
20 changes: 11 additions & 9 deletions src/awkward/operations/ak_drop_none.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def drop_none(array, axis=None, highlevel=True, behavior=None):
Args:
array: Data in which to remove Nones.
axis (None or int): If None, the operation drops Nones at all levels of
nesting, returning an array of the same dimension, but without Nones.
Otherwise, it drops Nones at a specified depth.
The outermost dimension is `0`, followed by `1`, etc.,
and negative values count backward from the innermost: `-1` is the
nesting, returning an array of the same dimension, but without Nones.
Otherwise, it drops Nones at a specified depth.
The outermost dimension is `0`, followed by `1`, etc.,
and negative values count backward from the innermost: `-1` is the
innermost dimension, `-2` is the next level up, etc.
highlevel (bool): If True, return an #ak.Array; otherwise, return
a low-level #ak.contents.Content subclass.
Expand Down Expand Up @@ -46,7 +46,7 @@ def drop_none(array, axis=None, highlevel=True, behavior=None):

def _impl(array, axis, highlevel, behavior):
layout = ak.operations.to_layout(array, allow_record=False, allow_other=False)

if layout.is_NumpyType:
return array

Expand All @@ -59,13 +59,15 @@ def maybe_drop_none(layout):
if axis is None:
if layout.is_OptionType:
return layout.project()

def action(layout, continuation, **kwargs):
return maybe_drop_none(continuation())
return maybe_drop_none(continuation())

else:

def action(layout, depth, depth_context, **kwargs):
posaxis = layout.axis_wrap_if_negative(depth_context["posaxis"])

if posaxis == depth and layout.is_OptionType:
return layout.project()
elif posaxis == depth and layout.is_ListType:
Expand All @@ -77,4 +79,4 @@ def action(layout, depth, depth_context, **kwargs):
depth_context = {"posaxis": axis}
out = layout.recursively_apply(action, behavior, depth_context)

return ak._util.wrap(out, behavior, highlevel)
return ak._util.wrap(out, behavior, highlevel)
13 changes: 6 additions & 7 deletions src/cpu-kernels/awkward_ListOffsetArray_drop_none_indexes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ ERROR awkward_ListOffsetArray_drop_none_indexes(
T* tooffsets,
const C* noneindexes,
const T* fromoffsets,
int64_t length_offsets,
int64_t length_offsets,
int64_t length_indexes) {
T nr_of_nones = 0;
int64_t offset1 = 0;
int64_t offset2 = 0;

for (int64_t i = 0; i < length_offsets; i++) {
offset2 = fromoffsets[i];
for (int j = offset1; j < offset2; j++) {
Expand All @@ -32,27 +32,26 @@ ERROR awkward_ListOffsetArray_drop_none_indexes_64(
int64_t* tooffsets,
const int64_t* noneindexes,
const int64_t* fromoffsets,
int64_t length_offsets,
int64_t length_offsets,
int64_t length_indexes) {
return awkward_ListOffsetArray_drop_none_indexes<int64_t, int64_t>(
tooffsets,
noneindexes,
fromoffsets,
length_offsets,
length_offsets,
length_indexes);
}

ERROR awkward_ListOffsetArray_drop_none_indexes_32(
int64_t* tooffsets,
const int32_t* noneindexes,
const int64_t* fromoffsets,
int64_t length_offsets,
int64_t length_offsets,
int64_t length_indexes) {
return awkward_ListOffsetArray_drop_none_indexes<int64_t, int32_t>(
tooffsets,
noneindexes,
fromoffsets,
length_offsets,
length_offsets,
length_indexes);
}

Loading

0 comments on commit db3a86f

Please sign in to comment.