Skip to content

Commit

Permalink
refactor: drop default args
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed Oct 30, 2023
1 parent a387e2c commit 61416ef
Show file tree
Hide file tree
Showing 65 changed files with 74 additions and 122 deletions.
4 changes: 2 additions & 2 deletions src/awkward/_connect/numba/arrayview.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class ArrayView:
def fromarray(cls, array):
behavior = behavior_of(array)
layout = ak.operations.to_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)

return ArrayView(
Expand Down Expand Up @@ -578,7 +578,7 @@ class RecordView:
def fromrecord(cls, record):
behavior = behavior_of(record)
layout = ak.operations.to_layout(
record, allow_record=True, allow_unknown=False, primitive_policy="error"
record, allow_record=True, primitive_policy="error"
)
assert isinstance(layout, ak.record.Record)
arraylayout = layout.array
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _impl(array, axis, keepdims, mask_identity, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
reducer = ak._reducers.All()

Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_any.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _impl(array, axis, keepdims, mask_identity, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
reducer = ak._reducers.Any()

Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_argcombinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _impl(
else:
layout = ak._do.local_index(
ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
),
axis,
)
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_argmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def _impl(array, axis, keepdims, mask_identity, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
reducer = ak._reducers.ArgMax()

Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_argmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def _impl(array, axis, keepdims, mask_identity, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)

reducer = ak._reducers.ArgMin()
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_argsort.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _impl(array, axis, ascending, stable, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
out = ak._do.argsort(layout, axis, ascending, stable)
return ctx.wrap_layout(out, highlevel=highlevel)
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def action(layout, **kwargs):
return None

layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
ak._do.recursively_apply(layout, action, behavior=behavior)

Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_combinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def _impl(
parameters = {**parameters, "__record__": with_name}

layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
out = ak._do.combinations(
layout,
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_concatenate.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _impl(arrays, axis, mergebool, highlevel, behavior, attrs):
):
# Convert the array to a layout object
content = ak.operations.to_layout(
arrays, allow_record=False, allow_unknown=False, primitive_policy="error"
arrays, allow_record=False, primitive_policy="error"
)
# Only handle concatenation along `axis=0`
# Let ambiguous depth arrays fall through
Expand Down
8 changes: 2 additions & 6 deletions src/awkward/operations/ak_corr.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,8 @@ def _impl(x, y, weight, axis, keepdims, mask_identity, highlevel, behavior, attr
axis = regularize_axis(axis)

x_layout, y_layout, weight_layout = ctx.finalize(
ctx.unwrap_layout(
x, allow_record=False, allow_unknown=False, primitive_policy="error"
),
ctx.unwrap_layout(
y, allow_record=False, allow_unknown=False, primitive_policy="error"
),
ctx.unwrap_layout(x, allow_record=False, primitive_policy="error"),
ctx.unwrap_layout(y, allow_record=False, primitive_policy="error"),
ctx.unwrap_layout(
weight,
allow_record=False,
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def _impl(array, axis, keepdims, mask_identity, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
reducer = ak._reducers.Count()

Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_count_nonzero.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _impl(array, axis, keepdims, mask_identity, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
reducer = ak._reducers.CountNonzero()

Expand Down
8 changes: 2 additions & 6 deletions src/awkward/operations/ak_covar.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,8 @@ def _impl(x, y, weight, axis, keepdims, mask_identity, highlevel, behavior, attr
axis = regularize_axis(axis)

x_layout, y_layout, weight_layout = ctx.finalize(
ctx.unwrap_layout(
x, allow_record=False, allow_unknown=False, primitive_policy="error"
),
ctx.unwrap_layout(
y, allow_record=False, allow_unknown=False, primitive_policy="error"
),
ctx.unwrap_layout(x, allow_record=False, primitive_policy="error"),
ctx.unwrap_layout(y, allow_record=False, primitive_policy="error"),
ctx.unwrap_layout(
weight,
allow_record=False,
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_drop_none.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _impl(array, axis, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)

if axis is None:
Expand Down
4 changes: 1 addition & 3 deletions src/awkward/operations/ak_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,5 @@ def fields(array):


def _impl(array):
layout = ak.operations.to_layout(
array, allow_record=True, allow_unknown=False, primitive_policy="error"
)
layout = ak.operations.to_layout(array, allow_record=True, primitive_policy="error")
return layout.fields.copy()
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_flatten.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def _impl(array, axis, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)

if axis is None:
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_from_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def action(layout, **kwargs):
return None

layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
out = ak._do.recursively_apply(layout, action)
return ctx.wrap_layout(out, highlevel=highlevel, allow_other=True)
4 changes: 1 addition & 3 deletions src/awkward/operations/ak_full_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ def _impl(array, fill_value, highlevel, behavior, dtype, including_unknown, attr
array, fill_value, behavior=behavior, attrs=attrs
)

layout = ak.operations.to_layout(
array, allow_record=True, allow_unknown=False, primitive_policy="error"
)
layout = ak.operations.to_layout(array, allow_record=True, primitive_policy="error")

if dtype is not None:
# In the case of strings and byte strings,
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_is_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ def is_categorical(array):

def _impl(array):
layout = ak.operations.to_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
return layout.purelist_parameter("__array__") == "categorical"
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_is_none.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _impl(array, axis, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)

if not is_integer(axis):
Expand Down
8 changes: 2 additions & 6 deletions src/awkward/operations/ak_linear_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,8 @@ def _impl(x, y, weight, axis, keepdims, mask_identity, highlevel, behavior, attr
axis = regularize_axis(axis)

x_layout, y_layout, weight_layout = ctx.finalize(
ctx.unwrap_layout(
x, allow_record=False, allow_unknown=False, primitive_policy="error"
),
ctx.unwrap_layout(
y, allow_record=False, allow_unknown=False, primitive_policy="error"
),
ctx.unwrap_layout(x, allow_record=False, primitive_policy="error"),
ctx.unwrap_layout(y, allow_record=False, primitive_policy="error"),
ctx.unwrap_layout(
weight,
allow_record=False,
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_local_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _impl(array, axis, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
out = ak._do.local_index(layout, axis)
return ctx.wrap_layout(out, highlevel=highlevel)
8 changes: 2 additions & 6 deletions src/awkward/operations/ak_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,8 @@ def action(inputs, backend, **kwargs):
return None

layouts = ctx.finalize(
ctx.unwrap_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
),
ctx.unwrap_layout(
mask, allow_record=False, allow_unknown=False, primitive_policy="error"
),
ctx.unwrap_layout(array, allow_record=False, primitive_policy="error"),
ctx.unwrap_layout(mask, allow_record=False, primitive_policy="error"),
)

out = ak._broadcasting.broadcast_and_apply(
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_max.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def _impl(array, axis, keepdims, initial, mask_identity, highlevel, behavior, at

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
reducer = ak._reducers.Max(initial)

Expand Down
4 changes: 1 addition & 3 deletions src/awkward/operations/ak_mean.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ def _impl(x, weight, axis, keepdims, mask_identity, highlevel, behavior, attrs):
axis = regularize_axis(axis)

x_layout, weight_layout = ctx.finalize(
ctx.unwrap_layout(
x, allow_record=False, allow_unknown=False, primitive_policy="error"
),
ctx.unwrap_layout(x, allow_record=False, primitive_policy="error"),
ctx.unwrap_layout(
weight,
allow_record=False,
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_merge_option_of_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _impl(array, axis, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)

# First, normalise type-invsible "index-of-records" to "record-of-index"
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_merge_union_of_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _impl(array, axis, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)

def invert_record_union(
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_min.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def _impl(array, axis, keepdims, initial, mask_identity, highlevel, behavior, at

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
reducer = ak._reducers.Min(initial)

Expand Down
4 changes: 1 addition & 3 deletions src/awkward/operations/ak_moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ def _impl(x, n, weight, axis, keepdims, mask_identity, highlevel, behavior, attr
axis = regularize_axis(axis)

x_layout, weight_layout = ctx.finalize(
ctx.unwrap_layout(
x, allow_record=False, allow_unknown=False, primitive_policy="error"
),
ctx.unwrap_layout(x, allow_record=False, primitive_policy="error"),
ctx.unwrap_layout(
weight,
allow_record=False,
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_nan_to_none.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def action(layout, continuation, backend, **kwargs):
return None

layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
out = ak._do.recursively_apply(layout, action)
return ctx.wrap_layout(out, highlevel=highlevel)
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_num.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _impl(array, axis, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)

if not is_integer(axis):
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_pad_none.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _impl(array, target, axis, clip, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
out = ak._do.pad_none(layout, target, axis, clip=clip)

Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _impl(array, axis, keepdims, mask_identity, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
reducer = ak._reducers.Prod()

Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_ptp.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _impl(array, axis, keepdims, mask_identity, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)

with np.errstate(invalid="ignore", divide="ignore"):
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_ravel.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def _impl(array, highlevel, behavior, attrs):
ctx = HighLevelContext(behavior=behavior, attrs=attrs)

layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)

out = ak._do.remove_structure(layout, function_name="ak.ravel", drop_nones=False)
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_run_lengths.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def run_lengths(array, *, highlevel=True, behavior=None, attrs=None):
def _impl(array, highlevel, behavior, attrs):
ctx = HighLevelContext(behavior=behavior, attrs=attrs)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)

def lengths_of(data, offsets):
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_singletons.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _impl(array, axis, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)

if not is_integer(axis):
Expand Down
4 changes: 1 addition & 3 deletions src/awkward/operations/ak_softmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ def _impl(x, axis, keepdims, mask_identity, highlevel, behavior, attrs):

axis = regularize_axis(axis)
x = ctx.wrap_layout(
ctx.unwrap_and_finalize_layout(
x, allow_record=False, allow_unknown=False, primitive_policy="error"
)
ctx.unwrap_and_finalize_layout(x, allow_record=False, primitive_policy="error")
)

with np.errstate(invalid="ignore", divide="ignore"):
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _impl(array, axis, ascending, stable, highlevel, behavior, attrs):

axis = regularize_axis(axis)
layout = ctx.unwrap_and_finalize_layout(
array, allow_record=False, allow_unknown=False, primitive_policy="error"
array, allow_record=False, primitive_policy="error"
)
out = ak._do.sort(layout, axis, ascending, stable)
return ctx.wrap_layout(out, highlevel=highlevel)
Expand Down
Loading

0 comments on commit 61416ef

Please sign in to comment.