Skip to content
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

Rename low-level methods to match high-level function names. #1468

Merged
merged 4 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/awkward/_v2/_slicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def prepare_tuple_bool_to_int(item):
and issubclass(item.content.dtype.type, (bool, np.bool_))
):
if item.nplike.known_data or item.nplike.known_shape:
localindex = item.localindex(axis=1)
localindex = item.local_index(axis=1)
nextcontent = localindex.content.data[item.content.data]

cumsum = item.nplike.empty(item.content.data.shape[0] + 1, np.int64)
Expand Down Expand Up @@ -337,7 +337,7 @@ def prepare_tuple_bool_to_int(item):
safeindex.shape[0], np.bool_
)

localindex = item.localindex(axis=1)
localindex = item.local_index(axis=1)

# nextcontent does not include missing values
expanded[isnegative] = False
Expand Down
12 changes: 6 additions & 6 deletions src/awkward/_v2/contents/bitmaskedarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ def mergemany(self, others):
def fillna(self, value):
return self.toIndexedOptionArray64().fillna(value)

def _localindex(self, axis, depth):
return self.toByteMaskedArray()._localindex(axis, depth)
def _local_index(self, axis, depth):
return self.toByteMaskedArray()._local_index(axis, depth)

def numbers_to_type(self, name):
return self.toByteMaskedArray().numbers_to_type(name)
Expand Down Expand Up @@ -501,7 +501,7 @@ def _reduce_next(
keepdims,
)

def _validityerror(self, path):
def _validity_error(self, path):
if self.mask.length * 8 < self.length:
return f'at {path} ("{type(self)}"): len(mask) * 8 < length'
elif self._content.length < self.length:
Expand All @@ -518,16 +518,16 @@ def _validityerror(self, path):
):
return "{0} contains \"{1}\", the operation that made it might have forgotten to call 'simplify_optiontype()'"
else:
return self._content.validityerror(path + ".content")
return self._content.validity_error(path + ".content")

def _nbytes_part(self):
result = self.mask._nbytes_part() + self.content._nbytes_part()
if self.identifier is not None:
result = result + self.identifier._nbytes_part()
return result

def _rpad(self, target, axis, depth, clip):
return self.toByteMaskedArray()._rpad(target, axis, depth, clip)
def _pad_none(self, target, axis, depth, clip):
return self.toByteMaskedArray()._pad_none(target, axis, depth, clip)

def _to_arrow(self, pyarrow, mask_node, validbytes, length, options):
return self.toByteMaskedArray()._to_arrow(
Expand Down
18 changes: 9 additions & 9 deletions src/awkward/_v2/contents/bytemaskedarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,16 +590,16 @@ def mergemany(self, others):
def fillna(self, value):
return self.toIndexedOptionArray64().fillna(value)

def _localindex(self, axis, depth):
def _local_index(self, axis, depth):
posaxis = self.axis_wrap_if_negative(axis)
if posaxis == depth:
return self._localindex_axis0()
return self._local_index_axis0()
else:
numnull = ak._v2.index.Index64.empty(1, self._nplike)
nextcarry, outindex = self._nextcarry_outindex(numnull)

next = self._content._carry(nextcarry, False)
out = next._localindex(posaxis, depth)
out = next._local_index(posaxis, depth)
out2 = ak._v2.contents.indexedoptionarray.IndexedOptionArray(
outindex,
out,
Expand Down Expand Up @@ -855,7 +855,7 @@ def _reduce_next(
)
)

def _validityerror(self, path):
def _validity_error(self, path):
if self._nplike.known_shape and self._content.length < self.mask.length:
return f'at {path} ("{type(self)}"): len(content) < len(mask)'
elif isinstance(
Expand All @@ -870,18 +870,18 @@ def _validityerror(self, path):
):
return "{0} contains \"{1}\", the operation that made it might have forgotten to call 'simplify_optiontype()'"
else:
return self._content.validityerror(path + ".content")
return self._content.validity_error(path + ".content")

def _nbytes_part(self):
result = self.mask._nbytes_part() + self.content._nbytes_part()
if self.identifier is not None:
result = result + self.identifier._nbytes_part()
return result

def _rpad(self, target, axis, depth, clip):
def _pad_none(self, target, axis, depth, clip):
posaxis = self.axis_wrap_if_negative(axis)
if posaxis == depth:
return self.rpad_axis0(target, clip)
return self.pad_none_axis0(target, clip)
elif posaxis == depth + 1:
mask = ak._v2.index.Index8(self.mask_as_bool(valid_when=False))
index = ak._v2.index.Index64.empty(mask.length, self._nplike)
Expand All @@ -897,7 +897,7 @@ def _rpad(self, target, axis, depth, clip):
self._mask.length,
)
)
next = self.project()._rpad(target, posaxis, depth, clip)
next = self.project()._pad_none(target, posaxis, depth, clip)
return ak._v2.contents.indexedoptionarray.IndexedOptionArray(
index,
next,
Expand All @@ -908,7 +908,7 @@ def _rpad(self, target, axis, depth, clip):
else:
return ak._v2.contents.bytemaskedarray.ByteMaskedArray(
self._mask,
self._content._rpad(target, posaxis, depth, clip),
self._content._pad_none(target, posaxis, depth, clip),
self._valid_when,
None,
self._parameters,
Expand Down
22 changes: 11 additions & 11 deletions src/awkward/_v2/contents/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ def axis_wrap_if_negative(self, axis):

return axis

def _localindex_axis0(self):
def _local_index_axis0(self):
localindex = ak._v2.index.Index64.empty(self.length, self._nplike)
self._handle_error(
self._nplike["awkward_localindex", np.int64](
Expand Down Expand Up @@ -790,8 +790,8 @@ def _merging_strategy(self, others):

return (head, tail)

def localindex(self, axis):
return self._localindex(axis, 0)
def local_index(self, axis):
return self._local_index(axis, 0)

def _reduce(self, reducer, axis=-1, mask=True, keepdims=False):
if axis is None:
Expand Down Expand Up @@ -1040,7 +1040,7 @@ def combinations(self, n, replacement=False, axis=1, fields=None, parameters=Non
)
return self._combinations(n, replacement, recordlookup, parameters, axis, 0)

def validityerror_parameters(self, path):
def validity_error_parameters(self, path):
if self.parameter("__array__") == "string":
content = None
if isinstance(
Expand Down Expand Up @@ -1140,11 +1140,11 @@ def validityerror_parameters(self, path):

return ""

def validityerror(self, path="layout"):
paramcheck = self.validityerror_parameters(path)
def validity_error(self, path="layout"):
paramcheck = self.validity_error_parameters(path)
if paramcheck != "":
return paramcheck
return self._validityerror(path)
return self._validity_error(path)

@property
def nbytes(self):
Expand Down Expand Up @@ -1235,7 +1235,7 @@ def is_tuple(self):
def dimension_optiontype(self):
return self.Form.dimension_optiontype.__get__(self)

def rpad_axis0(self, target, clip):
def pad_none_axis0(self, target, clip):
if not clip and target < self.length:
index = ak._v2.index.Index64(
self._nplike.arange(self.length, dtype=np.int64)
Expand All @@ -1261,8 +1261,8 @@ def rpad_axis0(self, target, clip):
)
return next.simplify_optiontype()

def rpad(self, length, axis, clip=False):
return self._rpad(length, axis, 0, clip)
def pad_none(self, length, axis, clip=False):
return self._pad_none(length, axis, 0, clip)

def to_arrow(
self,
Expand Down Expand Up @@ -1462,7 +1462,7 @@ def to_backend(self, backend):
else:
return self._to_nplike(ak._v2._util.regularize_backend(backend))

def withparameter(self, key, value):
def with_parameter(self, key, value):
out = copy.copy(self)

if self._parameters is None:
Expand Down
8 changes: 4 additions & 4 deletions src/awkward/_v2/contents/emptyarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def mergemany(self, others):
def fillna(self, value):
return EmptyArray(None, self._parameters, self._nplike)

def _localindex(self, axis, depth):
def _local_index(self, axis, depth):
return ak._v2.contents.numpyarray.NumpyArray(
self._nplike.empty(0, np.int64), None, None, self._nplike
)
Expand Down Expand Up @@ -253,22 +253,22 @@ def _reduce_next(
keepdims,
)

def _validityerror(self, path):
def _validity_error(self, path):
return ""

def _nbytes_part(self):
if self.identifier is not None:
return self.identifier._nbytes_part()
return 0

def _rpad(self, target, axis, depth, clip):
def _pad_none(self, target, axis, depth, clip):
posaxis = self.axis_wrap_if_negative(axis)
if posaxis != depth:
raise ak._v2._util.error(
np.AxisError(f"axis={axis} exceeds the depth of this array({depth})")
)
else:
return self.rpad_axis0(target, True)
return self.pad_none_axis0(target, True)

def _to_arrow(self, pyarrow, mask_node, validbytes, length, options):
if options["emptyarray_to"] is None:
Expand Down
18 changes: 9 additions & 9 deletions src/awkward/_v2/contents/indexedarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,12 +653,12 @@ def fillna(self, value):
self._nplike,
)

def _localindex(self, axis, depth):
def _local_index(self, axis, depth):
posaxis = self.axis_wrap_if_negative(axis)
if posaxis == depth:
return self._localindex_axis0()
return self._local_index_axis0()
else:
return self.project()._localindex(posaxis, depth)
return self.project()._local_index(posaxis, depth)

def _unique_index(self, index, sorted=True):
next = ak._v2.index.Index64.zeros(self.length, self._nplike)
Expand Down Expand Up @@ -1061,7 +1061,7 @@ def _reduce_next(
)
)

def _validityerror(self, path):
def _validity_error(self, path):
error = self._nplike["awkward_IndexedArray_validity", self.index.dtype.type](
self.index.data, self.index.length, self._content.length, False
)
Expand Down Expand Up @@ -1089,24 +1089,24 @@ def _validityerror(self, path):
):
return "{0} contains \"{1}\", the operation that made it might have forgotten to call 'simplify_optiontype()'"
else:
return self._content.validityerror(path + ".content")
return self._content.validity_error(path + ".content")

def _nbytes_part(self):
result = self.index._nbytes_part() + self.content._nbytes_part()
if self.identifier is not None:
result = result + self.identifier._nbytes_part()
return result

def _rpad(self, target, axis, depth, clip):
def _pad_none(self, target, axis, depth, clip):
posaxis = self.axis_wrap_if_negative(axis)
if posaxis == depth:
return self.rpad_axis0(target, clip)
return self.pad_none_axis0(target, clip)
elif posaxis == depth + 1:
return self.project()._rpad(target, posaxis, depth, clip)
return self.project()._pad_none(target, posaxis, depth, clip)
else:
return ak._v2.contents.indexedarray.IndexedArray(
self._index,
self._content._rpad(target, posaxis, depth, clip),
self._content._pad_none(target, posaxis, depth, clip),
None,
self._parameters,
self._nplike,
Expand Down
18 changes: 9 additions & 9 deletions src/awkward/_v2/contents/indexedoptionarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,15 +764,15 @@ def fillna(self, value):
)
return out.simplify_uniontype(True, True)

def _localindex(self, axis, depth):
def _local_index(self, axis, depth):
posaxis = self.axis_wrap_if_negative(axis)
if posaxis == depth:
return self._localindex_axis0()
return self._local_index_axis0()
else:
_, nextcarry, outindex = self._nextcarry_outindex(self._nplike)

next = self._content._carry(nextcarry, False)
out = next._localindex(posaxis, depth)
out = next._local_index(posaxis, depth)
out2 = ak._v2.contents.indexedoptionarray.IndexedOptionArray(
outindex,
out,
Expand Down Expand Up @@ -1426,7 +1426,7 @@ def _combinations(self, n, replacement, recordlookup, parameters, axis, depth):
)
return out2.simplify_optiontype()

def _validityerror(self, path):
def _validity_error(self, path):
assert self.index.nplike is self._nplike
error = self._nplike["awkward_IndexedArray_validity", self.index.dtype.type](
self.index.data, self.index.length, self._content.length, True
Expand Down Expand Up @@ -1455,18 +1455,18 @@ def _validityerror(self, path):
):
return "{0} contains \"{1}\", the operation that made it might have forgotten to call 'simplify_optiontype()'"
else:
return self._content.validityerror(path + ".content")
return self._content.validity_error(path + ".content")

def _nbytes_part(self):
result = self.index._nbytes_part() + self.content._nbytes_part()
if self.identifier is not None:
result = result + self.identifier._nbytes_part()
return result

def _rpad(self, target, axis, depth, clip):
def _pad_none(self, target, axis, depth, clip):
posaxis = self.axis_wrap_if_negative(axis)
if posaxis == depth:
return self.rpad_axis0(target, clip)
return self.pad_none_axis0(target, clip)
elif posaxis == depth + 1:
mask = ak._v2.index.Index8(self.mask_as_bool(valid_when=False))
index = ak._v2.index.Index64.empty(mask.length, self._nplike)
Expand All @@ -1478,7 +1478,7 @@ def _rpad(self, target, axis, depth, clip):
mask.dtype.type,
](index.data, mask.data, mask.length)
)
next = self.project()._rpad(target, posaxis, depth, clip)
next = self.project()._pad_none(target, posaxis, depth, clip)
return ak._v2.contents.indexedoptionarray.IndexedOptionArray(
index,
next,
Expand All @@ -1489,7 +1489,7 @@ def _rpad(self, target, axis, depth, clip):
else:
return ak._v2.contents.indexedoptionarray.IndexedOptionArray(
self._index,
self._content._rpad(target, posaxis, depth, clip),
self._content._pad_none(target, posaxis, depth, clip),
None,
self._parameters,
self._nplike,
Expand Down
Loading