diff --git a/src/awkward/_broadcasting.py b/src/awkward/_broadcasting.py index c98616bf2c..978dde814c 100644 --- a/src/awkward/_broadcasting.py +++ b/src/awkward/_broadcasting.py @@ -54,7 +54,11 @@ def broadcast_pack(inputs, isscalar): elif isinstance(x, Content): nextinputs.append( RegularArray( - x, x.length if x.nplike.known_shape else 1, 1, None, x.nplike + x, + x.length if x.nplike.known_shape else 1, + 1, + parameters=None, + nplike=x.nplike, ) ) isscalar.append(False) diff --git a/src/awkward/_connect/jax/trees.py b/src/awkward/_connect/jax/trees.py index 47abba9210..28e17260ef 100644 --- a/src/awkward/_connect/jax/trees.py +++ b/src/awkward/_connect/jax/trees.py @@ -42,7 +42,9 @@ def action(node, **kwargs): if not (numpy.is_own_array(buffer) or jax.is_own_array(buffer)): return else: - return ak.contents.NumpyArray(buffer, node.parameters, nplike=nplike) + return ak.contents.NumpyArray( + buffer, parameters=node.parameters, nplike=nplike + ) return layout.recursively_apply(action=action, numpy_to_regular=False) diff --git a/src/awkward/_connect/pyarrow.py b/src/awkward/_connect/pyarrow.py index 5d25fa719e..1f5f04381c 100644 --- a/src/awkward/_connect/pyarrow.py +++ b/src/awkward/_connect/pyarrow.py @@ -876,7 +876,7 @@ def remove_optiontype(akarray): assert type(akarray).is_option if isinstance(akarray, ak.contents.IndexedOptionArray): return ak.contents.IndexedArray( - akarray.index, akarray.content, akarray.parameters + akarray.index, akarray.content, parameters=akarray.parameters ) else: return akarray.content @@ -888,8 +888,8 @@ def form_remove_optiontype(akform): return ak.forms.IndexedForm( akform.index, akform.content, - akform.parameters, - akform.form_key, + parameters=akform.parameters, + form_key=akform.form_key, ) else: return akform.content diff --git a/src/awkward/_slicing.py b/src/awkward/_slicing.py index 85b97eb34f..f2ca70fe88 100644 --- a/src/awkward/_slicing.py +++ b/src/awkward/_slicing.py @@ -514,5 +514,5 @@ def getitem_next_array_wrap(outcontent, shape, outer_length=0): size = shape[i] if isinstance(size, ak._typetracer.UnknownLengthType): size = 1 - outcontent = ak.contents.RegularArray(outcontent, size, length, None) + outcontent = ak.contents.RegularArray(outcontent, size, length, parameters=None) return outcontent diff --git a/src/awkward/_util.py b/src/awkward/_util.py index 166166443d..2acfaedb6d 100644 --- a/src/awkward/_util.py +++ b/src/awkward/_util.py @@ -480,7 +480,7 @@ def union_to_record(unionarray, anonymous): unionarray.tags, unionarray.index, contents, - unionarray.parameters, + parameters=unionarray.parameters, ) else: @@ -524,7 +524,7 @@ def union_to_record(unionarray, anonymous): unionarray.tags, unionarray.index, union_contents, - unionarray.parameters, + parameters=unionarray.parameters, ).simplify_uniontype() ) diff --git a/src/awkward/contents/bitmaskedarray.py b/src/awkward/contents/bitmaskedarray.py index 626ee0771c..7e5fa761b9 100644 --- a/src/awkward/contents/bitmaskedarray.py +++ b/src/awkward/contents/bitmaskedarray.py @@ -24,6 +24,7 @@ def copy( valid_when=unset, length=unset, lsb_order=unset, + *, parameters=unset, nplike=unset, ): @@ -33,8 +34,8 @@ def copy( self._valid_when if valid_when is unset else valid_when, self._length if length is unset else length, self._lsb_order if lsb_order is unset else lsb_order, - self._parameters if parameters is unset else parameters, - self._nplike if nplike is unset else nplike, + parameters=self._parameters if parameters is unset else parameters, + nplike=self._nplike if nplike is unset else nplike, ) def __copy__(self): @@ -54,6 +55,7 @@ def __init__( valid_when, length, lsb_order, + *, parameters=None, nplike=None, ): @@ -170,8 +172,8 @@ def typetracer(self): self._valid_when, self._length, self._lsb_order, - self._parameters, - tt, + parameters=self._parameters, + nplike=tt, ) @property @@ -185,8 +187,8 @@ def _forget_length(self): self._valid_when, ak._typetracer.UnknownLength, self._lsb_order, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def __repr__(self): @@ -215,8 +217,8 @@ def merge_parameters(self, parameters): self._valid_when, self._length, self._lsb_order, - ak._util.merge_parameters(self._parameters, parameters), - self._nplike, + parameters=ak._util.merge_parameters(self._parameters, parameters), + nplike=self._nplike, ) def to_IndexedOptionArray64(self): @@ -238,8 +240,8 @@ def to_IndexedOptionArray64(self): return ak.contents.IndexedOptionArray( index[0 : self._length], self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def to_ByteMaskedArray(self): @@ -262,8 +264,8 @@ def to_ByteMaskedArray(self): bytemask[: self._length], self._content, self._valid_when, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def to_BitMaskedArray(self, valid_when, lsb_order): @@ -277,8 +279,8 @@ def to_BitMaskedArray(self, valid_when, lsb_order): valid_when, self._length, lsb_order, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: @@ -298,8 +300,8 @@ def to_BitMaskedArray(self, valid_when, lsb_order): valid_when, self._length, lsb_order, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def mask_as_bool(self, valid_when=None, nplike=None): @@ -355,8 +357,8 @@ def _getitem_field(self, where, only_fields=()): self._valid_when, self._length, self._lsb_order, - None, - self._nplike, + parameters=None, + nplike=self._nplike, ).simplify_optiontype() def _getitem_fields(self, where, only_fields=()): @@ -366,8 +368,8 @@ def _getitem_fields(self, where, only_fields=()): self._valid_when, self._length, self._lsb_order, - None, - self._nplike, + parameters=None, + nplike=self._nplike, ).simplify_optiontype() def _carry(self, carry, allow_lazy): @@ -623,8 +625,8 @@ def continuation(): self._valid_when, self._length, self._lsb_order, - self._parameters if options["keep_parameters"] else None, - self._nplike, + parameters=self._parameters if options["keep_parameters"] else None, + nplike=self._nplike, ) else: @@ -668,8 +670,8 @@ def packed(self): return ak.contents.IndexedOptionArray( next._index, content, - next._parameters, - self._nplike, + parameters=next._parameters, + nplike=self._nplike, ) else: @@ -689,8 +691,8 @@ def packed(self): self._valid_when, self._length, self._lsb_order, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _to_list(self, behavior, json_conversions): diff --git a/src/awkward/contents/bytemaskedarray.py b/src/awkward/contents/bytemaskedarray.py index d74ccc7915..78a192d565 100644 --- a/src/awkward/contents/bytemaskedarray.py +++ b/src/awkward/contents/bytemaskedarray.py @@ -21,6 +21,7 @@ def copy( mask=unset, content=unset, valid_when=unset, + *, parameters=unset, nplike=unset, ): @@ -28,8 +29,8 @@ def copy( self._mask if mask is unset else mask, self._content if content is unset else content, self._valid_when if valid_when is unset else valid_when, - self._parameters if parameters is unset else parameters, - self._nplike if nplike is unset else nplike, + parameters=self._parameters if parameters is unset else parameters, + nplike=self._nplike if nplike is unset else nplike, ) def __copy__(self): @@ -42,7 +43,7 @@ def __deepcopy__(self, memo): parameters=copy.deepcopy(self._parameters, memo), ) - def __init__(self, mask, content, valid_when, parameters=None, nplike=None): + def __init__(self, mask, content, valid_when, *, parameters=None, nplike=None): if not (isinstance(mask, Index) and mask.dtype == np.dtype(np.int8)): raise ak._errors.wrap_error( TypeError( @@ -126,8 +127,8 @@ def typetracer(self): ak.index.Index(self._mask.raw(tt)), self._content.typetracer, self._valid_when, - self._parameters, - tt, + parameters=self._parameters, + nplike=tt, ) @property @@ -139,8 +140,8 @@ def _forget_length(self): self._mask.forget_length(), self._content, self._valid_when, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def __repr__(self): @@ -165,8 +166,8 @@ def merge_parameters(self, parameters): self._mask, self._content, self._valid_when, - ak._util.merge_parameters(self._parameters, parameters), - self._nplike, + parameters=ak._util.merge_parameters(self._parameters, parameters), + nplike=self._nplike, ) def to_IndexedOptionArray64(self): @@ -186,7 +187,7 @@ def to_IndexedOptionArray64(self): ) return ak.contents.IndexedOptionArray( - index, self._content, self._parameters, self._nplike + index, self._content, parameters=self._parameters, nplike=self._nplike ) def to_ByteMaskedArray(self, valid_when): @@ -201,8 +202,8 @@ def to_ByteMaskedArray(self, valid_when): ), self._content, valid_when, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def to_BitMaskedArray(self, valid_when, lsb_order): @@ -217,8 +218,8 @@ def to_BitMaskedArray(self, valid_when, lsb_order): valid_when, self.length, lsb_order, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: @@ -233,8 +234,8 @@ def to_BitMaskedArray(self, valid_when, lsb_order): valid_when, self.length, lsb_order, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def mask_as_bool(self, valid_when=None, nplike=None): @@ -274,8 +275,8 @@ def _getitem_range(self, where): self._mask[start:stop], self._content._getitem_range(slice(start, stop)), self._valid_when, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _getitem_field(self, where, only_fields=()): @@ -283,8 +284,8 @@ def _getitem_field(self, where, only_fields=()): self._mask, self._content._getitem_field(where, only_fields), self._valid_when, - None, - self._nplike, + parameters=None, + nplike=self._nplike, ).simplify_optiontype() def _getitem_fields(self, where, only_fields=()): @@ -292,8 +293,8 @@ def _getitem_fields(self, where, only_fields=()): self._mask, self._content._getitem_fields(where, only_fields), self._valid_when, - None, - self._nplike, + parameters=None, + nplike=self._nplike, ).simplify_optiontype() def _carry(self, carry, allow_lazy): @@ -308,8 +309,8 @@ def _carry(self, carry, allow_lazy): nextmask, self._content._carry(carry, allow_lazy), self._valid_when, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _nextcarry_outindex(self, nplike): @@ -360,7 +361,11 @@ def _getitem_next_jagged_generic(self, slicestarts, slicestops, slicecontent, ta raise ak._errors.index_error( self, ak.contents.ListArray( - slicestarts, slicestops, slicecontent, None, self._nplike + slicestarts, + slicestops, + slicecontent, + parameters=None, + nplike=self._nplike, ), "cannot fit jagged slice with length {} into {} of size {}".format( slicestarts.length, type(self).__name__, self.length @@ -402,7 +407,7 @@ def _getitem_next_jagged_generic(self, slicestarts, slicestops, slicecontent, ta out = next._getitem_next_jagged(reducedstarts, reducedstops, slicecontent, tail) out2 = ak.contents.IndexedOptionArray( - outindex, out, self._parameters, self._nplike + outindex, out, parameters=self._parameters, nplike=self._nplike ) return out2.simplify_optiontype() @@ -426,8 +431,8 @@ def _getitem_next(self, head, tail, advanced): out2 = ak.contents.IndexedOptionArray( outindex, out, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return out2.simplify_optiontype() @@ -488,8 +493,8 @@ def project(self, mask=None): nextmask, self._content, valid_when, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return next.project() @@ -556,7 +561,7 @@ def num(self, axis, depth=0): out = next.num(posaxis, depth) out2 = ak.contents.IndexedOptionArray( - outindex, out, self.parameters, self._nplike + outindex, out, parameters=self.parameters, nplike=self._nplike ) return out2.simplify_optiontype() @@ -575,7 +580,10 @@ def _offsets_and_flattened(self, axis, depth): return ( offsets, ak.contents.IndexedOptionArray( - outindex, flattened, self._parameters, self._nplike + outindex, + flattened, + parameters=self._parameters, + nplike=self._nplike, ), ) @@ -646,8 +654,8 @@ def mergemany(self, others): ak.index.Index8(self._nplike.concatenate(masks)), self._content[: self.length].mergemany(tail_contents), self._valid_when, - parameters, - self._nplike, + parameters=parameters, + nplike=self._nplike, ) else: @@ -668,8 +676,8 @@ def _local_index(self, axis, depth): out2 = ak.contents.IndexedOptionArray( outindex, out, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return out2.simplify_optiontype() @@ -678,8 +686,8 @@ def numbers_to_type(self, name): self._mask, self._content.numbers_to_type(name), self._valid_when, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _is_unique(self, negaxis, starts, parents, outlength): @@ -750,7 +758,7 @@ def _combinations(self, n, replacement, recordlookup, parameters, axis, depth): n, replacement, recordlookup, parameters, posaxis, depth ) out2 = ak.contents.IndexedOptionArray( - outindex, out, parameters, self._nplike + outindex, out, parameters=parameters, nplike=self._nplike ) return out2.simplify_optiontype() @@ -904,15 +912,12 @@ def _reduce_next( tmp = ak.contents.IndexedOptionArray( outindex, out_content, - None, - self._nplike, + parameters=None, + nplike=self._nplike, ).simplify_optiontype() return ak.contents.ListOffsetArray( - outoffsets, - tmp, - None, - self._nplike, + outoffsets, tmp, parameters=None, nplike=self._nplike ) def _validity_error(self, path): @@ -958,16 +963,16 @@ def _pad_none(self, target, axis, depth, clip): return ak.contents.IndexedOptionArray( index, next, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ).simplify_optiontype() else: return ak.contents.ByteMaskedArray( self._mask, self._content._pad_none(target, posaxis, depth, clip), self._valid_when, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _to_arrow(self, pyarrow, mask_node, validbytes, length, options): @@ -1013,8 +1018,8 @@ def continuation(): options, ), self._valid_when, - self._parameters if options["keep_parameters"] else None, - self._nplike, + parameters=self._parameters if options["keep_parameters"] else None, + nplike=self._nplike, ) else: @@ -1057,8 +1062,8 @@ def packed(self): return ak.contents.IndexedOptionArray( next._index, content, - next._parameters, - self._nplike, + parameters=next._parameters, + nplike=self._nplike, ) else: @@ -1070,8 +1075,8 @@ def packed(self): self._mask, content, self._valid_when, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _to_list(self, behavior, json_conversions): diff --git a/src/awkward/contents/content.py b/src/awkward/contents/content.py index e336631917..598e6437ca 100644 --- a/src/awkward/contents/content.py +++ b/src/awkward/contents/content.py @@ -331,10 +331,10 @@ def _getitem_next_newaxis(self, tail, advanced: ak.index.Index | None): nexthead, nexttail = ak._slicing.headtail(tail) return ak.contents.RegularArray( self._getitem_next(nexthead, nexttail, advanced), - 1, # size - 0, # zeros_length is irrelevant when the size is 1 (!= 0) - None, - self._nplike, + 1, + 0, + parameters=None, + nplike=self._nplike, ) def _getitem_next_ellipsis(self, tail, advanced: ak.index.Index | None): @@ -383,15 +383,15 @@ def _getitem_next_regular_missing( ) out = ak.contents.IndexedOptionArray( - outindex, raw.content, self._parameters, self._nplike + outindex, raw.content, parameters=self._parameters, nplike=self._nplike ) return ak.contents.RegularArray( out.simplify_optiontype(), indexlength, 1, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _getitem_next_missing_jagged( @@ -443,14 +443,14 @@ def _getitem_next_missing_jagged( tmp = content._getitem_next_jagged(starts, stops, jagged.content, tail) out = ak.contents.IndexedOptionArray( - outputmask, tmp, self._parameters, self._nplike + outputmask, tmp, parameters=self._parameters, nplike=self._nplike ) return ak.contents.RegularArray( out.simplify_optiontype(), index.length, 1, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _getitem_next_missing( @@ -512,8 +512,8 @@ def _getitem_next_missing( contents, nextcontent._fields, None, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: @@ -558,8 +558,8 @@ def _getitem(self, where): self, self.length if self._nplike.known_shape else 1, 1, - None, - self._nplike, + parameters=None, + nplike=self._nplike, ) out = next._getitem_next(nextwhere[0], nextwhere[1:], None) @@ -637,7 +637,9 @@ def _getitem(self, where): return self._getitem(layout) else: return self._getitem( - ak.contents.NumpyArray(as_array, None, layout.nplike) + ak.contents.NumpyArray( + as_array, parameters=None, nplike=layout.nplike + ) ) else: @@ -731,7 +733,7 @@ def _local_index_axis0(self) -> ak.contents.NumpyArray: localindex.length, ) ) - return ak.contents.NumpyArray(localindex, None, self._nplike) + return ak.contents.NumpyArray(localindex, parameters=None, nplike=self._nplike) def merge(self, other: Content) -> Content: others = [other] @@ -787,7 +789,9 @@ def merge_as_union(self, other: Content) -> ak.contents.UnionArray: ) ) - return ak.contents.UnionArray(tags, index, contents, None, self._nplike) + return ak.contents.UnionArray( + tags, index, contents, parameters=None, nplike=self._nplike + ) def _merging_strategy( self, others: list[Content] @@ -1208,11 +1212,15 @@ def _combinations_axis0( contents = [] length = None for ptr in tocarry: - contents.append(ak.contents.IndexedArray(ptr, self, None, self._nplike)) + contents.append( + ak.contents.IndexedArray( + ptr, self, parameters=None, nplike=self._nplike + ) + ) length = contents[-1].length assert length is not None return ak.contents.RecordArray( - contents, recordlookup, length, parameters, self._nplike + contents, recordlookup, length, parameters=parameters, nplike=self._nplike ) def combinations( @@ -1489,8 +1497,8 @@ def pad_none_axis0(self, target: Integral, clip: bool) -> Content: next = ak.contents.IndexedOptionArray( index, self, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return next.simplify_optiontype() @@ -1815,3 +1823,6 @@ def _layout_equal( def _repr(self, indent: str, pre: str, post: str) -> str: raise ak._errors.wrap_error(NotImplementedError) + + def numbers_to_type(self, name: str) -> Self: + raise ak._errors.wrap_error(NotImplementedError) diff --git a/src/awkward/contents/emptyarray.py b/src/awkward/contents/emptyarray.py index 4fb2d3631f..948c053d3d 100644 --- a/src/awkward/contents/emptyarray.py +++ b/src/awkward/contents/emptyarray.py @@ -16,12 +16,13 @@ class EmptyArray(Content): def copy( self, + *, parameters=unset, nplike=unset, ): return EmptyArray( - self._parameters if parameters is unset else parameters, - self._nplike if nplike is unset else nplike, + parameters=self._parameters if parameters is unset else parameters, + nplike=self._nplike if nplike is unset else nplike, ) def __copy__(self): @@ -30,7 +31,7 @@ def __copy__(self): def __deepcopy__(self, memo): return self.copy(parameters=copy.deepcopy(self._parameters, memo)) - def __init__(self, parameters=None, nplike=None): + def __init__(self, *, parameters=None, nplike=None): if nplike is None: nplike = numpy self._init(parameters, nplike) @@ -46,14 +47,14 @@ def _to_buffers(self, form, getkey, container, nplike): @property def typetracer(self): tt = ak._typetracer.TypeTracer.instance() - return EmptyArray(self._parameters, tt) + return EmptyArray(parameters=self._parameters, nplike=tt) @property def length(self): return 0 def _forget_length(self): - return EmptyArray(self._parameters, self._nplike) + return EmptyArray(parameters=self._parameters, nplike=self._nplike) def __repr__(self): return self._repr("", "", "") @@ -71,7 +72,8 @@ def _repr(self, indent, pre, post): def merge_parameters(self, parameters): return EmptyArray( - ak._util.merge_parameters(self._parameters, parameters), self._nplike + parameters=ak._util.merge_parameters(self._parameters, parameters), + nplike=self._nplike, ) def to_NumpyArray(self, dtype, nplike=None): @@ -79,7 +81,9 @@ def to_NumpyArray(self, dtype, nplike=None): nplike = self._nplike if nplike is None: nplike = numpy - return ak.contents.NumpyArray(nplike.empty(0, dtype), self._parameters, nplike) + return ak.contents.NumpyArray( + nplike.empty(0, dtype), parameters=self._parameters, nplike=nplike + ) def __array__(self, **kwargs): return numpy.empty((0,)) @@ -116,7 +120,11 @@ def _getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail): raise ak._errors.index_error( self, ak.contents.ListArray( - slicestarts, slicestops, slicecontent, None, self._nplike + slicestarts, + slicestops, + slicecontent, + parameters=None, + nplike=self._nplike, ), "too many jagged slice dimensions for array", ) @@ -169,7 +177,7 @@ def num(self, axis, depth=0): return out else: out = ak.index.Index64.empty(0, self._nplike) - return ak.contents.NumpyArray(out, None, self._nplike) + return ak.contents.NumpyArray(out, parameters=None, nplike=self._nplike) def _offsets_and_flattened(self, axis, depth): posaxis = self.axis_wrap_if_negative(axis) @@ -179,7 +187,10 @@ def _offsets_and_flattened(self, axis, depth): ) else: offsets = ak.index.Index64.zeros(1, self._nplike) - return (offsets, EmptyArray(self._parameters, self._nplike)) + return ( + offsets, + EmptyArray(parameters=self._parameters, nplike=self._nplike), + ) def _mergeable(self, other, mergebool): return True @@ -196,15 +207,15 @@ def mergemany(self, others): return others[0].mergemany(tail_others) def fill_none(self, value): - return EmptyArray(self._parameters, self._nplike) + return EmptyArray(parameters=self._parameters, nplike=self._nplike) def _local_index(self, axis, depth): return ak.contents.NumpyArray( - self._nplike.empty(0, np.int64), None, self._nplike + self._nplike.empty(0, np.int64), parameters=None, nplike=self._nplike ) def numbers_to_type(self, name): - return ak.contents.EmptyArray(self._parameters, self._nplike) + return ak.contents.EmptyArray(parameters=self._parameters, nplike=self._nplike) def _is_unique(self, negaxis, starts, parents, outlength): return True @@ -243,7 +254,7 @@ def _sort_next( return self def _combinations(self, n, replacement, recordlookup, parameters, axis, depth): - return ak.contents.EmptyArray(self._parameters, self._nplike) + return ak.contents.EmptyArray(parameters=self._parameters, nplike=self._nplike) def _reduce_next( self, @@ -326,7 +337,7 @@ def continuation(): if options["keep_parameters"]: return self else: - return EmptyArray(None, self._nplike) + return EmptyArray(parameters=None, nplike=self._nplike) else: diff --git a/src/awkward/contents/indexedarray.py b/src/awkward/contents/indexedarray.py index 69a027491b..06e9ac3347 100644 --- a/src/awkward/contents/indexedarray.py +++ b/src/awkward/contents/indexedarray.py @@ -18,14 +18,15 @@ def copy( self, index=unset, content=unset, + *, parameters=unset, nplike=unset, ): return IndexedArray( self._index if index is unset else index, self._content if content is unset else content, - self._parameters if parameters is unset else parameters, - self._nplike if nplike is unset else nplike, + parameters=self._parameters if parameters is unset else parameters, + nplike=self._nplike if nplike is unset else nplike, ) def __copy__(self): @@ -38,7 +39,7 @@ def __deepcopy__(self, memo): parameters=copy.deepcopy(self._parameters, memo), ) - def __init__(self, index, content, parameters=None, nplike=None): + def __init__(self, index, content, *, parameters=None, nplike=None): if not ( isinstance(index, Index) and index.dtype @@ -102,8 +103,8 @@ def typetracer(self): return IndexedArray( ak.index.Index(self._index.raw(tt)), self._content.typetracer, - self._parameters, - tt, + parameters=self._parameters, + nplike=tt, ) @property @@ -114,8 +115,8 @@ def _forget_length(self): return IndexedArray( self._index.forget_length(), self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def __repr__(self): @@ -137,13 +138,13 @@ def merge_parameters(self, parameters): return IndexedArray( self._index, self._content, - ak._util.merge_parameters(self._parameters, parameters), - self._nplike, + parameters=ak._util.merge_parameters(self._parameters, parameters), + nplike=self._nplike, ) def to_IndexedOptionArray64(self): return ak.contents.IndexedOptionArray( - self._index, self._content, self._parameters, self._nplike + self._index, self._content, parameters=self._parameters, nplike=self._nplike ) def mask_as_bool(self, valid_when=True): @@ -174,24 +175,24 @@ def _getitem_range(self, where): return IndexedArray( self._index[start:stop], self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _getitem_field(self, where, only_fields=()): return IndexedArray( self._index, self._content._getitem_field(where, only_fields), - None, - self._nplike, + parameters=None, + nplike=self._nplike, ) def _getitem_fields(self, where, only_fields=()): return IndexedArray( self._index, self._content._getitem_fields(where, only_fields), - None, - self._nplike, + parameters=None, + nplike=self._nplike, ) def _carry(self, carry, allow_lazy): @@ -203,10 +204,7 @@ def _carry(self, carry, allow_lazy): raise ak._errors.index_error(self, carry.data, str(err)) from err return IndexedArray( - nextindex, - self._content, - self._parameters, - self._nplike, + nextindex, self._content, parameters=self._parameters, nplike=self._nplike ) def _getitem_next_jagged_generic(self, slicestarts, slicestops, slicecontent, tail): @@ -214,7 +212,11 @@ def _getitem_next_jagged_generic(self, slicestarts, slicestops, slicecontent, ta raise ak._errors.index_error( self, ak.contents.ListArray( - slicestarts, slicestops, slicecontent, None, self._nplike + slicestarts, + slicestops, + slicecontent, + parameters=None, + nplike=self._nplike, ), "cannot fit jagged slice with length {} into {} of size {}".format( slicestarts.length, type(self).__name__, self.length @@ -325,8 +327,8 @@ def project(self, mask=None): next = ak.contents.IndexedOptionArray( nextindex, self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return next.project() @@ -405,8 +407,8 @@ def simplify_optiontype(self): return IndexedArray( result, self._content.content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) if isinstance( @@ -421,8 +423,8 @@ def simplify_optiontype(self): return ak.contents.IndexedOptionArray( result, self._content.content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: @@ -534,7 +536,9 @@ def _reverse_merge(self, other): ) parameters = ak._util.merge_parameters(self._parameters, other._parameters) - return ak.contents.IndexedArray(index, content, parameters, self._nplike) + return ak.contents.IndexedArray( + index, content, parameters=parameters, nplike=self._nplike + ) def mergemany(self, others): if len(others) == 0: @@ -610,7 +614,7 @@ def mergemany(self, others): tail_contents = contents[1:] nextcontent = contents[0].mergemany(tail_contents) next = ak.contents.IndexedArray( - nextindex, nextcontent, parameters, self._nplike + nextindex, nextcontent, parameters=parameters, nplike=self._nplike ) if len(tail) == 0: @@ -636,8 +640,8 @@ def fill_none(self, value): return IndexedArray( self._index, self._content.fill_none(value), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _local_index(self, axis, depth): @@ -710,8 +714,8 @@ def numbers_to_type(self, name): return ak.contents.IndexedArray( self._index, self._content.numbers_to_type(name), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _is_unique(self, negaxis, starts, parents, outlength): @@ -799,8 +803,8 @@ def _unique(self, negaxis, starts, parents, outlength): return ak.contents.IndexedOptionArray( nextoutindex, unique, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ).simplify_optiontype() if not branch and negaxis == depth: @@ -838,17 +842,11 @@ def _unique(self, negaxis, starts, parents, outlength): ) tmp = ak.contents.IndexedArray( - outindex, - unique._content, - None, - self._nplike, + outindex, unique._content, parameters=None, nplike=self._nplike ) return ak.contents.ListOffsetArray( - outoffsets, - tmp, - None, - self._nplike, + outoffsets, tmp, parameters=None, nplike=self._nplike ) elif isinstance(unique, ak.contents.NumpyArray): @@ -859,8 +857,8 @@ def _unique(self, negaxis, starts, parents, outlength): out = ak.contents.IndexedOptionArray( nextoutindex, unique, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ).simplify_optiontype() return out @@ -992,8 +990,8 @@ def _pad_none(self, target, axis, depth, clip): return ak.contents.IndexedArray( self._index, self._content._pad_none(target, posaxis, depth, clip), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _to_arrow(self, pyarrow, mask_node, validbytes, length, options): @@ -1006,8 +1004,8 @@ def _to_arrow(self, pyarrow, mask_node, validbytes, length, options): next = IndexedArray( self._index, self._content, - next_parameters, - self._nplike, + parameters=next_parameters, + nplike=self._nplike, ) return next._to_arrow(pyarrow, mask_node, validbytes, length, options) @@ -1083,8 +1081,8 @@ def continuation(): lateral_context, options, ), - self._parameters if options["keep_parameters"] else None, - self._nplike, + parameters=self._parameters if options["keep_parameters"] else None, + nplike=self._nplike, ) else: diff --git a/src/awkward/contents/indexedoptionarray.py b/src/awkward/contents/indexedoptionarray.py index c2f394e08c..c3c98e1e83 100644 --- a/src/awkward/contents/indexedoptionarray.py +++ b/src/awkward/contents/indexedoptionarray.py @@ -19,14 +19,15 @@ def copy( self, index=unset, content=unset, + *, parameters=unset, nplike=unset, ): return IndexedOptionArray( self._index if index is unset else index, self._content if content is unset else content, - self._parameters if parameters is unset else parameters, - self._nplike if nplike is unset else nplike, + parameters=self._parameters if parameters is unset else parameters, + nplike=self._nplike if nplike is unset else nplike, ) def __copy__(self): @@ -39,7 +40,7 @@ def __deepcopy__(self, memo): parameters=copy.deepcopy(self._parameters, memo), ) - def __init__(self, index, content, parameters=None, nplike=None): + def __init__(self, index, content, *, parameters=None, nplike=None): if not ( isinstance(index, Index) and index.dtype @@ -102,8 +103,8 @@ def typetracer(self): return IndexedOptionArray( ak.index.Index(self._index.raw(tt)), self._content.typetracer, - self._parameters, - tt, + parameters=self._parameters, + nplike=tt, ) @property @@ -114,8 +115,8 @@ def _forget_length(self): return IndexedOptionArray( self._index.forget_length(), self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def __repr__(self): @@ -137,8 +138,8 @@ def merge_parameters(self, parameters): return IndexedOptionArray( self._index, self._content, - ak._util.merge_parameters(self._parameters, parameters), - self._nplike, + parameters=ak._util.merge_parameters(self._parameters, parameters), + nplike=self._nplike, ) def to_IndexedOptionArray64(self): @@ -148,8 +149,8 @@ def to_IndexedOptionArray64(self): return IndexedOptionArray( self._index.astype(np.int64), self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def to_ByteMaskedArray(self, valid_when): @@ -171,8 +172,8 @@ def to_ByteMaskedArray(self, valid_when): mask, content, valid_when, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def to_BitMaskedArray(self, valid_when, lsb_order): @@ -214,24 +215,24 @@ def _getitem_range(self, where): return IndexedOptionArray( self._index[start:stop], self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _getitem_field(self, where, only_fields=()): return IndexedOptionArray( self._index, self._content._getitem_field(where, only_fields), - None, - self._nplike, + parameters=None, + nplike=self._nplike, ) def _getitem_fields(self, where, only_fields=()): return IndexedOptionArray( self._index, self._content._getitem_fields(where, only_fields), - None, - self._nplike, + parameters=None, + nplike=self._nplike, ) def _carry(self, carry, allow_lazy): @@ -245,8 +246,8 @@ def _carry(self, carry, allow_lazy): return IndexedOptionArray( nextindex, self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _nextcarry_outindex(self, nplike): @@ -297,7 +298,11 @@ def _getitem_next_jagged_generic(self, slicestarts, slicestops, slicecontent, ta raise ak._errors.index_error( self, ak.contents.ListArray( - slicestarts, slicestops, slicecontent, None, self._nplike + slicestarts, + slicestops, + slicecontent, + parameters=None, + nplike=self._nplike, ), "cannot fit jagged slice with length {} into {} of size {}".format( slicestarts.length, type(self).__name__, self.length @@ -337,7 +342,7 @@ def _getitem_next_jagged_generic(self, slicestarts, slicestops, slicecontent, ta out = next._getitem_next_jagged(reducedstarts, reducedstops, slicecontent, tail) out2 = ak.contents.IndexedOptionArray( - outindex, out, self._parameters, self._nplike + outindex, out, parameters=self._parameters, nplike=self._nplike ) return out2.simplify_optiontype() @@ -359,7 +364,9 @@ def _getitem_next(self, head, tail, advanced): next = self._content._carry(nextcarry, True) out = next._getitem_next(head, tail, advanced) - out2 = IndexedOptionArray(outindex, out, self._parameters, self._nplike) + out2 = IndexedOptionArray( + outindex, out, parameters=self._parameters, nplike=self._nplike + ) return out2.simplify_optiontype() elif isinstance(head, str): @@ -412,8 +419,8 @@ def project(self, mask=None): next = ak.contents.IndexedOptionArray( nextindex, self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return next.project() else: @@ -506,8 +513,8 @@ def simplify_optiontype(self): return ak.contents.IndexedOptionArray( result, self._content.content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: @@ -525,7 +532,7 @@ def num(self, axis, depth=0): next = self._content._carry(nextcarry, False) out = next.num(posaxis, depth) out2 = ak.contents.IndexedOptionArray( - outindex, out, self.parameters, self._nplike + outindex, out, parameters=self.parameters, nplike=self._nplike ) return out2.simplify_optiontype() @@ -543,7 +550,10 @@ def _offsets_and_flattened(self, axis, depth): return ( offsets, ak.contents.IndexedOptionArray( - outindex, flattened, self._parameters, self._nplike + outindex, + flattened, + parameters=self._parameters, + nplike=self._nplike, ), ) @@ -663,7 +673,9 @@ def _reverse_merge(self, other): ) parameters = ak._util.merge_parameters(self._parameters, other._parameters) - return ak.contents.IndexedOptionArray(index, content, parameters, self._nplike) + return ak.contents.IndexedOptionArray( + index, content, parameters=parameters, nplike=self._nplike + ) def mergemany(self, others): if len(others) == 0: @@ -740,7 +752,7 @@ def mergemany(self, others): tail_contents = contents[1:] nextcontent = contents[0].mergemany(tail_contents) next = ak.contents.IndexedOptionArray( - nextindex, nextcontent, parameters, self._nplike + nextindex, nextcontent, parameters=parameters, nplike=self._nplike ) if len(tail) == 0: @@ -775,7 +787,7 @@ def fill_none(self, value): ](index.data, self._index.data, tags.length) ) out = ak.contents.UnionArray( - tags, index, contents, self._parameters, self._nplike + tags, index, contents, parameters=self._parameters, nplike=self._nplike ) return out.simplify_uniontype(True, True) @@ -791,8 +803,8 @@ def _local_index(self, axis, depth): out2 = ak.contents.IndexedOptionArray( outindex, out, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return out2 @@ -864,8 +876,8 @@ def numbers_to_type(self, name): return ak.contents.IndexedOptionArray( self._index, self._content.numbers_to_type(name), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _is_unique(self, negaxis, starts, parents, outlength): @@ -921,8 +933,8 @@ def _unique(self, negaxis, starts, parents, outlength): return ak.contents.IndexedOptionArray( nextoutindex, out, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ).simplify_optiontype() if isinstance(out, ak.contents.ListOffsetArray): @@ -976,15 +988,15 @@ def _unique(self, negaxis, starts, parents, outlength): out = ak.contents.IndexedOptionArray( newindex[: newoffsets[-1]], out._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ).simplify_optiontype() return ak.contents.ListOffsetArray( newoffsets, out, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) if isinstance(out, ak.contents.NumpyArray): @@ -1007,8 +1019,8 @@ def _unique(self, negaxis, starts, parents, outlength): return ak.contents.IndexedOptionArray( nextoutindex, out, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ).simplify_optiontype() if inject_nones: @@ -1016,8 +1028,8 @@ def _unique(self, negaxis, starts, parents, outlength): out, out.length, 0, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return out @@ -1177,7 +1189,9 @@ def _argsort_next( # We can test for this condition by seeing whether the NumpyArray of indices # is mergeable with our content (`out = next._argsort_next result`). # If so, try to concatenate them at the end of `out`.` - nulls_index_content = ak.contents.NumpyArray(nulls_index, None, self._nplike) + nulls_index_content = ak.contents.NumpyArray( + nulls_index, parameters=None, nplike=self._nplike + ) if out.mergeable(nulls_index_content, True): out = out.merge(nulls_index_content) nulls_merged = True @@ -1223,8 +1237,8 @@ def _argsort_next( out = ak.contents.IndexedOptionArray( nextoutindex, out, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ).simplify_optiontype() inject_nones = ( @@ -1239,8 +1253,8 @@ def _argsort_next( return ak.contents.IndexedOptionArray( outindex, out, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ).simplify_optiontype() # Otherwise, if we are rearranging (e.g sorting) the contents of this layout, # then we do NOT want to return an optional layout, @@ -1289,8 +1303,8 @@ def _sort_next( out = ak.contents.IndexedOptionArray( nextoutindex, out, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ).simplify_optiontype() inject_nones = True if not branch and negaxis != depth else False @@ -1303,8 +1317,8 @@ def _sort_next( return ak.contents.IndexedOptionArray( outindex, out, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ).simplify_optiontype() # Otherwise, if we are rearranging (e.g sorting) the contents of this layout, # then we do NOT want to return an optional layout @@ -1400,16 +1414,16 @@ def _reduce_next( inner = ak.contents.IndexedOptionArray( outindex, out_content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ).simplify_optiontype() # Re-wrap content return ak.contents.ListOffsetArray( outoffsets, inner, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _combinations(self, n, replacement, recordlookup, parameters, axis, depth): @@ -1423,7 +1437,7 @@ def _combinations(self, n, replacement, recordlookup, parameters, axis, depth): n, replacement, recordlookup, parameters, posaxis, depth ) out2 = ak.contents.IndexedOptionArray( - outindex, out, parameters, self._nplike + outindex, out, parameters=parameters, nplike=self._nplike ) return out2.simplify_optiontype() @@ -1480,15 +1494,15 @@ def _pad_none(self, target, axis, depth, clip): return ak.contents.IndexedOptionArray( index, next, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ).simplify_optiontype() else: return ak.contents.IndexedOptionArray( self._index, self._content._pad_none(target, posaxis, depth, clip), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _to_arrow(self, pyarrow, mask_node, validbytes, length, options): @@ -1506,8 +1520,8 @@ def _to_arrow(self, pyarrow, mask_node, validbytes, length, options): next = ak.contents.IndexedArray( ak.index.Index(index), self._content, - next_parameters, - self._nplike, + parameters=next_parameters, + nplike=self._nplike, ) return next._to_arrow( pyarrow, @@ -1607,8 +1621,8 @@ def continuation(): lateral_context, options, ), - self._parameters if options["keep_parameters"] else None, - self._nplike, + parameters=self._parameters if options["keep_parameters"] else None, + nplike=self._nplike, ) else: @@ -1651,8 +1665,8 @@ def packed(self): return ak.contents.IndexedOptionArray( self._index, self._content.packed(), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: @@ -1667,8 +1681,8 @@ def packed(self): return ak.contents.IndexedOptionArray( ak.index.Index(new_index, nplike=self.nplike), self.project().packed(), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _to_list(self, behavior, json_conversions): @@ -1691,7 +1705,9 @@ def _to_list(self, behavior, json_conversions): def _to_nplike(self, nplike): index = self._index._to_nplike(nplike) content = self._content._to_nplike(nplike) - return IndexedOptionArray(index, content, self.parameters, nplike=nplike) + return IndexedOptionArray( + index, content, parameters=self.parameters, nplike=nplike + ) def _layout_equal(self, other, index_dtype=True, numpyarray=True): return self.index.layout_equal( diff --git a/src/awkward/contents/listarray.py b/src/awkward/contents/listarray.py index 7edc402347..e7a554b203 100644 --- a/src/awkward/contents/listarray.py +++ b/src/awkward/contents/listarray.py @@ -19,6 +19,7 @@ def copy( starts=unset, stops=unset, content=unset, + *, parameters=unset, nplike=unset, ): @@ -26,8 +27,8 @@ def copy( self._starts if starts is unset else starts, self._stops if stops is unset else stops, self._content if content is unset else content, - self._parameters if parameters is unset else parameters, - self._nplike if nplike is unset else nplike, + parameters=self._parameters if parameters is unset else parameters, + nplike=self._nplike if nplike is unset else nplike, ) def __copy__(self): @@ -41,7 +42,7 @@ def __deepcopy__(self, memo): parameters=copy.deepcopy(self._parameters, memo), ) - def __init__(self, starts, stops, content, parameters=None, nplike=None): + def __init__(self, starts, stops, content, *, parameters=None, nplike=None): if not isinstance(starts, Index) and starts.dtype in ( np.dtype(np.int32), np.dtype(np.uint32), @@ -131,8 +132,8 @@ def typetracer(self): ak.index.Index(self._starts.raw(tt)), ak.index.Index(self._stops.raw(tt)), self._content.typetracer, - self._parameters, - tt, + parameters=self._parameters, + nplike=tt, ) @property @@ -144,8 +145,8 @@ def _forget_length(self): self._starts.forget_length(), self._stops, self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def __repr__(self): @@ -169,8 +170,8 @@ def merge_parameters(self, parameters): self._starts, self._stops, self._content, - ak._util.merge_parameters(self._parameters, parameters), - self._nplike, + parameters=ak._util.merge_parameters(self._parameters, parameters), + nplike=self._nplike, ) def to_ListOffsetArray64(self, start_at_zero=False): @@ -184,8 +185,8 @@ def to_ListOffsetArray64(self, start_at_zero=False): return ListOffsetArray( ak.index.Index(offsets, nplike=self._nplike), self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) elif self._nplike.index_nplike.array_equal(starts[1:], stops[:-1]): @@ -200,8 +201,8 @@ def to_ListOffsetArray64(self, start_at_zero=False): return ListOffsetArray( ak.index.Index(offsets, nplike=self._nplike), self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ).to_ListOffsetArray64(start_at_zero=start_at_zero) else: @@ -236,8 +237,8 @@ def _getitem_range(self, where): self._starts[start:stop], self._stops[start:stop], self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _getitem_field(self, where, only_fields=()): @@ -245,8 +246,8 @@ def _getitem_field(self, where, only_fields=()): self._starts, self._stops, self._content._getitem_field(where, only_fields), - None, - self._nplike, + parameters=None, + nplike=self._nplike, ) def _getitem_fields(self, where, only_fields=()): @@ -254,8 +255,8 @@ def _getitem_fields(self, where, only_fields=()): self._starts, self._stops, self._content._getitem_fields(where, only_fields), - None, - self._nplike, + parameters=None, + nplike=self._nplike, ) def _carry(self, carry, allow_lazy): @@ -271,8 +272,8 @@ def _carry(self, carry, allow_lazy): nextstarts, nextstops, self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _compact_offsets64(self, start_at_zero): @@ -308,7 +309,11 @@ def _getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail): raise ak._errors.index_error( self, ak.contents.ListArray( - slicestarts, slicestops, slicecontent, None, self._nplike + slicestarts, + slicestops, + slicecontent, + parameters=None, + nplike=self._nplike, ), "cannot fit jagged slice with length {} into {} of size {}".format( slicestarts.length, type(self).__name__, self.length @@ -355,7 +360,7 @@ def _getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail): ) return ak.contents.ListOffsetArray( - outoffsets, outcontent, self._parameters, self._nplike + outoffsets, outcontent, parameters=self._parameters, nplike=self._nplike ) elif isinstance(slicecontent, ak.contents.NumpyArray): @@ -421,7 +426,7 @@ def _getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail): outcontent = nextcontent._getitem_next(nexthead, nexttail, None) return ak.contents.ListOffsetArray( - outoffsets, outcontent, None, self._nplike + outoffsets, outcontent, parameters=None, nplike=self._nplike ) elif isinstance(slicecontent, ak.contents.IndexedOptionArray): @@ -429,7 +434,11 @@ def _getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail): raise ak._errors.index_error( self, ak.contents.ListArray( - slicestarts, slicestops, slicecontent, None, self._nplike + slicestarts, + slicestops, + slicecontent, + parameters=None, + nplike=self._nplike, ), "jagged slice length differs from array length", ) @@ -503,7 +512,10 @@ def _getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail): as_list_offset_array = self.to_ListOffsetArray64(True) nextcontent = as_list_offset_array._content._carry(nextcarry, True) next = ak.contents.ListOffsetArray( - smalloffsets, nextcontent, self._parameters, self._nplike + smalloffsets, + nextcontent, + parameters=self._parameters, + nplike=self._nplike, ) out = next._getitem_next_jagged( smalloffsets[:-1], smalloffsets[1:], slicecontent._content, tail @@ -521,15 +533,18 @@ def _getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail): else: missing_trim = missing indexedoptionarray = ak.contents.IndexedOptionArray( - missing_trim, content, self._parameters, self._nplike + missing_trim, + content, + parameters=self._parameters, + nplike=self._nplike, ) if isinstance(self._nplike, ak._typetracer.TypeTracer): indexedoptionarray = indexedoptionarray.typetracer return ak.contents.ListOffsetArray( largeoffsets, indexedoptionarray.simplify_optiontype(), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: raise ak._errors.wrap_error( @@ -664,8 +679,8 @@ def _getitem_next(self, head, tail, advanced): return ak.contents.ListOffsetArray( nextoffsets, nextcontent._getitem_next(nexthead, nexttail, advanced), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: if self._nplike.known_shape: @@ -714,8 +729,8 @@ def _getitem_next(self, head, tail, advanced): return ak.contents.ListOffsetArray( nextoffsets, nextcontent._getitem_next(nexthead, nexttail, nextadvanced), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) elif isinstance(head, str): @@ -868,7 +883,7 @@ def _getitem_next(self, head, tail, advanced): ) return ak.contents.RegularArray( - down, headlength, 1, self._parameters, self._nplike + down, headlength, 1, parameters=self._parameters, nplike=self._nplike ) elif isinstance(head, ak.contents.IndexedOptionArray): @@ -905,7 +920,7 @@ def num(self, axis, depth=0): self.length, ) ) - return ak.contents.NumpyArray(tonum, None, self._nplike) + return ak.contents.NumpyArray(tonum, parameters=None, nplike=self._nplike) else: return self.to_ListOffsetArray64(True).num(posaxis, depth) @@ -1061,7 +1076,11 @@ def mergemany(self, others): pass next = ak.contents.ListArray( - nextstarts, nextstops, nextcontent, parameters, self._nplike + nextstarts, + nextstops, + nextcontent, + parameters=parameters, + nplike=self._nplike, ) if len(tail) == 0: @@ -1078,8 +1097,8 @@ def fill_none(self, value): self._starts, self._stops, self._content.fill_none(value), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _local_index(self, axis, depth): @@ -1108,16 +1127,16 @@ def _local_index(self, axis, depth): return ak.contents.ListOffsetArray( offsets, ak.contents.NumpyArray(localindex), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: return ak.contents.ListArray( self._starts, self._stops, self._content._local_index(posaxis, depth + 1), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def numbers_to_type(self, name): @@ -1125,8 +1144,8 @@ def numbers_to_type(self, name): self._starts, self._stops, self._content.numbers_to_type(name), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _is_unique(self, negaxis, starts, parents, outlength): @@ -1334,24 +1353,24 @@ def _pad_none(self, target, axis, depth, clip): next = ak.contents.IndexedOptionArray( index, self._content, - None, - self._nplike, + parameters=None, + nplike=self._nplike, ) return ak.contents.ListArray( starts_, stops_, next.simplify_optiontype(), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: return ak.contents.ListArray( self._starts, self._stops, self._content._pad_none(target, posaxis, depth + 1, clip), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: return self.to_ListOffsetArray64(True)._pad_none( @@ -1408,8 +1427,8 @@ def continuation(): lateral_context, options, ), - self._parameters if options["keep_parameters"] else None, - self._nplike, + parameters=self._parameters if options["keep_parameters"] else None, + nplike=self._nplike, ) else: diff --git a/src/awkward/contents/listoffsetarray.py b/src/awkward/contents/listoffsetarray.py index c73d7c36fe..600e381263 100644 --- a/src/awkward/contents/listoffsetarray.py +++ b/src/awkward/contents/listoffsetarray.py @@ -18,14 +18,15 @@ def copy( self, offsets=unset, content=unset, + *, parameters=unset, nplike=unset, ): return ListOffsetArray( self._offsets if offsets is unset else offsets, self._content if content is unset else content, - self._parameters if parameters is unset else parameters, - self._nplike if nplike is unset else nplike, + parameters=self._parameters if parameters is unset else parameters, + nplike=self._nplike if nplike is unset else nplike, ) def __copy__(self): @@ -38,7 +39,7 @@ def __deepcopy__(self, memo): parameters=copy.deepcopy(self._parameters, memo), ) - def __init__(self, offsets, content, parameters=None, nplike=None): + def __init__(self, offsets, content, *, parameters=None, nplike=None): if not isinstance(offsets, Index) and offsets.dtype in ( np.dtype(np.int32), np.dtype(np.uint32), @@ -114,8 +115,8 @@ def typetracer(self): return ListOffsetArray( ak.index.Index(self._offsets.raw(tt)), self._content.typetracer, - self._parameters, - tt, + parameters=self._parameters, + nplike=tt, ) @property @@ -126,8 +127,8 @@ def _forget_length(self): return ListOffsetArray( self._offsets.forget_length(), self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def __repr__(self): @@ -149,8 +150,8 @@ def merge_parameters(self, parameters): return ListOffsetArray( self._offsets, self._content, - ak._util.merge_parameters(self._parameters, parameters), - self._nplike, + parameters=ak._util.merge_parameters(self._parameters, parameters), + nplike=self._nplike, ) def to_ListOffsetArray64(self, start_at_zero=False): @@ -171,7 +172,9 @@ def to_ListOffsetArray64(self, start_at_zero=False): else: offsets, content = self._offsets, self._content - return ListOffsetArray(offsets, content, self._parameters, self._nplike) + return ListOffsetArray( + offsets, content, parameters=self._parameters, nplike=self._nplike + ) else: offsets = self._compact_offsets64(start_at_zero) @@ -198,8 +201,8 @@ def to_RegularArray(self): content, size[0], self._offsets.length - 1, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _getitem_nothing(self): @@ -228,26 +231,23 @@ def _getitem_range(self, where): nplike=self.nplike, ) return ListOffsetArray( - offsets, - self._content, - self._parameters, - self._nplike, + offsets, self._content, parameters=self._parameters, nplike=self._nplike ) def _getitem_field(self, where, only_fields=()): return ListOffsetArray( self._offsets, self._content._getitem_field(where, only_fields), - None, - self._nplike, + parameters=None, + nplike=self._nplike, ) def _getitem_fields(self, where, only_fields=()): return ListOffsetArray( self._offsets, self._content._getitem_fields(where, only_fields), - None, - self._nplike, + parameters=None, + nplike=self._nplike, ) def _carry(self, carry, allow_lazy): @@ -263,8 +263,8 @@ def _carry(self, carry, allow_lazy): nextstarts, nextstops, self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _compact_offsets64(self, start_at_zero): @@ -327,15 +327,17 @@ def _broadcast_tooffsets64(self, offsets): nextcontent = self._content._carry(nextcarry, True) - return ListOffsetArray(offsets, nextcontent, self._parameters, self._nplike) + return ListOffsetArray( + offsets, nextcontent, parameters=self._parameters, nplike=self._nplike + ) def _getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail): out = ak.contents.ListArray( self.starts, self.stops, self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return out._getitem_next_jagged(slicestarts, slicestops, slicecontent, tail) @@ -447,8 +449,8 @@ def _getitem_next(self, head, tail, advanced): return ak.contents.ListOffsetArray( nextoffsets, nextcontent._getitem_next(nexthead, nexttail, advanced), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: @@ -493,8 +495,8 @@ def _getitem_next(self, head, tail, advanced): return ak.contents.ListOffsetArray( nextoffsets, nextcontent._getitem_next(nexthead, nexttail, nextadvanced), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) elif isinstance(head, str): @@ -595,8 +597,8 @@ def _getitem_next(self, head, tail, advanced): self.starts, self.stops, self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return listarray._getitem_next(head, tail, advanced) @@ -634,12 +636,12 @@ def num(self, axis, depth=0): self.length, ) ) - return ak.contents.NumpyArray(tonum, None, self._nplike) + return ak.contents.NumpyArray(tonum, parameters=None, nplike=self._nplike) else: next = self._content.num(posaxis, depth + 1) offsets = self._compact_offsets64(True) return ak.contents.ListOffsetArray( - offsets, next, self.parameters, self._nplike + offsets, next, parameters=self.parameters, nplike=self._nplike ) def _offsets_and_flattened(self, axis, depth): @@ -663,7 +665,10 @@ def _offsets_and_flattened(self, axis, depth): return ( offsets, ListOffsetArray( - self._offsets, flattened, self._parameters, self._nplike + self._offsets, + flattened, + parameters=self._parameters, + nplike=self._nplike, ), ) @@ -672,7 +677,10 @@ def _offsets_and_flattened(self, axis, depth): return ( offsets, ListOffsetArray( - tooffsets, flattened, self._parameters, self._nplike + tooffsets, + flattened, + parameters=self._parameters, + nplike=self._nplike, ), ) @@ -702,7 +710,10 @@ def _offsets_and_flattened(self, axis, depth): return ( offsets, ListOffsetArray( - tooffsets, flattened, self._parameters, self._nplike + tooffsets, + flattened, + parameters=self._parameters, + nplike=self._nplike, ), ) @@ -736,7 +747,11 @@ def mergemany(self, others): if len(others) == 0: return self listarray = ak.contents.ListArray( - self.starts, self.stops, self._content, self._parameters, self._nplike + self.starts, + self.stops, + self._content, + parameters=self._parameters, + nplike=self._nplike, ) out = listarray.mergemany(others) @@ -752,8 +767,8 @@ def fill_none(self, value): return ListOffsetArray( self._offsets, self._content.fill_none(value), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _local_index(self, axis, depth): @@ -782,23 +797,23 @@ def _local_index(self, axis, depth): return ak.contents.ListOffsetArray( offsets, ak.contents.NumpyArray(localindex), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: return ak.contents.ListOffsetArray( self._offsets, self._content._local_index(posaxis, depth + 1), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def numbers_to_type(self, name): return ak.contents.ListOffsetArray( self._offsets, self._content.numbers_to_type(name), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _is_unique(self, negaxis, starts, parents, outlength): @@ -823,10 +838,7 @@ def _is_unique(self, negaxis, starts, parents, outlength): if isinstance(self._content, ak.contents.NumpyArray): out, outoffsets = self._content._as_unique_strings(self._offsets) out2 = ak.contents.ListOffsetArray( - outoffsets, - out, - self._parameters, - self._nplike, + outoffsets, out, parameters=self._parameters, nplike=self._nplike ) return out2.length == self.length @@ -879,10 +891,7 @@ def _unique(self, negaxis, starts, parents, outlength): if isinstance(self._content, ak.contents.NumpyArray): out, nextoffsets = self._content._as_unique_strings(self._offsets) return ak.contents.ListOffsetArray( - nextoffsets, - out, - self._parameters, - self._nplike, + nextoffsets, out, parameters=self._parameters, nplike=self._nplike ) if not branch and (negaxis == depth): @@ -931,8 +940,8 @@ def _unique(self, negaxis, starts, parents, outlength): return ak.contents.ListOffsetArray( outcontent._compact_offsets64(True), outcontent._content._carry(outcarry, False), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: @@ -969,10 +978,7 @@ def _unique(self, negaxis, starts, parents, outlength): outoffsets = self._compact_offsets64(True) return ak.contents.ListOffsetArray( - outoffsets, - outcontent, - self._parameters, - self._nplike, + outoffsets, outcontent, parameters=self._parameters, nplike=self._nplike ) def _argsort_next( @@ -1033,7 +1039,9 @@ def _argsort_next( True, ) ) - return ak.contents.NumpyArray(nextcarry, None, self._nplike) + return ak.contents.NumpyArray( + nextcarry, parameters=None, nplike=self._nplike + ) if not branch and (negaxis == depth): if ( @@ -1123,10 +1131,7 @@ def _argsort_next( out_offsets = self._compact_offsets64(True) out = outcontent._carry(outcarry, False) return ak.contents.ListOffsetArray( - out_offsets, - out, - self._parameters, - self._nplike, + out_offsets, out, parameters=self._parameters, nplike=self._nplike ) else: nextparents = ak.index.Index64.empty( @@ -1163,10 +1168,7 @@ def _argsort_next( ) outoffsets = self._compact_offsets64(True) return ak.contents.ListOffsetArray( - outoffsets, - outcontent, - self._parameters, - self._nplike, + outoffsets, outcontent, parameters=self._parameters, nplike=self._nplike ) def _sort_next( @@ -1270,8 +1272,8 @@ def _sort_next( return ak.contents.ListOffsetArray( self._compact_offsets64(True), outcontent._carry(outcarry, False), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: nextparents = ak.index.Index64.empty( @@ -1307,10 +1309,7 @@ def _sort_next( ) outoffsets = self._compact_offsets64(True) return ak.contents.ListOffsetArray( - outoffsets, - outcontent, - self._parameters, - self._nplike, + outoffsets, outcontent, parameters=self._parameters, nplike=self._nplike ) def _combinations(self, n, replacement, recordlookup, parameters, axis, depth): @@ -1400,10 +1399,10 @@ def _combinations(self, n, replacement, recordlookup, parameters, axis, depth): contents.append(self._content._carry(ptr, True)) recordarray = ak.contents.RecordArray( - contents, recordlookup, None, parameters, self._nplike + contents, recordlookup, None, parameters=parameters, nplike=self._nplike ) return ak.contents.ListOffsetArray( - offsets, recordarray, self._parameters, self._nplike + offsets, recordarray, parameters=self._parameters, nplike=self._nplike ) else: compact = self.to_ListOffsetArray64(True) @@ -1411,7 +1410,7 @@ def _combinations(self, n, replacement, recordlookup, parameters, axis, depth): n, replacement, recordlookup, parameters, posaxis, depth + 1 ) return ak.contents.ListOffsetArray( - compact.offsets, next, self._parameters, self._nplike + compact.offsets, next, parameters=self._parameters, nplike=self._nplike ) def _reduce_next( @@ -1531,20 +1530,12 @@ def _reduce_next( ) out = ak.contents.ListArray( - outstarts, - outstops, - outcontent, - None, - self._nplike, + outstarts, outstops, outcontent, parameters=None, nplike=self._nplike ) if keepdims: out = ak.contents.RegularArray( - out, - 1, - self.length, - None, - self._nplike, + out, 1, self.length, parameters=None, nplike=self._nplike ) return out @@ -1611,10 +1602,7 @@ def _reduce_next( outcontent = outcontent.to_ListOffsetArray64(False) return ak.contents.ListOffsetArray( - outoffsets, - outcontent, - None, - self._nplike, + outoffsets, outcontent, parameters=None, nplike=self._nplike ) def _rearrange_prepare_next(self, outlength, parents): @@ -1781,14 +1769,14 @@ def _pad_none(self, target, axis, depth, clip): next = ak.contents.IndexedOptionArray( outindex, self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return ak.contents.ListOffsetArray( offsets_, next.simplify_optiontype(), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: starts_ = ak.index.Index64.empty(self._offsets.length - 1, self._nplike) @@ -1829,22 +1817,22 @@ def _pad_none(self, target, axis, depth, clip): next = ak.contents.IndexedOptionArray( outindex, self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return ak.contents.RegularArray( next.simplify_optiontype(), target, self.length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: return ak.contents.ListOffsetArray( self._offsets, self._content._pad_none(target, posaxis, depth + 1, clip), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _to_arrow(self, pyarrow, mask_node, validbytes, length, options): @@ -1878,8 +1866,8 @@ def _to_arrow(self, pyarrow, mask_node, validbytes, length, options): ak.index.Index(new_starts), ak.index.Index(new_stops), self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return next.to_ListOffsetArray64(True)._to_arrow( pyarrow, mask_node, validbytes, length, options @@ -2002,8 +1990,8 @@ def continuation(): lateral_context, options, ), - self._parameters if options["keep_parameters"] else None, - self._nplike, + parameters=self._parameters if options["keep_parameters"] else None, + nplike=self._nplike, ) else: @@ -2041,7 +2029,9 @@ def packed(self): content = next._content.packed() if content.length != next._offsets[-1]: content = content[: next._offsets[-1]] - return ListOffsetArray(next._offsets, content, next._parameters, self._nplike) + return ListOffsetArray( + next._offsets, content, parameters=next._parameters, nplike=self._nplike + ) def _to_list(self, behavior, json_conversions): starts, stops = self.starts, self.stops diff --git a/src/awkward/contents/numpyarray.py b/src/awkward/contents/numpyarray.py index 488b6b4d3a..3e383018fc 100644 --- a/src/awkward/contents/numpyarray.py +++ b/src/awkward/contents/numpyarray.py @@ -17,13 +17,14 @@ class NumpyArray(Content): def copy( self, data=unset, + *, parameters=unset, nplike=unset, ): return NumpyArray( self._data if data is unset else data, - self._parameters if parameters is unset else parameters, - self._nplike if nplike is unset else nplike, + parameters=self._parameters if parameters is unset else parameters, + nplike=self._nplike if nplike is unset else nplike, ) def __copy__(self): @@ -35,7 +36,7 @@ def __deepcopy__(self, memo): parameters=copy.deepcopy(self._parameters, memo), ) - def __init__(self, data, parameters=None, nplike=None): + def __init__(self, data, *, parameters=None, nplike=None): if nplike is None: nplike = ak.nplikes.nplike_of(data) if isinstance(data, ak.index.Index): @@ -111,11 +112,7 @@ def _to_buffers(self, form, getkey, container, nplike): @property def typetracer(self): tt = ak._typetracer.TypeTracer.instance() - return NumpyArray( - self.raw(tt), - self._parameters, - tt, - ) + return NumpyArray(self.raw(tt), parameters=self._parameters, nplike=tt) @property def length(self): @@ -123,9 +120,7 @@ def length(self): def _forget_length(self): return NumpyArray( - self._data.forget_length(), - self._parameters, - self._nplike, + self._data.forget_length(), parameters=self._parameters, nplike=self._nplike ) def __repr__(self): @@ -168,8 +163,8 @@ def _repr(self, indent, pre, post): def merge_parameters(self, parameters): return NumpyArray( self._data, - ak._util.merge_parameters(self._parameters, parameters), - self._nplike, + parameters=ak._util.merge_parameters(self._parameters, parameters), + nplike=self._nplike, ) def to_RegularArray(self): @@ -178,10 +173,10 @@ def to_RegularArray(self): for x in shape: zeroslen.append(zeroslen[-1] * x) - out = NumpyArray(self._data.reshape(-1), None, self._nplike) + out = NumpyArray(self._data.reshape(-1), parameters=None, nplike=self._nplike) for i in range(len(shape) - 1, 0, -1): out = ak.contents.RegularArray( - out, shape[i], zeroslen[i], None, self._nplike + out, shape[i], zeroslen[i], parameters=None, nplike=self._nplike ) out._parameters = self._parameters return out @@ -198,9 +193,7 @@ def __iter__(self): def _getitem_nothing(self): tmp = self._data[0:0] return NumpyArray( - tmp.reshape((0,) + tmp.shape[2:]), - None, - self._nplike, + tmp.reshape((0,) + tmp.shape[2:]), parameters=None, nplike=self._nplike ) def _getitem_at(self, where): @@ -213,7 +206,7 @@ def _getitem_at(self, where): raise ak._errors.index_error(self, where, str(err)) from err if hasattr(out, "shape") and len(out.shape) != 0: - return NumpyArray(out, None, self._nplike) + return NumpyArray(out, parameters=None, nplike=self._nplike) else: return out @@ -229,11 +222,7 @@ def _getitem_range(self, where): except IndexError as err: raise ak._errors.index_error(self, where, str(err)) from err - return NumpyArray( - out, - self._parameters, - self._nplike, - ) + return NumpyArray(out, parameters=self._parameters, nplike=self._nplike) def _getitem_field(self, where, only_fields=()): raise ak._errors.index_error(self, where, "not an array of records") @@ -249,18 +238,18 @@ def _carry(self, carry, allow_lazy): nextdata = self._data[carry.data] except IndexError as err: raise ak._errors.index_error(self, carry.data, str(err)) from err - return NumpyArray( - nextdata, - self._parameters, - self._nplike, - ) + return NumpyArray(nextdata, parameters=self._parameters, nplike=self._nplike) def _getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail): if self._data.ndim == 1: raise ak._errors.index_error( self, ak.contents.ListArray( - slicestarts, slicestops, slicecontent, None, self._nplike + slicestarts, + slicestops, + slicecontent, + parameters=None, + nplike=self._nplike, ), "too many jagged slice dimensions for array", ) @@ -283,7 +272,7 @@ def _getitem_next(self, head, tail, advanced): raise ak._errors.index_error(self, (head,) + tail, str(err)) from err if hasattr(out, "shape") and len(out.shape) != 0: - return NumpyArray(out, None, self._nplike) + return NumpyArray(out, parameters=None, nplike=self._nplike) else: return out @@ -293,7 +282,7 @@ def _getitem_next(self, head, tail, advanced): out = self._data[where] except IndexError as err: raise ak._errors.index_error(self, (head,) + tail, str(err)) from err - out2 = NumpyArray(out, self._parameters, self._nplike) + out2 = NumpyArray(out, parameters=self._parameters, nplike=self._nplike) return out2 elif isinstance(head, str): @@ -316,7 +305,7 @@ def _getitem_next(self, head, tail, advanced): except IndexError as err: raise ak._errors.index_error(self, (head,) + tail, str(err)) from err - return NumpyArray(out, self._parameters, self._nplike) + return NumpyArray(out, parameters=self._parameters, nplike=self._nplike) elif isinstance(head, ak.contents.ListOffsetArray): where = (slice(None), head) + tail @@ -324,7 +313,7 @@ def _getitem_next(self, head, tail, advanced): out = self._data[where] except IndexError as err: raise ak._errors.index_error(self, (head,) + tail, str(err)) from err - out2 = NumpyArray(out, self._parameters, self._nplike) + out2 = NumpyArray(out, parameters=self._parameters, nplike=self._nplike) return out2 elif isinstance(head, ak.contents.IndexedOptionArray): @@ -365,7 +354,7 @@ def num(self, axis, depth=0): ) ) return ak.contents.NumpyArray( - tonum.data.reshape(shape), self.parameters, self._nplike + tonum.data.reshape(shape), parameters=self.parameters, nplike=self._nplike ) def _offsets_and_flattened(self, axis, depth): @@ -468,7 +457,7 @@ def mergemany(self, others): contiguous_arrays = self._nplike.concatenate(contiguous_arrays) - next = NumpyArray(contiguous_arrays, parameters, self._nplike) + next = NumpyArray(contiguous_arrays, parameters=parameters, nplike=self._nplike) if len(tail) == 0: return next @@ -499,8 +488,8 @@ def contiguous(self): else: return ak.contents.NumpyArray( self._nplike.ascontiguousarray(self._data), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) @property @@ -618,7 +607,7 @@ def _as_unique_strings(self, offsets): outlength.data, ) ) - out2 = NumpyArray(out, self._parameters, self._nplike) + out2 = NumpyArray(out, parameters=self._parameters, nplike=self._nplike) return out2, nextoffsets[: outlength[0]] @@ -634,8 +623,8 @@ def numbers_to_type(self, name): dtype = primitive_to_dtype(name) return NumpyArray( self._nplike.asarray(self._data, dtype=dtype), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _is_unique(self, negaxis, starts, parents, outlength): @@ -714,8 +703,8 @@ def _unique(self, negaxis, starts, parents, outlength): return ak.contents.NumpyArray( self._nplike.asarray(out[: nextlength[0]], self.dtype), - None, - self._nplike, + parameters=None, + nplike=self._nplike, ) # axis is not None @@ -823,8 +812,8 @@ def _unique(self, negaxis, starts, parents, outlength): return ak.contents.ListOffsetArray( outoffsets, ak.contents.NumpyArray(out), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _argsort_next( @@ -943,7 +932,7 @@ def _argsort_next( starts.length, ) ) - out = NumpyArray(nextcarry, None, self._nplike) + out = NumpyArray(nextcarry, parameters=None, nplike=self._nplike) return out def _sort_next( @@ -1026,7 +1015,9 @@ def _sort_next( ) ) return ak.contents.NumpyArray( - self._nplike.asarray(out, self.dtype), None, self._nplike + self._nplike.asarray(out, self.dtype), + parameters=None, + nplike=self._nplike, ) def _combinations(self, n, replacement, recordlookup, parameters, axis, depth): @@ -1149,20 +1140,12 @@ def _reduce_next( ) out = ak.contents.ByteMaskedArray( - outmask, - out, - False, - None, - self._nplike, + outmask, out, False, parameters=None, nplike=self._nplike ) if keepdims: out = ak.contents.RegularArray( - out, - 1, - self.length, - None, - self._nplike, + out, 1, self.length, parameters=None, nplike=self._nplike ) return out @@ -1255,7 +1238,7 @@ def continuation(): if options["keep_parameters"]: return self else: - return NumpyArray(self._data, None, self._nplike) + return NumpyArray(self._data, parameters=None, nplike=self._nplike) else: diff --git a/src/awkward/contents/recordarray.py b/src/awkward/contents/recordarray.py index 2c1edfae1d..3fcf2d3131 100644 --- a/src/awkward/contents/recordarray.py +++ b/src/awkward/contents/recordarray.py @@ -21,6 +21,7 @@ def copy( contents=unset, fields=unset, length=unset, + *, parameters=unset, nplike=unset, ): @@ -28,8 +29,8 @@ def copy( self._contents if contents is unset else contents, self._fields if fields is unset else fields, self._length if length is unset else length, - self._parameters if parameters is unset else parameters, - self._nplike if nplike is unset else nplike, + parameters=self._parameters if parameters is unset else parameters, + nplike=self._nplike if nplike is unset else nplike, ) def __copy__(self): @@ -47,6 +48,7 @@ def __init__( contents, fields, length=None, + *, parameters=None, nplike=None, ): @@ -171,11 +173,7 @@ def is_tuple(self): @property def as_tuple(self): return RecordArray( - self._contents, - None, - self._length, - None, - self._nplike, + self._contents, None, self._length, parameters=None, nplike=self._nplike ) Form = RecordForm @@ -205,8 +203,8 @@ def typetracer(self): [x.typetracer for x in self._contents], self._fields, self._length, - self._parameters, - tt, + parameters=self._parameters, + nplike=tt, ) @property @@ -218,8 +216,8 @@ def _forget_length(self): [x._forget_length() for x in self._contents], self._fields, ak._typetracer.UnknownLength, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def __repr__(self): @@ -258,8 +256,8 @@ def merge_parameters(self, parameters): self._contents, self._fields, self._length, - ak._util.merge_parameters(self._parameters, parameters), - self._nplike, + parameters=ak._util.merge_parameters(self._parameters, parameters), + nplike=self._nplike, ) def index_to_field(self, index): @@ -304,8 +302,8 @@ def _getitem_range(self, where): [], self._fields, stop - start, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: nextslice = slice(start, stop) @@ -313,8 +311,8 @@ def _getitem_range(self, where): [x._getitem_range(nextslice) for x in self._contents], self._fields, stop - start, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _getitem_field(self, where, only_fields=()): @@ -349,11 +347,7 @@ def _getitem_fields(self, where, only_fields=()): ] return RecordArray( - contents, - fields, - self._length, - None, - self._nplike, + contents, fields, self._length, parameters=None, nplike=self._nplike ) def _carry(self, carry, allow_lazy): @@ -374,10 +368,7 @@ def _carry(self, carry, allow_lazy): nextindex = ak.index.Index64(where, nplike=self.nplike) return ak.contents.IndexedArray( - nextindex, - self, - None, - self._nplike, + nextindex, self, parameters=None, nplike=self._nplike ) else: @@ -397,8 +388,8 @@ def _carry(self, carry, allow_lazy): contents, self._fields, length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail): @@ -409,7 +400,9 @@ def _getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail): slicestarts, slicestops, slicecontent, tail ) ) - return RecordArray(contents, self._fields, self._length, None, self._nplike) + return RecordArray( + contents, self._fields, self._length, parameters=None, nplike=self._nplike + ) def _getitem_next(self, head, tail, advanced): if head == (): @@ -445,7 +438,9 @@ def _getitem_next(self, head, tail, advanced): or advanced is None ): parameters = self._parameters - next = RecordArray(contents, self._fields, None, parameters, self._nplike) + next = RecordArray( + contents, self._fields, None, parameters=parameters, nplike=self._nplike + ) return next._getitem_next(nexthead, nexttail, advanced) def num(self, axis, depth=0): @@ -453,10 +448,16 @@ def num(self, axis, depth=0): if posaxis == depth: npsingle = self._nplike.index_nplike.full((1,), self.length, np.int64) single = ak.index.Index64(npsingle, nplike=self._nplike) - singleton = ak.contents.NumpyArray(single, None, self._nplike) + singleton = ak.contents.NumpyArray( + single, parameters=None, nplike=self._nplike + ) contents = [singleton] * len(self._contents) record = ak.contents.RecordArray( - contents, self._fields, 1, self._parameters, self._nplike + contents, + self._fields, + 1, + parameters=self._parameters, + nplike=self._nplike, ) return record[0] else: @@ -467,8 +468,8 @@ def num(self, axis, depth=0): contents, self._fields, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _offsets_and_flattened(self, axis, depth): @@ -502,8 +503,8 @@ def _offsets_and_flattened(self, axis, depth): contents, self._fields, self._length, - None, - self._nplike, + parameters=None, + nplike=self._nplike, ), ) @@ -653,7 +654,11 @@ def mergemany(self, others): minlength += x.length next = RecordArray( - nextcontents, self._fields, minlength, parameters, self._nplike + nextcontents, + self._fields, + minlength, + parameters=parameters, + nplike=self._nplike, ) if len(tail) == 0: @@ -679,8 +684,8 @@ def fill_none(self, value): contents, self._fields, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _local_index(self, axis, depth): @@ -695,8 +700,8 @@ def _local_index(self, axis, depth): contents, self._fields, self.length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def numbers_to_type(self, name): @@ -707,8 +712,8 @@ def numbers_to_type(self, name): contents, self._fields, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _is_unique(self, negaxis, starts, parents, outlength): @@ -739,7 +744,9 @@ def _sort_next( ): if self._fields is None or len(self._fields) == 0: return ak.contents.NumpyArray( - self._nplike.instance().empty(0, np.int64), None, self._nplike + self._nplike.instance().empty(0, np.int64), + parameters=None, + nplike=self._nplike, ) contents = [] @@ -757,7 +764,11 @@ def _sort_next( ) ) return RecordArray( - contents, self._fields, self._length, self._parameters, self._nplike + contents, + self._fields, + self._length, + parameters=self._parameters, + nplike=self._nplike, ) def _combinations(self, n, replacement, recordlookup, parameters, axis, depth): @@ -776,8 +787,8 @@ def _combinations(self, n, replacement, recordlookup, parameters, axis, depth): contents, recordlookup, self.length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _reduce_next( @@ -837,16 +848,16 @@ def _pad_none(self, target, axis, depth, clip): contents, self._fields, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: return ak.contents.RecordArray( contents, self._fields, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _to_arrow(self, pyarrow, mask_node, validbytes, length, options): @@ -956,8 +967,8 @@ def continuation(): ], self._fields, self._length, - self._parameters if options["keep_parameters"] else None, - self._nplike, + parameters=self._parameters if options["keep_parameters"] else None, + nplike=self._nplike, ) else: @@ -999,8 +1010,8 @@ def packed(self): ], self._fields, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _to_list(self, behavior, json_conversions): diff --git a/src/awkward/contents/regulararray.py b/src/awkward/contents/regulararray.py index 2f8e0c31a6..bdc7ca4542 100644 --- a/src/awkward/contents/regulararray.py +++ b/src/awkward/contents/regulararray.py @@ -19,6 +19,7 @@ def copy( content=unset, size=unset, zeros_length=unset, + *, parameters=unset, nplike=unset, ): @@ -26,8 +27,8 @@ def copy( self._content if content is unset else content, self._size if size is unset else size, self._length if zeros_length is unset else zeros_length, - self._parameters if parameters is unset else parameters, - self._nplike if nplike is unset else nplike, + parameters=self._parameters if parameters is unset else parameters, + nplike=self._nplike if nplike is unset else nplike, ) def __copy__(self): @@ -44,6 +45,7 @@ def __init__( content, size, zeros_length=0, + *, parameters=None, nplike=None, ): @@ -116,8 +118,8 @@ def typetracer(self): self._content.typetracer, self._size, self._length, - self._parameters, - tt, + parameters=self._parameters, + nplike=tt, ) @property @@ -129,8 +131,8 @@ def _forget_length(self): self._content._forget_length(), self._size, ak._typetracer.UnknownLength, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def __repr__(self): @@ -154,8 +156,8 @@ def merge_parameters(self, parameters): self._content, self._size, self._length, - ak._util.merge_parameters(self._parameters, parameters), - self._nplike, + parameters=ak._util.merge_parameters(self._parameters, parameters), + nplike=self._nplike, ) def to_ListOffsetArray64(self, start_at_zero=False): @@ -176,8 +178,10 @@ def maybe_to_NumpyArray(self): shape = (self._length, self._size) + content.data.shape[1:] return ak.contents.NumpyArray( content.data.reshape(shape), - ak._util.merge_parameters(self._parameters, content.parameters, True), - self._nplike, + parameters=ak._util.merge_parameters( + self._parameters, content.parameters, True + ), + nplike=self._nplike, ) def _getitem_nothing(self): @@ -204,8 +208,8 @@ def _getitem_range(self, where): self._content._getitem_range(slice(substart, substop)), self._size, zeros_length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _getitem_field(self, where, only_fields=()): @@ -213,8 +217,8 @@ def _getitem_field(self, where, only_fields=()): self._content._getitem_field(where, only_fields), self._size, self._length, - None, - self._nplike, + parameters=None, + nplike=self._nplike, ) def _getitem_fields(self, where, only_fields=()): @@ -222,8 +226,8 @@ def _getitem_fields(self, where, only_fields=()): self._content._getitem_fields(where, only_fields), self._size, self._length, - None, - self._nplike, + parameters=None, + nplike=self._nplike, ) def _carry(self, carry, allow_lazy): @@ -267,8 +271,8 @@ def _carry(self, carry, allow_lazy): self._content._carry(nextcarry, allow_lazy), self._size, where.shape[0], - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _compact_offsets64(self, start_at_zero): @@ -319,7 +323,7 @@ def _broadcast_tooffsets64(self, offsets): ) nextcontent = self._content._carry(nextcarry, True) return ak.contents.ListOffsetArray( - offsets, nextcontent, self._parameters, self._nplike + offsets, nextcontent, parameters=self._parameters, nplike=self._nplike ) else: @@ -334,7 +338,7 @@ def _broadcast_tooffsets64(self, offsets): ) ) return ak.contents.ListOffsetArray( - offsets, self._content, self._parameters, self._nplike + offsets, self._content, parameters=self._parameters, nplike=self._nplike ) def _getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail): @@ -410,8 +414,8 @@ def _getitem_next(self, head, tail, advanced): nextcontent._getitem_next(nexthead, nexttail, advanced), nextsize, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: nextadvanced = ak.index.Index64.empty( @@ -439,8 +443,8 @@ def _getitem_next(self, head, tail, advanced): nextcontent._getitem_next(nexthead, nexttail, nextadvanced), nextsize, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) elif isinstance(head, str): @@ -601,7 +605,11 @@ def _getitem_next(self, head, tail, advanced): ) return RegularArray( - down, headlength, self._length, self._parameters, self._nplike + down, + headlength, + self._length, + parameters=self._parameters, + nplike=self._nplike, ) elif isinstance(head, ak.contents.IndexedOptionArray): @@ -626,11 +634,15 @@ def num(self, axis, depth=0): tonum.data, self._size, self._length ) ) - return ak.contents.NumpyArray(tonum, None, self._nplike) + return ak.contents.NumpyArray(tonum, parameters=None, nplike=self._nplike) else: next = self._content.num(posaxis, depth + 1) return ak.contents.RegularArray( - next, self._size, self._length, self._parameters, self._nplike + next, + self._size, + self._length, + parameters=self._parameters, + nplike=self._nplike, ) def _offsets_and_flattened(self, axis, depth): @@ -693,7 +705,7 @@ def mergemany(self, others): self._content[: self._length * self._size].mergemany(tail_contents), self._size, zeros_length, - parameters, + parameters=parameters, ) else: @@ -704,8 +716,8 @@ def fill_none(self, value): self._content.fill_none(value), self._size, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _local_index(self, axis, depth): @@ -725,16 +737,16 @@ def _local_index(self, axis, depth): ak.contents.NumpyArray(localindex), self._size, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: return ak.contents.RegularArray( self._content._local_index(posaxis, depth + 1), self._size, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def numbers_to_type(self, name): @@ -742,8 +754,8 @@ def numbers_to_type(self, name): self._content.numbers_to_type(name), self._size, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _is_unique(self, negaxis, starts, parents, outlength): @@ -773,8 +785,8 @@ def _unique(self, negaxis, starts, parents, outlength): out._content.to_RegularArray(), out._size, out._length, - out._parameters, - self._nplike, + parameters=out._parameters, + nplike=self._nplike, ) return out @@ -810,8 +822,8 @@ def _argsort_next( out._content.to_RegularArray(), out._size, out._length, - out._parameters, - self._nplike, + parameters=out._parameters, + nplike=self._nplike, ) return out @@ -915,14 +927,18 @@ def _combinations(self, n, replacement, recordlookup, parameters, axis, depth): length = contents[-1].length assert length is not None recordarray = ak.contents.RecordArray( - contents, recordlookup, length, parameters, self._nplike + contents, + recordlookup, + length, + parameters=parameters, + nplike=self._nplike, ) return ak.contents.RegularArray( recordarray, combinationslen, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: next = self._content._getitem_range( @@ -934,8 +950,8 @@ def _combinations(self, n, replacement, recordlookup, parameters, axis, depth): next, self._size, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _reduce_next( @@ -1010,20 +1026,12 @@ def _reduce_next( ) out = ak.contents.RegularArray( - outcontent, - self._size, - outlength, - None, - self._nplike, + outcontent, self._size, outlength, parameters=None, nplike=self._nplike ) if keepdims: out = ak.contents.RegularArray( - out, - 1, - self.length, - None, - self._nplike, + out, 1, self.length, parameters=None, nplike=self._nplike ) return out else: @@ -1133,10 +1141,7 @@ def _reduce_next( ) return ak.contents.ListOffsetArray( - outoffsets, - outcontent, - None, - self._nplike, + outoffsets, outcontent, parameters=None, nplike=self._nplike ) def _validity_error(self, path): @@ -1176,15 +1181,15 @@ def _pad_none(self, target, axis, depth, clip): next = ak.contents.IndexedOptionArray( index, self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return ak.contents.RegularArray( next.simplify_optiontype(), target, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: @@ -1192,8 +1197,8 @@ def _pad_none(self, target, axis, depth, clip): self._content._pad_none(target, posaxis, depth + 1, clip), self._size, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _to_numpy(self, allow_missing): @@ -1292,8 +1297,8 @@ def continuation(): ), self._size, self._length, - self._parameters if options["keep_parameters"] else None, - self._nplike, + parameters=self._parameters if options["keep_parameters"] else None, + nplike=self._nplike, ) else: @@ -1337,8 +1342,8 @@ def packed(self): content, self._size, self._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _to_list(self, behavior, json_conversions): diff --git a/src/awkward/contents/unionarray.py b/src/awkward/contents/unionarray.py index 150d4db364..89c2c3656a 100644 --- a/src/awkward/contents/unionarray.py +++ b/src/awkward/contents/unionarray.py @@ -23,6 +23,7 @@ def copy( tags=unset, index=unset, contents=unset, + *, parameters=unset, nplike=unset, ): @@ -30,8 +31,8 @@ def copy( self._tags if tags is unset else tags, self._index if index is unset else index, self._contents if contents is unset else contents, - self._parameters if parameters is unset else parameters, - self._nplike if nplike is unset else nplike, + parameters=self._parameters if parameters is unset else parameters, + nplike=self._nplike if nplike is unset else nplike, ) def __copy__(self): @@ -45,7 +46,7 @@ def __deepcopy__(self, memo): parameters=copy.deepcopy(self._parameters, memo), ) - def __init__(self, tags, index, contents, parameters=None, nplike=None): + def __init__(self, tags, index, contents, *, parameters=None, nplike=None): if not (isinstance(tags, Index) and tags.dtype == np.dtype(np.int8)): raise ak._errors.wrap_error( TypeError( @@ -165,8 +166,8 @@ def typetracer(self): ak.index.Index(self._tags.raw(tt)), ak.index.Index(self._index.raw(tt)), [x.typetracer for x in self._contents], - self._parameters, - tt, + parameters=self._parameters, + nplike=tt, ) @property @@ -178,8 +179,8 @@ def _forget_length(self): self._tags.forget_length(), self._index, self._contents, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def __repr__(self): @@ -208,8 +209,8 @@ def merge_parameters(self, parameters): self._tags, self._index, self._contents, - ak._util.merge_parameters(self._parameters, parameters), - self._nplike, + parameters=ak._util.merge_parameters(self._parameters, parameters), + nplike=self._nplike, ) def _getitem_nothing(self): @@ -236,8 +237,8 @@ def _getitem_range(self, where): self._tags[start:stop], self._index[start:stop], self._contents, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _getitem_field(self, where, only_fields=()): @@ -245,8 +246,8 @@ def _getitem_field(self, where, only_fields=()): self._tags, self._index, [x._getitem_field(where, only_fields) for x in self._contents], - None, - self._nplike, + parameters=None, + nplike=self._nplike, ).simplify_uniontype() def _getitem_fields(self, where, only_fields=()): @@ -254,8 +255,8 @@ def _getitem_fields(self, where, only_fields=()): self._tags, self._index, [x._getitem_fields(where, only_fields) for x in self._contents], - None, - self._nplike, + parameters=None, + nplike=self._nplike, ).simplify_uniontype() def _carry(self, carry, allow_lazy): @@ -271,8 +272,8 @@ def _carry(self, carry, allow_lazy): nexttags, nextindex, self._contents, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def project(self, index): @@ -405,7 +406,11 @@ def _getitem_next_jagged_generic(self, slicestarts, slicestops, slicecontent, ta raise ak._errors.index_error( self, ak.contents.ListArray( - slicestarts, slicestops, slicecontent, None, self._nplike + slicestarts, + slicestops, + slicecontent, + parameters=None, + nplike=self._nplike, ), "cannot apply jagged slices to irreducible union arrays", ) @@ -435,8 +440,8 @@ def _getitem_next(self, head, tail, advanced): self._tags, outindex, outcontents, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return out.simplify_uniontype() @@ -646,7 +651,9 @@ def simplify_uniontype(self, merge=True, mergebool=False): return contents[0]._carry(index, True) else: - return UnionArray(tags, index, contents, self._parameters, self._nplike) + return UnionArray( + tags, index, contents, parameters=self._parameters, nplike=self._nplike + ) def num(self, axis, depth=0): posaxis = self.axis_wrap_if_negative(axis) @@ -661,7 +668,11 @@ def num(self, axis, depth=0): for content in self._contents: contents.append(content.num(posaxis, depth)) out = UnionArray( - self._tags, self._index, contents, self._parameters, self._nplike + self._tags, + self._index, + contents, + parameters=self._parameters, + nplike=self._nplike, ) return out.simplify_uniontype(True, False) @@ -747,7 +758,11 @@ def _offsets_and_flattened(self, axis, depth): return ( tooffsets, UnionArray( - totags, toindex, contents, self._parameters, self._nplike + totags, + toindex, + contents, + parameters=self._parameters, + nplike=self._nplike, ), ) @@ -759,8 +774,8 @@ def _offsets_and_flattened(self, axis, depth): self._tags, self._index, contents, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ), ) @@ -857,7 +872,9 @@ def _reverse_merge(self, other): ) parameters = ak._util.merge_parameters(self._parameters, other._parameters) - return ak.contents.UnionArray(tags, index, contents, parameters, self._nplike) + return ak.contents.UnionArray( + tags, index, contents, parameters=parameters, nplike=self._nplike + ) def mergemany(self, others): if len(others) == 0: @@ -952,7 +969,11 @@ def mergemany(self, others): ) next = ak.contents.UnionArray( - nexttags, nextindex, nextcontents, parameters, self._nplike + nexttags, + nextindex, + nextcontents, + parameters=parameters, + nplike=self._nplike, ) # Given UnionArray's merging_strategy, tail is always empty, but just to be formal... @@ -974,8 +995,8 @@ def fill_none(self, value): self._tags, self._index, contents, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return out.simplify_uniontype(True, False) @@ -991,8 +1012,8 @@ def _local_index(self, axis, depth): self._tags, self._index, contents, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _combinations(self, n, replacement, recordlookup, parameters, axis, depth): @@ -1011,8 +1032,8 @@ def _combinations(self, n, replacement, recordlookup, parameters, axis, depth): self._tags, self._index, contents, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def numbers_to_type(self, name): @@ -1023,8 +1044,8 @@ def numbers_to_type(self, name): self._tags, self._index, contents, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _is_unique(self, negaxis, starts, parents, outlength): @@ -1060,7 +1081,7 @@ def _argsort_next( simplified = self.simplify_uniontype(mergebool=True) if simplified.length == 0: return ak.contents.NumpyArray( - self._nplike.empty(0, np.int64), None, self._nplike + self._nplike.empty(0, np.int64), parameters=None, nplike=self._nplike ) if isinstance(simplified, ak.contents.UnionArray): @@ -1189,8 +1210,8 @@ def _pad_none(self, target, axis, depth, clip): self.tags, self.index, contents, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) return out.simplify_uniontype(True, False) @@ -1326,8 +1347,8 @@ def continuation(): ) for content in self._contents ], - self._parameters if options["keep_parameters"] else None, - self._nplike, + parameters=self._parameters if options["keep_parameters"] else None, + nplike=self._nplike, ) else: @@ -1385,8 +1406,8 @@ def packed(self): ak.index.Index8(tags, nplike=self.nplike), ak.index.Index(index, nplike=self.nplike), contents, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _to_list(self, behavior, json_conversions): diff --git a/src/awkward/contents/unmaskedarray.py b/src/awkward/contents/unmaskedarray.py index b4157f86b7..df40acee81 100644 --- a/src/awkward/contents/unmaskedarray.py +++ b/src/awkward/contents/unmaskedarray.py @@ -16,13 +16,14 @@ class UnmaskedArray(Content): def copy( self, content=unset, + *, parameters=unset, nplike=unset, ): return UnmaskedArray( self._content if content is unset else content, - self._parameters if parameters is unset else parameters, - self._nplike if nplike is unset else nplike, + parameters=self._parameters if parameters is unset else parameters, + nplike=self._nplike if nplike is unset else nplike, ) def __copy__(self): @@ -34,7 +35,7 @@ def __deepcopy__(self, memo): parameters=copy.deepcopy(self._parameters, memo), ) - def __init__(self, content, parameters=None, nplike=None): + def __init__(self, content, *, parameters=None, nplike=None): if not isinstance(content, Content): raise ak._errors.wrap_error( TypeError( @@ -71,9 +72,7 @@ def _to_buffers(self, form, getkey, container, nplike): def typetracer(self): tt = ak._typetracer.TypeTracer.instance() return UnmaskedArray( - self._content.typetracer, - self._parameters, - tt, + self._content.typetracer, parameters=self._parameters, nplike=tt ) @property @@ -83,8 +82,8 @@ def length(self): def _forget_length(self): return UnmaskedArray( self._content._forget_length(), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def __repr__(self): @@ -104,8 +103,8 @@ def _repr(self, indent, pre, post): def merge_parameters(self, parameters): return UnmaskedArray( self._content, - ak._util.merge_parameters(self._parameters, parameters), - self._nplike, + parameters=ak._util.merge_parameters(self._parameters, parameters), + nplike=self._nplike, ) def to_IndexedOptionArray64(self): @@ -113,8 +112,8 @@ def to_IndexedOptionArray64(self): return ak.contents.IndexedOptionArray( ak.index.Index64(arange, nplike=self.nplike), self._content, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def to_ByteMaskedArray(self, valid_when): @@ -124,8 +123,8 @@ def to_ByteMaskedArray(self, valid_when): ), self._content, valid_when, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def to_BitMaskedArray(self, valid_when, lsb_order): @@ -141,8 +140,8 @@ def to_BitMaskedArray(self, valid_when, lsb_order): valid_when, self.length, lsb_order, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def mask_as_bool(self, valid_when=True, nplike=None): @@ -171,29 +170,29 @@ def _getitem_range(self, where): assert step == 1 return UnmaskedArray( self._content._getitem_range(slice(start, stop)), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _getitem_field(self, where, only_fields=()): return UnmaskedArray( self._content._getitem_field(where, only_fields), - None, - self._nplike, + parameters=None, + nplike=self._nplike, ) def _getitem_fields(self, where, only_fields=()): return UnmaskedArray( self._content._getitem_fields(where, only_fields), - None, - self._nplike, + parameters=None, + nplike=self._nplike, ) def _carry(self, carry, allow_lazy): return UnmaskedArray( self._content._carry(carry, allow_lazy), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail): @@ -201,8 +200,8 @@ def _getitem_next_jagged(self, slicestarts, slicestops, slicecontent, tail): self._content._getitem_next_jagged( slicestarts, slicestops, slicecontent, tail ), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _getitem_next(self, head, tail, advanced): @@ -214,8 +213,8 @@ def _getitem_next(self, head, tail, advanced): ): return UnmaskedArray( self._content._getitem_next(head, tail, advanced), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ).simplify_optiontype() elif isinstance(head, str): @@ -242,8 +241,8 @@ def project(self, mask=None): mask, self._content, False, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ).project() else: return self._content @@ -273,7 +272,9 @@ def num(self, axis, depth=0): return out else: return ak.contents.UnmaskedArray( - self._content.num(posaxis, depth), self._parameters, self._nplike + self._content.num(posaxis, depth), + parameters=self._parameters, + nplike=self._nplike, ) def _offsets_and_flattened(self, axis, depth): @@ -285,7 +286,9 @@ def _offsets_and_flattened(self, axis, depth): if offsets.length == 0: return ( offsets, - UnmaskedArray(flattened, self._parameters, self._nplike), + UnmaskedArray( + flattened, parameters=self._parameters, nplike=self._nplike + ), ) else: @@ -323,8 +326,8 @@ def mergemany(self, others): return UnmaskedArray( self._content.mergemany(tail_contents), - parameters, - self._nplike, + parameters=parameters, + nplike=self._nplike, ) else: @@ -340,15 +343,15 @@ def _local_index(self, axis, depth): else: return UnmaskedArray( self._content._local_index(posaxis, depth), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def numbers_to_type(self, name): return ak.contents.UnmaskedArray( self._content.numbers_to_type(name), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _is_unique(self, negaxis, starts, parents, outlength): @@ -387,17 +390,11 @@ def _argsort_next( if isinstance(out, ak.contents.RegularArray): tmp = ak.contents.UnmaskedArray( - out._content, - None, - self._nplike, + out._content, parameters=None, nplike=self._nplike ).simplify_optiontype() return ak.contents.RegularArray( - tmp, - out._size, - out._length, - None, - self._nplike, + tmp, out._size, out._length, parameters=None, nplike=self._nplike ) else: @@ -419,17 +416,15 @@ def _sort_next( if isinstance(out, ak.contents.RegularArray): tmp = ak.contents.UnmaskedArray( - out._content, - self._parameters, - self._nplike, + out._content, parameters=self._parameters, nplike=self._nplike ).simplify_optiontype() return ak.contents.RegularArray( tmp, out._size, out._length, - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) else: @@ -444,8 +439,8 @@ def _combinations(self, n, replacement, recordlookup, parameters, axis, depth): self._content._combinations( n, replacement, recordlookup, parameters, posaxis, depth ), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _reduce_next( @@ -499,8 +494,8 @@ def _pad_none(self, target, axis, depth, clip): else: return ak.contents.UnmaskedArray( self._content._pad_none(target, posaxis, depth, clip), - self._parameters, - self._nplike, + parameters=self._parameters, + nplike=self._nplike, ) def _to_arrow(self, pyarrow, mask_node, validbytes, length, options): @@ -535,8 +530,8 @@ def continuation(): lateral_context, options, ), - self._parameters if options["keep_parameters"] else None, - self._nplike, + parameters=self._parameters if options["keep_parameters"] else None, + nplike=self._nplike, ) else: @@ -570,7 +565,9 @@ def continuation(): raise ak._errors.wrap_error(AssertionError(result)) def packed(self): - return UnmaskedArray(self._content.packed(), self._parameters, self._nplike) + return UnmaskedArray( + self._content.packed(), parameters=self._parameters, nplike=self._nplike + ) def _to_list(self, behavior, json_conversions): out = self._to_list_custom(behavior, json_conversions) diff --git a/src/awkward/forms/bitmaskedform.py b/src/awkward/forms/bitmaskedform.py index 9db4e44b97..94fa96a4dd 100644 --- a/src/awkward/forms/bitmaskedform.py +++ b/src/awkward/forms/bitmaskedform.py @@ -13,6 +13,7 @@ def __init__( content, valid_when, lsb_order, + *, parameters=None, form_key=None, ): @@ -99,7 +100,7 @@ def _to_dict_part(self, verbose, toplevel): def _type(self, typestrs): return ak.types.OptionType( self._content._type(typestrs), - self._parameters, + parameters=self._parameters, typestr=ak._util.gettypestr(self._parameters, typestrs), ).simplify_option_union() @@ -180,8 +181,8 @@ def _select_columns(self, index, specifier, matches, output): self._content._select_columns(index, specifier, matches, output), self._valid_when, self._lsb_order, - self._parameters, - self._form_key, + parameters=self._parameters, + form_key=self._form_key, ) def _column_types(self): diff --git a/src/awkward/forms/bytemaskedform.py b/src/awkward/forms/bytemaskedform.py index 18440f63a7..6ff8bf1536 100644 --- a/src/awkward/forms/bytemaskedform.py +++ b/src/awkward/forms/bytemaskedform.py @@ -12,6 +12,7 @@ def __init__( mask, content, valid_when, + *, parameters=None, form_key=None, ): @@ -83,7 +84,7 @@ def _to_dict_part(self, verbose, toplevel): def _type(self, typestrs): return ak.types.OptionType( self._content._type(typestrs), - self._parameters, + parameters=self._parameters, typestr=ak._util.gettypestr(self._parameters, typestrs), ).simplify_option_union() @@ -162,8 +163,8 @@ def _select_columns(self, index, specifier, matches, output): self._mask, self._content._select_columns(index, specifier, matches, output), self._valid_when, - self._parameters, - self._form_key, + parameters=self._parameters, + form_key=self._form_key, ) def _column_types(self): diff --git a/src/awkward/forms/emptyform.py b/src/awkward/forms/emptyform.py index 02d1f77440..28d36aaaec 100644 --- a/src/awkward/forms/emptyform.py +++ b/src/awkward/forms/emptyform.py @@ -8,7 +8,7 @@ class EmptyForm(Form): is_numpy = True is_unknown = True - def __init__(self, parameters=None, form_key=None): + def __init__(self, *, parameters=None, form_key=None): self._init(parameters, form_key) def __repr__(self): @@ -20,7 +20,7 @@ def _to_dict_part(self, verbose, toplevel): def _type(self, typestrs): return ak.types.UnknownType( - self._parameters, + parameters=self._parameters, typestr=ak._util.gettypestr(self._parameters, typestrs), ) @@ -28,7 +28,7 @@ def __eq__(self, other): return isinstance(other, EmptyForm) and self._form_key == other._form_key def to_NumpyForm(self, dtype): - return ak.forms.numpyform.from_dtype(dtype, self._parameters) + return ak.forms.numpyform.from_dtype(dtype, parameters=self._parameters) def purelist_parameter(self, key): if self._parameters is None or key not in self._parameters: diff --git a/src/awkward/forms/form.py b/src/awkward/forms/form.py index 5a5cbedd4c..602dc56511 100644 --- a/src/awkward/forms/form.py +++ b/src/awkward/forms/form.py @@ -25,10 +25,12 @@ def from_dict(input: dict) -> Form: if input["class"] == "NumpyArray": primitive = input["primitive"] inner_shape = input.get("inner_shape", []) - return ak.forms.NumpyForm(primitive, inner_shape, parameters, form_key) + return ak.forms.NumpyForm( + primitive, inner_shape, parameters=parameters, form_key=form_key + ) elif input["class"] == "EmptyArray": - return ak.forms.EmptyForm(parameters, form_key) + return ak.forms.EmptyForm(parameters=parameters, form_key=form_key) elif input["class"] == "RegularArray": return ak.forms.RegularForm( diff --git a/src/awkward/forms/indexedform.py b/src/awkward/forms/indexedform.py index 982a51b3c5..e7b9c098c3 100644 --- a/src/awkward/forms/indexedform.py +++ b/src/awkward/forms/indexedform.py @@ -11,6 +11,7 @@ def __init__( self, index, content=None, + *, parameters=None, form_key=None, ): @@ -139,8 +140,8 @@ def _select_columns(self, index, specifier, matches, output): return IndexedForm( self._index, self._content._select_columns(index, specifier, matches, output), - self._parameters, - self._form_key, + parameters=self._parameters, + form_key=self._form_key, ) def _column_types(self): diff --git a/src/awkward/forms/indexedoptionform.py b/src/awkward/forms/indexedoptionform.py index 815ff72f2c..8ef0f1486c 100644 --- a/src/awkward/forms/indexedoptionform.py +++ b/src/awkward/forms/indexedoptionform.py @@ -12,6 +12,7 @@ def __init__( self, index, content, + *, parameters=None, form_key=None, ): @@ -68,7 +69,7 @@ def _type(self, typestrs): return ak.types.OptionType( self._content._type(typestrs), - parameters, + parameters=parameters, typestr=ak._util.gettypestr(self._parameters, typestrs), ).simplify_option_union() @@ -149,8 +150,8 @@ def _select_columns(self, index, specifier, matches, output): return IndexedOptionForm( self._index, self._content._select_columns(index, specifier, matches, output), - self._parameters, - self._form_key, + parameters=self._parameters, + form_key=self._form_key, ) def _column_types(self): diff --git a/src/awkward/forms/listform.py b/src/awkward/forms/listform.py index b3ddabf890..444c60833f 100644 --- a/src/awkward/forms/listform.py +++ b/src/awkward/forms/listform.py @@ -12,6 +12,7 @@ def __init__( starts, stops, content, + *, parameters=None, form_key=None, ): @@ -79,7 +80,7 @@ def _to_dict_part(self, verbose, toplevel): def _type(self, typestrs): return ak.types.ListType( self._content._type(typestrs), - self._parameters, + parameters=self._parameters, typestr=ak._util.gettypestr(self._parameters, typestrs), ) @@ -159,8 +160,8 @@ def _select_columns(self, index, specifier, matches, output): self._starts, self._stops, self._content._select_columns(index, specifier, matches, output), - self._parameters, - self._form_key, + parameters=self._parameters, + form_key=self._form_key, ) def _column_types(self): diff --git a/src/awkward/forms/listoffsetform.py b/src/awkward/forms/listoffsetform.py index ec23517a06..bb6fd71af3 100644 --- a/src/awkward/forms/listoffsetform.py +++ b/src/awkward/forms/listoffsetform.py @@ -7,7 +7,7 @@ class ListOffsetForm(Form): is_list = True - def __init__(self, offsets, content, parameters=None, form_key=None): + def __init__(self, offsets, content, *, parameters=None, form_key=None): if not isinstance(offsets, str): raise ak._errors.wrap_error( TypeError( @@ -49,7 +49,7 @@ def _to_dict_part(self, verbose, toplevel): def _type(self, typestrs): return ak.types.ListType( self._content._type(typestrs), - self._parameters, + parameters=self._parameters, typestr=ak._util.gettypestr(self._parameters, typestrs), ) @@ -127,8 +127,8 @@ def _select_columns(self, index, specifier, matches, output): return ListOffsetForm( self._offsets, self._content._select_columns(index, specifier, matches, output), - self._parameters, - self._form_key, + parameters=self._parameters, + form_key=self._form_key, ) def _column_types(self): diff --git a/src/awkward/forms/numpyform.py b/src/awkward/forms/numpyform.py index c661599f26..b7436c7901 100644 --- a/src/awkward/forms/numpyform.py +++ b/src/awkward/forms/numpyform.py @@ -40,6 +40,7 @@ def __init__( self, primitive, inner_shape=(), + *, parameters=None, form_key=None, ): @@ -100,7 +101,7 @@ def _to_dict_part(self, verbose, toplevel): def _type(self, typestrs): out = ak.types.NumpyType( self._primitive, - None, + parameters=None, typestr=ak._util.gettypestr(self._parameters, typestrs), ) for x in self._inner_shape[::-1]: @@ -124,9 +125,9 @@ def __eq__(self, other): return False def to_RegularForm(self): - out = NumpyForm(self._primitive, (), None, None) + out = NumpyForm(self._primitive, (), parameters=None, form_key=None) for x in self._inner_shape[::-1]: - out = ak.forms.RegularForm(out, x, None, None) + out = ak.forms.RegularForm(out, x, parameters=None, form_key=None) out._parameters = self._parameters return out diff --git a/src/awkward/forms/recordform.py b/src/awkward/forms/recordform.py index 0519e551db..4bcac5c09b 100644 --- a/src/awkward/forms/recordform.py +++ b/src/awkward/forms/recordform.py @@ -14,6 +14,7 @@ def __init__( self, contents, fields, + *, parameters=None, form_key=None, ): @@ -149,7 +150,7 @@ def _type(self, typestrs): return ak.types.RecordType( [x._type(typestrs) for x in self._contents], self._fields, - self._parameters, + parameters=self._parameters, typestr=ak._util.gettypestr(self._parameters, typestrs), ) @@ -245,8 +246,8 @@ def _select_columns(self, index, specifier, matches, output): return RecordForm( contents, fields, - self._parameters, - self._form_key, + parameters=self._parameters, + form_key=self._form_key, ) def _column_types(self): diff --git a/src/awkward/forms/regularform.py b/src/awkward/forms/regularform.py index c83d279a85..9eaa93f00a 100644 --- a/src/awkward/forms/regularform.py +++ b/src/awkward/forms/regularform.py @@ -8,7 +8,7 @@ class RegularForm(Form): is_list = True is_regular = True - def __init__(self, content, size, parameters=None, form_key=None): + def __init__(self, content, size, *, parameters=None, form_key=None): if not isinstance(content, Form): raise ak._errors.wrap_error( TypeError( @@ -56,7 +56,7 @@ def _type(self, typestrs): return ak.types.RegularType( self._content._type(typestrs), self._size, - self._parameters, + parameters=self._parameters, typestr=ak._util.gettypestr(self._parameters, typestrs), ) @@ -134,8 +134,8 @@ def _select_columns(self, index, specifier, matches, output): return RegularForm( self._content._select_columns(index, specifier, matches, output), self._size, - self._parameters, - self._form_key, + parameters=self._parameters, + form_key=self._form_key, ) def _column_types(self): diff --git a/src/awkward/forms/unionform.py b/src/awkward/forms/unionform.py index 7d1d1f7432..68990a4a96 100644 --- a/src/awkward/forms/unionform.py +++ b/src/awkward/forms/unionform.py @@ -14,6 +14,7 @@ def __init__( tags, index, contents, + *, parameters=None, form_key=None, ): @@ -96,7 +97,7 @@ def _to_dict_part(self, verbose, toplevel): def _type(self, typestrs): return ak.types.UnionType( [x._type(typestrs) for x in self._contents], - self._parameters, + parameters=self._parameters, typestr=ak._util.gettypestr(self._parameters, typestrs), ) @@ -203,7 +204,9 @@ def _select_columns(self, index, specifier, matches, output): contents.append(next_content) if len(contents) == 0: - return ak.forms.EmptyForm(self._parameters, self._form_key) + return ak.forms.EmptyForm( + parameters=self._parameters, form_key=self._form_key + ) elif len(contents) == 1: return contents[0] else: @@ -211,8 +214,8 @@ def _select_columns(self, index, specifier, matches, output): self._tags, self._index, contents, - self._parameters, - self._form_key, + parameters=self._parameters, + form_key=self._form_key, ) def _column_types(self): diff --git a/src/awkward/forms/unmaskedform.py b/src/awkward/forms/unmaskedform.py index cea910b50c..0d3f0daa4d 100644 --- a/src/awkward/forms/unmaskedform.py +++ b/src/awkward/forms/unmaskedform.py @@ -10,6 +10,7 @@ class UnmaskedForm(Form): def __init__( self, content, + *, parameters=None, form_key=None, ): @@ -45,7 +46,7 @@ def _to_dict_part(self, verbose, toplevel): def _type(self, typestrs): return ak.types.OptionType( self._content._type(typestrs), - self._parameters, + parameters=self._parameters, typestr=ak._util.gettypestr(self._parameters, typestrs), ).simplify_option_union() @@ -120,8 +121,8 @@ def _columns(self, path, output, list_indicator): def _select_columns(self, index, specifier, matches, output): return UnmaskedForm( self._content._select_columns(index, specifier, matches, output), - self._parameters, - self._form_key, + parameters=self._parameters, + form_key=self._form_key, ) def _column_types(self): diff --git a/src/awkward/operations/ak_from_buffers.py b/src/awkward/operations/ak_from_buffers.py index bbb51e2a9a..5df89a85ca 100644 --- a/src/awkward/operations/ak_from_buffers.py +++ b/src/awkward/operations/ak_from_buffers.py @@ -131,7 +131,7 @@ def reconstitute(form, length, container, getkey, nplike): raise ak._errors.wrap_error( ValueError(f"EmptyForm node, but the expected length is {length}") ) - return ak.contents.EmptyArray(form.parameters) + return ak.contents.EmptyArray(parameters=form.parameters) elif isinstance(form, ak.forms.NumpyForm): dtype = ak.types.numpytype.primitive_to_dtype(form.primitive) @@ -145,11 +145,11 @@ def reconstitute(form, length, container, getkey, nplike): data = data.reshape((length,) + form.inner_shape) else: data = data.reshape((-1,) + form.inner_shape) - return ak.contents.NumpyArray(data, form.parameters, nplike) + return ak.contents.NumpyArray(data, parameters=form.parameters, nplike=nplike) elif isinstance(form, ak.forms.UnmaskedForm): content = reconstitute(form.content, length, container, getkey, nplike) - return ak.contents.UnmaskedArray(content, form.parameters) + return ak.contents.UnmaskedArray(content, parameters=form.parameters) elif isinstance(form, ak.forms.BitMaskedForm): raw_array = container[getkey(form, "mask")] @@ -163,7 +163,7 @@ def reconstitute(form, length, container, getkey, nplike): form.valid_when, length, form.lsb_order, - form.parameters, + parameters=form.parameters, ) elif isinstance(form, ak.forms.ByteMaskedForm): @@ -175,7 +175,7 @@ def reconstitute(form, length, container, getkey, nplike): ak.index.Index(mask), reconstitute(form.content, length, container, getkey, nplike), form.valid_when, - form.parameters, + parameters=form.parameters, ) elif isinstance(form, ak.forms.IndexedOptionForm): @@ -189,7 +189,7 @@ def reconstitute(form, length, container, getkey, nplike): return ak.contents.IndexedOptionArray( ak.index.Index(index), reconstitute(form.content, next_length, container, getkey, nplike), - form.parameters, + parameters=form.parameters, ) elif isinstance(form, ak.forms.IndexedForm): @@ -201,7 +201,7 @@ def reconstitute(form, length, container, getkey, nplike): return ak.contents.IndexedArray( ak.index.Index(index), reconstitute(form.content, next_length, container, getkey, nplike), - form.parameters, + parameters=form.parameters, ) elif isinstance(form, ak.forms.ListForm): @@ -219,7 +219,7 @@ def reconstitute(form, length, container, getkey, nplike): ak.index.Index(starts), ak.index.Index(stops), reconstitute(form.content, next_length, container, getkey, nplike), - form.parameters, + parameters=form.parameters, ) elif isinstance(form, ak.forms.ListOffsetForm): @@ -231,7 +231,7 @@ def reconstitute(form, length, container, getkey, nplike): return ak.contents.ListOffsetArray( ak.index.Index(offsets), reconstitute(form.content, next_length, container, getkey, nplike), - form.parameters, + parameters=form.parameters, ) elif isinstance(form, ak.forms.RegularForm): @@ -240,7 +240,7 @@ def reconstitute(form, length, container, getkey, nplike): reconstitute(form.content, next_length, container, getkey, nplike), form.size, length, - form.parameters, + parameters=form.parameters, ) elif isinstance(form, ak.forms.RecordForm): @@ -251,7 +251,7 @@ def reconstitute(form, length, container, getkey, nplike): ], None if form.is_tuple else form.fields, length, - form.parameters, + parameters=form.parameters, ) elif isinstance(form, ak.forms.UnionForm): @@ -277,7 +277,7 @@ def reconstitute(form, length, container, getkey, nplike): reconstitute(content, lengths[i], container, getkey, nplike) for i, content in enumerate(form.contents) ], - form.parameters, + parameters=form.parameters, ) else: diff --git a/src/awkward/operations/ak_full_like.py b/src/awkward/operations/ak_full_like.py index 9484796e04..ac2d22a5e0 100644 --- a/src/awkward/operations/ak_full_like.py +++ b/src/awkward/operations/ak_full_like.py @@ -174,18 +174,15 @@ def action(layout, **kwargs): if fill_value == 0 or fill_value is _ZEROS: return ak.contents.NumpyArray( - nplike.zeros_like(original), - layout.parameters, + nplike.zeros_like(original), parameters=layout.parameters ) elif fill_value == 1: return ak.contents.NumpyArray( - nplike.ones_like(original), - layout.parameters, + nplike.ones_like(original), parameters=layout.parameters ) else: return ak.contents.NumpyArray( - nplike.full_like(original, fill_value), - layout.parameters, + nplike.full_like(original, fill_value), parameters=layout.parameters ) else: return None diff --git a/src/awkward/operations/ak_singletons.py b/src/awkward/operations/ak_singletons.py index 29ae9910a6..b873bc5aea 100644 --- a/src/awkward/operations/ak_singletons.py +++ b/src/awkward/operations/ak_singletons.py @@ -56,7 +56,7 @@ def action(layout, **kwargs): ak.contents.IndexedOptionArray( layout.index, layout.content, - layout.parameters, + parameters=layout.parameters, ) ) diff --git a/src/awkward/operations/ak_with_name.py b/src/awkward/operations/ak_with_name.py index 7a35d9e68f..eceb70f622 100644 --- a/src/awkward/operations/ak_with_name.py +++ b/src/awkward/operations/ak_with_name.py @@ -44,10 +44,7 @@ def action(layout, **ignore): parameters = dict(layout.parameters) parameters["__record__"] = name return ak.contents.RecordArray( - layout.contents, - layout.fields, - len(layout), - parameters, + layout.contents, layout.fields, len(layout), parameters=parameters ) else: return None diff --git a/src/awkward/types/listtype.py b/src/awkward/types/listtype.py index 12040b357f..2a29795b01 100644 --- a/src/awkward/types/listtype.py +++ b/src/awkward/types/listtype.py @@ -6,7 +6,7 @@ class ListType(Type): - def __init__(self, content, parameters=None, *, typestr=None): + def __init__(self, content, *, parameters=None, typestr=None): if not isinstance(content, Type): raise ak._errors.wrap_error( TypeError( diff --git a/src/awkward/types/numpytype.py b/src/awkward/types/numpytype.py index 952dd78d15..0c2355198e 100644 --- a/src/awkward/types/numpytype.py +++ b/src/awkward/types/numpytype.py @@ -93,7 +93,7 @@ def dtype_to_primitive(dtype): class NumpyType(Type): - def __init__(self, primitive, parameters=None, *, typestr=None): + def __init__(self, primitive, *, parameters=None, typestr=None): primitive = dtype_to_primitive(primitive_to_dtype(primitive)) if parameters is not None and not isinstance(parameters, dict): raise ak._errors.wrap_error( diff --git a/src/awkward/types/optiontype.py b/src/awkward/types/optiontype.py index d6b43b69aa..9c0daee726 100644 --- a/src/awkward/types/optiontype.py +++ b/src/awkward/types/optiontype.py @@ -9,7 +9,7 @@ class OptionType(Type): - def __init__(self, content, parameters=None, *, typestr=None): + def __init__(self, content, *, parameters=None, typestr=None): if not isinstance(content, Type): raise ak._errors.wrap_error( TypeError( @@ -103,7 +103,7 @@ def simplify_option_union(self): contents.append( OptionType( content.content, - ak._util.merge_parameters( + parameters=ak._util.merge_parameters( self._parameters, content._parameters ), typestr=typestr, @@ -112,11 +112,15 @@ def simplify_option_union(self): else: contents.append( - OptionType(content, self._parameters, typestr=self._typestr) + OptionType( + content, parameters=self._parameters, typestr=self._typestr + ) ) return UnionType( - contents, self._content.parameters, typestr=self._content.typestr + contents, + parameters=self._content.parameters, + typestr=self._content.typestr, ) else: diff --git a/src/awkward/types/recordtype.py b/src/awkward/types/recordtype.py index 873ccdb445..8be623e102 100644 --- a/src/awkward/types/recordtype.py +++ b/src/awkward/types/recordtype.py @@ -10,7 +10,7 @@ class RecordType(Type): - def __init__(self, contents, fields, parameters=None, *, typestr=None): + def __init__(self, contents, fields, *, parameters=None, typestr=None): if not isinstance(contents, Iterable): raise ak._errors.wrap_error( TypeError( diff --git a/src/awkward/types/regulartype.py b/src/awkward/types/regulartype.py index 09bb683149..21aee32000 100644 --- a/src/awkward/types/regulartype.py +++ b/src/awkward/types/regulartype.py @@ -6,7 +6,7 @@ class RegularType(Type): - def __init__(self, content, size, parameters=None, *, typestr=None): + def __init__(self, content, size, *, parameters=None, typestr=None): if not isinstance(content, Type): raise ak._errors.wrap_error( TypeError( diff --git a/src/awkward/types/type.py b/src/awkward/types/type.py index 12c791f36c..a820f538b5 100644 --- a/src/awkward/types/type.py +++ b/src/awkward/types/type.py @@ -101,35 +101,35 @@ def listtype(self, args): def varlen_string(self, args): return ak.types.ListType( - ak.types.NumpyType("uint8", {"__array__": "char"}), - {"__array__": "string"}, + ak.types.NumpyType("uint8", parameters={"__array__": "char"}), + parameters={"__array__": "string"}, ) def varlen_bytestring(self, args): return ak.types.ListType( - ak.types.NumpyType("uint8", {"__array__": "byte"}), - {"__array__": "bytestring"}, + ak.types.NumpyType("uint8", parameters={"__array__": "byte"}), + parameters={"__array__": "bytestring"}, ) def fixedlen_string(self, args): return ak.types.RegularType( - ak.types.NumpyType("uint8", {"__array__": "char"}), + ak.types.NumpyType("uint8", parameters={"__array__": "char"}), int(args[0]), - {"__array__": "string"}, + parameters={"__array__": "string"}, ) def fixedlen_bytestring(self, args): return ak.types.RegularType( - ak.types.NumpyType("uint8", {"__array__": "byte"}), + ak.types.NumpyType("uint8", parameters={"__array__": "byte"}), int(args[0]), - {"__array__": "bytestring"}, + parameters={"__array__": "bytestring"}, ) def char(self, args): - return ak.types.NumpyType("uint8", {"__array__": "char"}) + return ak.types.NumpyType("uint8", parameters={"__array__": "char"}) def byte(self, args): - return ak.types.NumpyType("uint8", {"__array__": "byte"}) + return ak.types.NumpyType("uint8", parameters={"__array__": "byte"}) def option1(self, args): return ak.types.OptionType(args[0]) @@ -158,7 +158,7 @@ def tuple_parameters(self, args): else: parameters = {} - return ak.types.RecordType(types, None, parameters) + return ak.types.RecordType(types, None, parameters=parameters) def record(self, args): if len(args) == 0: @@ -188,13 +188,13 @@ def record_parameters(self, args): else: parameters = {} - return ak.types.RecordType(types, fields, parameters) + return ak.types.RecordType(types, fields, parameters=parameters) def named0(self, args): parameters = {"__record__": str(args[0])} if 1 < len(args): parameters.update(args[1]) - return ak.types.RecordType([], None, parameters) + return ak.types.RecordType([], None, parameters=parameters) def named(self, args): parameters = {"__record__": str(args[0])} @@ -212,7 +212,7 @@ def named(self, args): fields = None contents = arguments - return ak.types.RecordType(contents, fields, parameters) + return ak.types.RecordType(contents, fields, parameters=parameters) def named_types(self, args): if len(args) == 2 and isinstance(args[1], list): @@ -243,7 +243,7 @@ def union(self, args): arguments = args[0] parameters = None - return ak.types.UnionType(arguments, parameters) + return ak.types.UnionType(arguments, parameters=parameters) def list_parameters(self, args): # modify recently created type object diff --git a/src/awkward/types/uniontype.py b/src/awkward/types/uniontype.py index 04d9ea5480..f6be5d2b33 100644 --- a/src/awkward/types/uniontype.py +++ b/src/awkward/types/uniontype.py @@ -8,7 +8,7 @@ class UnionType(Type): - def __init__(self, contents, parameters=None, *, typestr=None): + def __init__(self, contents, *, parameters=None, typestr=None): if not isinstance(contents, Iterable): raise ak._errors.wrap_error( TypeError( diff --git a/src/awkward/types/unknowntype.py b/src/awkward/types/unknowntype.py index 0e3bda269e..8f7a5541a4 100644 --- a/src/awkward/types/unknowntype.py +++ b/src/awkward/types/unknowntype.py @@ -6,7 +6,7 @@ class UnknownType(Type): - def __init__(self, parameters=None, *, typestr=None): + def __init__(self, *, parameters=None, typestr=None): if parameters is not None and not isinstance(parameters, dict): raise ak._errors.wrap_error( TypeError( diff --git a/tests/test_0773-typeparser.py b/tests/test_0773-typeparser.py index 64e751fc41..1bacab2b41 100644 --- a/tests/test_0773-typeparser.py +++ b/tests/test_0773-typeparser.py @@ -455,27 +455,29 @@ def test_numpytype_datetime64_10s(): def test_numpytype_int32_parameter(): - t = NumpyType("int32", {"__array__": "Something"}) + t = NumpyType("int32", parameters={"__array__": "Something"}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_numpytype_datetime64_parameter(): - t = NumpyType("datetime64", {"__array__": "Something"}) + t = NumpyType("datetime64", parameters={"__array__": "Something"}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_numpytype_datetime64_10s_parameter(): - t = NumpyType("datetime64[10s]", {"__array__": "Something"}) + t = NumpyType("datetime64[10s]", parameters={"__array__": "Something"}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_numpytype_int32_categorical(): - t = NumpyType("int32", {"__categorical__": True}) + t = NumpyType("int32", parameters={"__categorical__": True}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_numpytype_int32_parameters_categorical(): - t = NumpyType("int32", {"__array__": "Something", "__categorical__": True}) + t = NumpyType( + "int32", parameters={"__array__": "Something", "__categorical__": True} + ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) @@ -485,17 +487,17 @@ def test_unknowntype(): def test_unknowntype_parameter(): - t = UnknownType({"__array__": "Something"}) + t = UnknownType(parameters={"__array__": "Something"}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_unknowntype_categorical(): - t = UnknownType({"__categorical__": True}) + t = UnknownType(parameters={"__categorical__": True}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_unknowntype_categorical_parameter(): - t = UnknownType({"__array__": "Something", "__categorical__": True}) + t = UnknownType(parameters={"__array__": "Something", "__categorical__": True}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) @@ -505,18 +507,20 @@ def test_regulartype_numpytype(): def test_regulartype_numpytype_parameter(): - t = RegularType(NumpyType("int32"), 5, {"__array__": "Something"}) + t = RegularType(NumpyType("int32"), 5, parameters={"__array__": "Something"}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_regulartype_numpytype_categorical(): - t = RegularType(NumpyType("int32"), 5, {"__categorical__": True}) + t = RegularType(NumpyType("int32"), 5, parameters={"__categorical__": True}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_regulartype_numpytype_categorical_parameter(): t = RegularType( - NumpyType("int32"), 5, {"__categorical__": True, "__array__": "Something"} + NumpyType("int32"), + 5, + parameters={"__categorical__": True, "__array__": "Something"}, ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) @@ -527,53 +531,64 @@ def test_listtype_numpytype(): def test_listtype_numpytype_parameter(): - t = ListType(NumpyType("int32"), {"__array__": "Something"}) + t = ListType(NumpyType("int32"), parameters={"__array__": "Something"}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_listtype_numpytype_categorical(): - t = ListType(NumpyType("int32"), {"__categorical__": True}) + t = ListType(NumpyType("int32"), parameters={"__categorical__": True}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_listtype_numpytype_categorical_parameter(): t = ListType( - NumpyType("int32"), {"__categorical__": True, "__array__": "Something"} + NumpyType("int32"), + parameters={"__categorical__": True, "__array__": "Something"}, ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_varlen_string(): - t = ListType(NumpyType("uint8", {"__array__": "char"}), {"__array__": "string"}) + t = ListType( + NumpyType("uint8", parameters={"__array__": "char"}), + parameters={"__array__": "string"}, + ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_varlen_bytestring(): - t = ListType(NumpyType("uint8", {"__array__": "char"}), {"__array__": "bytestring"}) + t = ListType( + NumpyType("uint8", parameters={"__array__": "char"}), + parameters={"__array__": "bytestring"}, + ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_fixedlen_string(): t = RegularType( - NumpyType("uint8", {"__array__": "char"}), 5, {"__array__": "string"} + NumpyType("uint8", parameters={"__array__": "char"}), + 5, + parameters={"__array__": "string"}, ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_fixedlen_bytestring(): t = RegularType( - NumpyType("uint8", {"__array__": "byte"}), 5, {"__array__": "bytestring"} + NumpyType("uint8", parameters={"__array__": "byte"}), + 5, + parameters={"__array__": "bytestring"}, ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_char(): - t = NumpyType("uint8", {"__array__": "char"}) + t = NumpyType("uint8", parameters={"__array__": "char"}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_byte(): - t = NumpyType("uint8", {"__array__": "byte"}) + t = NumpyType("uint8", parameters={"__array__": "byte"}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) @@ -583,33 +598,40 @@ def test_optiontype_numpytype_int32(): def test_optiontype_numpytype_int32_parameters(): - t = OptionType(NumpyType("int32"), {"__array__": "Something"}) + t = OptionType(NumpyType("int32"), parameters={"__array__": "Something"}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_optiontype_numpytype_int32_categorical(): - t = OptionType(NumpyType("int32"), {"__categorical__": True}) + t = OptionType(NumpyType("int32"), parameters={"__categorical__": True}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_optiontype_numpytype_int32_categorical_parameters(): t = OptionType( - NumpyType("int32"), {"__array__": "Something", "__categorical__": True} + NumpyType("int32"), + parameters={"__array__": "Something", "__categorical__": True}, ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_option_varlen_string(): t = OptionType( - ListType(NumpyType("uint8", {"__array__": "char"}), {"__array__": "string"}) + ListType( + NumpyType("uint8", parameters={"__array__": "char"}), + parameters={"__array__": "string"}, + ) ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_option_varlen_string_parameters(): t = OptionType( - ListType(NumpyType("uint8", {"__array__": "char"}), {"__array__": "string"}), - {"__array__": "Something"}, + ListType( + NumpyType("uint8", parameters={"__array__": "char"}), + parameters={"__array__": "string"}, + ), + parameters={"__array__": "Something"}, ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) @@ -645,56 +667,62 @@ def test_record_fields_int32_float64(): def test_record_empty_parameters(): - t = RecordType([], None, {"p": [123]}) + t = RecordType([], None, parameters={"p": [123]}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_record_fields_empty_parameters(): - t = RecordType([], [], {"p": [123]}) + t = RecordType([], [], parameters={"p": [123]}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_record_int32_parameters(): - t = RecordType([NumpyType("int32")], None, {"p": [123]}) + t = RecordType([NumpyType("int32")], None, parameters={"p": [123]}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_record_int32_float64_parameters(): - t = RecordType([NumpyType("int32"), NumpyType("float64")], None, {"p": [123]}) + t = RecordType( + [NumpyType("int32"), NumpyType("float64")], None, parameters={"p": [123]} + ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_record_fields_int32_parameters(): - t = RecordType([NumpyType("int32")], ["one"], {"p": [123]}) + t = RecordType([NumpyType("int32")], ["one"], parameters={"p": [123]}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_record_fields_int32_float64_parameters(): t = RecordType( - [NumpyType("int32"), NumpyType("float64")], ["one", "t w o"], {"p": [123]} + [NumpyType("int32"), NumpyType("float64")], + ["one", "t w o"], + parameters={"p": [123]}, ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_named_record_empty(): - t = RecordType([], None, {"__record__": "Name"}) + t = RecordType([], None, parameters={"__record__": "Name"}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_named_record_int32(): - t = RecordType([NumpyType("int32")], None, {"__record__": "Name"}) + t = RecordType([NumpyType("int32")], None, parameters={"__record__": "Name"}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_named_record_int32_float64(): t = RecordType( - [NumpyType("int32"), NumpyType("float64")], None, {"__record__": "Name"} + [NumpyType("int32"), NumpyType("float64")], + None, + parameters={"__record__": "Name"}, ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_named_record_fields_int32(): - t = RecordType([NumpyType("int32")], ["one"], {"__record__": "Name"}) + t = RecordType([NumpyType("int32")], ["one"], parameters={"__record__": "Name"}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) @@ -702,18 +730,20 @@ def test_named_record_fields_int32_float64(): t = RecordType( [NumpyType("int32"), NumpyType("float64")], ["one", "t w o"], - {"__record__": "Name"}, + parameters={"__record__": "Name"}, ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_named_record_empty_parameters(): - t = RecordType([], None, {"__record__": "Name", "p": [123]}) + t = RecordType([], None, parameters={"__record__": "Name", "p": [123]}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_named_record_int32_parameters(): - t = RecordType([NumpyType("int32")], None, {"__record__": "Name", "p": [123]}) + t = RecordType( + [NumpyType("int32")], None, parameters={"__record__": "Name", "p": [123]} + ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) @@ -721,13 +751,15 @@ def test_named_record_int32_float64_parameters(): t = RecordType( [NumpyType("int32"), NumpyType("float64")], None, - {"__record__": "Name", "p": [123]}, + parameters={"__record__": "Name", "p": [123]}, ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_named_record_fields_int32_parameters(): - t = RecordType([NumpyType("int32")], ["one"], {"__record__": "Name", "p": [123]}) + t = RecordType( + [NumpyType("int32")], ["one"], parameters={"__record__": "Name", "p": [123]} + ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) @@ -735,7 +767,7 @@ def test_named_record_fields_int32_float64_parameters(): t = RecordType( [NumpyType("int32"), NumpyType("float64")], ["one", "t w o"], - {"__record__": "Name", "p": [123]}, + parameters={"__record__": "Name", "p": [123]}, ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) @@ -758,13 +790,13 @@ def test_union_float64_datetime64(): def test_union_float64_parameters(): - t = UnionType([NumpyType("float64")], {"__array__": "Something"}) + t = UnionType([NumpyType("float64")], parameters={"__array__": "Something"}) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) def test_union_float64_datetime64_parameters(): t = UnionType( [NumpyType("float64"), NumpyType("datetime64")], - {"__array__": "Something"}, + parameters={"__array__": "Something"}, ) assert str(ak.types.from_datashape(str(t), highlevel=False)) == str(t) diff --git a/tests/test_0914-types-and-forms.py b/tests/test_0914-types-and-forms.py index 60008b3f3d..74e668b858 100644 --- a/tests/test_0914-types-and-forms.py +++ b/tests/test_0914-types-and-forms.py @@ -9,26 +9,33 @@ def test_UnknownType(): assert str(ak.types.unknowntype.UnknownType()) == "unknown" assert ( - str(ak.types.unknowntype.UnknownType({"x": 123})) + str(ak.types.unknowntype.UnknownType(parameters={"x": 123})) == 'unknown[parameters={"x": 123}]' ) - assert str(ak.types.unknowntype.UnknownType(None, typestr="override")) == "override" assert ( - str(ak.types.unknowntype.UnknownType({"x": 123}, typestr="override")) + str(ak.types.unknowntype.UnknownType(parameters=None, typestr="override")) == "override" ) assert ( - str(ak.types.unknowntype.UnknownType({"__categorical__": True})) + str(ak.types.unknowntype.UnknownType(parameters={"x": 123}, typestr="override")) + == "override" + ) + assert ( + str(ak.types.unknowntype.UnknownType(parameters={"__categorical__": True})) == "categorical[type=unknown]" ) assert ( - str(ak.types.unknowntype.UnknownType({"__categorical__": True, "x": 123})) + str( + ak.types.unknowntype.UnknownType( + parameters={"__categorical__": True, "x": 123} + ) + ) == 'categorical[type=unknown[parameters={"x": 123}]]' ) assert ( str( ak.types.unknowntype.UnknownType( - {"__categorical__": True}, typestr="override" + parameters={"__categorical__": True}, typestr="override" ) ) == "categorical[type=override]" @@ -70,173 +77,195 @@ def test_NumpyType(): if hasattr(np, "complex256"): assert str(ak.types.numpytype.NumpyType("complex256")) == "complex256" assert ( - str(ak.types.numpytype.NumpyType("bool", {"x": 123})) + str(ak.types.numpytype.NumpyType("bool", parameters={"x": 123})) == 'bool[parameters={"x": 123}]' ) assert ( - str(ak.types.numpytype.NumpyType("bool", None, typestr="override")) + str(ak.types.numpytype.NumpyType("bool", parameters=None, typestr="override")) == "override" ) assert ( - str(ak.types.numpytype.NumpyType("bool", {"x": 123}, typestr="override")) + str( + ak.types.numpytype.NumpyType( + "bool", parameters={"x": 123}, typestr="override" + ) + ) == "override" ) assert ( - str(ak.types.numpytype.NumpyType("bool", {"__categorical__": True})) + str(ak.types.numpytype.NumpyType("bool", parameters={"__categorical__": True})) == "categorical[type=bool]" ) assert ( - str(ak.types.numpytype.NumpyType("bool", {"__categorical__": True, "x": 123})) + str( + ak.types.numpytype.NumpyType( + "bool", parameters={"__categorical__": True, "x": 123} + ) + ) == 'categorical[type=bool[parameters={"x": 123}]]' ) assert ( str( ak.types.numpytype.NumpyType( - "bool", {"__categorical__": True}, typestr="override" + "bool", parameters={"__categorical__": True}, typestr="override" ) ) == "categorical[type=override]" ) assert str(ak.types.numpytype.NumpyType("datetime64")) == "datetime64" assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "Y"})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"__unit__": "Y"})) == 'datetime64[unit="Y"]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "M"})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"__unit__": "M"})) == 'datetime64[unit="M"]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "W"})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"__unit__": "W"})) == 'datetime64[unit="W"]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "D"})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"__unit__": "D"})) == 'datetime64[unit="D"]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "h"})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"__unit__": "h"})) == 'datetime64[unit="h"]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "m"})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"__unit__": "m"})) == 'datetime64[unit="m"]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "s"})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"__unit__": "s"})) == 'datetime64[unit="s"]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "ms"})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"__unit__": "ms"})) == 'datetime64[unit="ms"]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "us"})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"__unit__": "us"})) == 'datetime64[unit="us"]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "ns"})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"__unit__": "ns"})) == 'datetime64[unit="ns"]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "ps"})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"__unit__": "ps"})) == 'datetime64[unit="ps"]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "fs"})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"__unit__": "fs"})) == 'datetime64[unit="fs"]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "as"})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"__unit__": "as"})) == 'datetime64[unit="as"]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "10s"})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"__unit__": "10s"})) == 'datetime64[unit="10s"]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "1s"})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"__unit__": "1s"})) == 'datetime64[unit="s"]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"__unit__": "s", "x": 123})) + str( + ak.types.numpytype.NumpyType( + "datetime64", parameters={"__unit__": "s", "x": 123} + ) + ) == 'datetime64[unit="s", parameters={"x": 123}]' ) assert ( - str(ak.types.numpytype.NumpyType("datetime64", {"x": 123})) + str(ak.types.numpytype.NumpyType("datetime64", parameters={"x": 123})) == 'datetime64[parameters={"x": 123}]' ) assert str(ak.types.numpytype.NumpyType("timedelta64")) == "timedelta64" assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "Y"})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"__unit__": "Y"})) == 'timedelta64[unit="Y"]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "M"})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"__unit__": "M"})) == 'timedelta64[unit="M"]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "W"})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"__unit__": "W"})) == 'timedelta64[unit="W"]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "D"})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"__unit__": "D"})) == 'timedelta64[unit="D"]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "h"})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"__unit__": "h"})) == 'timedelta64[unit="h"]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "m"})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"__unit__": "m"})) == 'timedelta64[unit="m"]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "s"})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"__unit__": "s"})) == 'timedelta64[unit="s"]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "ms"})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"__unit__": "ms"})) == 'timedelta64[unit="ms"]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "us"})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"__unit__": "us"})) == 'timedelta64[unit="us"]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "ns"})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"__unit__": "ns"})) == 'timedelta64[unit="ns"]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "ps"})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"__unit__": "ps"})) == 'timedelta64[unit="ps"]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "fs"})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"__unit__": "fs"})) == 'timedelta64[unit="fs"]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "as"})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"__unit__": "as"})) == 'timedelta64[unit="as"]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "10s"})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"__unit__": "10s"})) == 'timedelta64[unit="10s"]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "1s"})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"__unit__": "1s"})) == 'timedelta64[unit="s"]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"__unit__": "s", "x": 123})) + str( + ak.types.numpytype.NumpyType( + "timedelta64", parameters={"__unit__": "s", "x": 123} + ) + ) == 'timedelta64[unit="s", parameters={"x": 123}]' ) assert ( - str(ak.types.numpytype.NumpyType("timedelta64", {"x": 123})) + str(ak.types.numpytype.NumpyType("timedelta64", parameters={"x": 123})) == 'timedelta64[parameters={"x": 123}]' ) - assert str(ak.types.numpytype.NumpyType("uint8", {"__array__": "char"})) == "char" - assert str(ak.types.numpytype.NumpyType("uint8", {"__array__": "byte"})) == "byte" + assert ( + str(ak.types.numpytype.NumpyType("uint8", parameters={"__array__": "char"})) + == "char" + ) + assert ( + str(ak.types.numpytype.NumpyType("uint8", parameters={"__array__": "byte"})) + == "byte" + ) assert repr(ak.types.numpytype.NumpyType(primitive="bool")) == "NumpyType('bool')" assert ( repr( @@ -288,7 +317,7 @@ def test_RegularType(): assert ( str( ak.types.regulartype.RegularType( - ak.types.unknowntype.UnknownType(), 10, {"x": 123} + ak.types.unknowntype.UnknownType(), 10, parameters={"x": 123} ) ) == '[10 * unknown, parameters={"x": 123}]' @@ -296,7 +325,10 @@ def test_RegularType(): assert ( str( ak.types.regulartype.RegularType( - ak.types.unknowntype.UnknownType(), 10, None, typestr="override" + ak.types.unknowntype.UnknownType(), + 10, + parameters=None, + typestr="override", ) ) == "override" @@ -304,7 +336,10 @@ def test_RegularType(): assert ( str( ak.types.regulartype.RegularType( - ak.types.unknowntype.UnknownType(), 10, {"x": 123}, typestr="override" + ak.types.unknowntype.UnknownType(), + 10, + parameters={"x": 123}, + typestr="override", ) ) == "override" @@ -312,7 +347,9 @@ def test_RegularType(): assert ( str( ak.types.regulartype.RegularType( - ak.types.unknowntype.UnknownType(), 10, {"__categorical__": True} + ak.types.unknowntype.UnknownType(), + 10, + parameters={"__categorical__": True}, ) ) == "categorical[type=10 * unknown]" @@ -322,7 +359,7 @@ def test_RegularType(): ak.types.regulartype.RegularType( ak.types.unknowntype.UnknownType(), 10, - {"__categorical__": True, "x": 123}, + parameters={"__categorical__": True, "x": 123}, ) ) == 'categorical[type=[10 * unknown, parameters={"x": 123}]]' @@ -332,7 +369,7 @@ def test_RegularType(): ak.types.regulartype.RegularType( ak.types.unknowntype.UnknownType(), 10, - {"__categorical__": True}, + parameters={"__categorical__": True}, typestr="override", ) ) @@ -341,9 +378,9 @@ def test_RegularType(): assert ( str( ak.types.regulartype.RegularType( - ak.types.numpytype.NumpyType("uint8", {"__array__": "char"}), + ak.types.numpytype.NumpyType("uint8", parameters={"__array__": "char"}), 10, - {"__array__": "string"}, + parameters={"__array__": "string"}, ) ) == "string[10]" @@ -351,9 +388,9 @@ def test_RegularType(): assert ( str( ak.types.regulartype.RegularType( - ak.types.numpytype.NumpyType("uint8", {"__array__": "byte"}), + ak.types.numpytype.NumpyType("uint8", parameters={"__array__": "byte"}), 10, - {"__array__": "bytestring"}, + parameters={"__array__": "bytestring"}, ) ) == "bytes[10]" @@ -410,13 +447,17 @@ def test_ListType(): == "var * unknown" ) assert ( - str(ak.types.listtype.ListType(ak.types.unknowntype.UnknownType(), {"x": 123})) + str( + ak.types.listtype.ListType( + ak.types.unknowntype.UnknownType(), parameters={"x": 123} + ) + ) == '[var * unknown, parameters={"x": 123}]' ) assert ( str( ak.types.listtype.ListType( - ak.types.unknowntype.UnknownType(), None, typestr="override" + ak.types.unknowntype.UnknownType(), parameters=None, typestr="override" ) ) == "override" @@ -424,7 +465,9 @@ def test_ListType(): assert ( str( ak.types.listtype.ListType( - ak.types.unknowntype.UnknownType(), {"x": 123}, typestr="override" + ak.types.unknowntype.UnknownType(), + parameters={"x": 123}, + typestr="override", ) ) == "override" @@ -432,7 +475,7 @@ def test_ListType(): assert ( str( ak.types.listtype.ListType( - ak.types.unknowntype.UnknownType(), {"__categorical__": True} + ak.types.unknowntype.UnknownType(), parameters={"__categorical__": True} ) ) == "categorical[type=var * unknown]" @@ -441,7 +484,7 @@ def test_ListType(): str( ak.types.listtype.ListType( ak.types.unknowntype.UnknownType(), - {"__categorical__": True, "x": 123}, + parameters={"__categorical__": True, "x": 123}, ) ) == 'categorical[type=[var * unknown, parameters={"x": 123}]]' @@ -450,7 +493,7 @@ def test_ListType(): str( ak.types.listtype.ListType( ak.types.unknowntype.UnknownType(), - {"__categorical__": True}, + parameters={"__categorical__": True}, typestr="override", ) ) @@ -459,8 +502,8 @@ def test_ListType(): assert ( str( ak.types.listtype.ListType( - ak.types.numpytype.NumpyType("uint8", {"__array__": "char"}), - {"__array__": "string"}, + ak.types.numpytype.NumpyType("uint8", parameters={"__array__": "char"}), + parameters={"__array__": "string"}, ) ) == "string" @@ -468,8 +511,8 @@ def test_ListType(): assert ( str( ak.types.listtype.ListType( - ak.types.numpytype.NumpyType("uint8", {"__array__": "byte"}), - {"__array__": "bytestring"}, + ak.types.numpytype.NumpyType("uint8", parameters={"__array__": "byte"}), + parameters={"__array__": "bytestring"}, ) ) == "bytes" @@ -546,7 +589,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], None, - {"__record__": "Name"}, + parameters={"__record__": "Name"}, ) ) == "Name[unknown, bool]" @@ -559,7 +602,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], ["x", "y"], - {"__record__": "Name"}, + parameters={"__record__": "Name"}, ) ) == "Name[x: unknown, y: bool]" @@ -572,7 +615,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], None, - None, + parameters=None, typestr="override", ) ) @@ -586,7 +629,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], ["x", "y"], - None, + parameters=None, typestr="override", ) ) @@ -600,7 +643,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], None, - {"__record__": "Name"}, + parameters={"__record__": "Name"}, typestr="override", ) ) @@ -614,7 +657,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], ["x", "y"], - {"__record__": "Name"}, + parameters={"__record__": "Name"}, typestr="override", ) ) @@ -628,7 +671,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], None, - {"x": 123}, + parameters={"x": 123}, ) ) == 'tuple[[unknown, bool], parameters={"x": 123}]' @@ -641,7 +684,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], ["x", "y"], - {"x": 123}, + parameters={"x": 123}, ) ) == 'struct[{x: unknown, y: bool}, parameters={"x": 123}]' @@ -654,7 +697,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], None, - {"__record__": "Name", "x": 123}, + parameters={"__record__": "Name", "x": 123}, ) ) == 'Name[unknown, bool, parameters={"x": 123}]' @@ -667,7 +710,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], ["x", "y"], - {"__record__": "Name", "x": 123}, + parameters={"__record__": "Name", "x": 123}, ) ) == 'Name[x: unknown, y: bool, parameters={"x": 123}]' @@ -680,7 +723,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], None, - {"x": 123}, + parameters={"x": 123}, typestr="override", ) ) @@ -694,7 +737,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], ["x", "y"], - {"x": 123}, + parameters={"x": 123}, typestr="override", ) ) @@ -708,7 +751,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], None, - {"__record__": "Name", "x": 123}, + parameters={"__record__": "Name", "x": 123}, typestr="override", ) ) @@ -722,7 +765,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], ["x", "y"], - {"__record__": "Name", "x": 123}, + parameters={"__record__": "Name", "x": 123}, typestr="override", ) ) @@ -736,7 +779,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], None, - {"__categorical__": True}, + parameters={"__categorical__": True}, ) ) == "categorical[type=(unknown, bool)]" @@ -749,7 +792,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], ["x", "y"], - {"__categorical__": True}, + parameters={"__categorical__": True}, ) ) == "categorical[type={x: unknown, y: bool}]" @@ -762,7 +805,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], None, - {"__record__": "Name", "__categorical__": True}, + parameters={"__record__": "Name", "__categorical__": True}, ) ) == "categorical[type=Name[unknown, bool]]" @@ -775,7 +818,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], ["x", "y"], - {"__record__": "Name", "__categorical__": True}, + parameters={"__record__": "Name", "__categorical__": True}, ) ) == "categorical[type=Name[x: unknown, y: bool]]" @@ -788,7 +831,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], None, - {"__categorical__": True}, + parameters={"__categorical__": True}, typestr="override", ) ) @@ -802,7 +845,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], ["x", "y"], - {"__categorical__": True}, + parameters={"__categorical__": True}, typestr="override", ) ) @@ -816,7 +859,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], None, - {"__record__": "Name", "__categorical__": True}, + parameters={"__record__": "Name", "__categorical__": True}, typestr="override", ) ) @@ -830,7 +873,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], ["x", "y"], - {"__record__": "Name", "__categorical__": True}, + parameters={"__record__": "Name", "__categorical__": True}, typestr="override", ) ) @@ -844,7 +887,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], None, - {"x": 123, "__categorical__": True}, + parameters={"x": 123, "__categorical__": True}, ) ) == 'categorical[type=tuple[[unknown, bool], parameters={"x": 123}]]' @@ -857,7 +900,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], ["x", "y"], - {"x": 123, "__categorical__": True}, + parameters={"x": 123, "__categorical__": True}, ) ) == 'categorical[type=struct[{x: unknown, y: bool}, parameters={"x": 123}]]' @@ -870,7 +913,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], None, - {"__record__": "Name", "x": 123, "__categorical__": True}, + parameters={"__record__": "Name", "x": 123, "__categorical__": True}, ) ) == 'categorical[type=Name[unknown, bool, parameters={"x": 123}]]' @@ -883,7 +926,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], ["x", "y"], - {"__record__": "Name", "x": 123, "__categorical__": True}, + parameters={"__record__": "Name", "x": 123, "__categorical__": True}, ) ) == 'categorical[type=Name[x: unknown, y: bool, parameters={"x": 123}]]' @@ -896,7 +939,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], None, - {"x": 123, "__categorical__": True}, + parameters={"x": 123, "__categorical__": True}, typestr="override", ) ) @@ -910,7 +953,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], ["x", "y"], - {"x": 123, "__categorical__": True}, + parameters={"x": 123, "__categorical__": True}, typestr="override", ) ) @@ -924,7 +967,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], None, - {"__record__": "Name", "x": 123, "__categorical__": True}, + parameters={"__record__": "Name", "x": 123, "__categorical__": True}, typestr="override", ) ) @@ -938,7 +981,7 @@ def test_RecordType(): ak.types.numpytype.NumpyType("bool"), ], ["x", "y"], - {"__record__": "Name", "x": 123, "__categorical__": True}, + parameters={"__record__": "Name", "x": 123, "__categorical__": True}, typestr="override", ) ) @@ -1036,7 +1079,7 @@ def test_OptionType(): assert ( str( ak.types.optiontype.OptionType( - ak.types.unknowntype.UnknownType(), {"x": 123} + ak.types.unknowntype.UnknownType(), parameters={"x": 123} ) ) == 'option[unknown, parameters={"x": 123}]' @@ -1045,7 +1088,7 @@ def test_OptionType(): str( ak.types.optiontype.OptionType( ak.types.listtype.ListType(ak.types.unknowntype.UnknownType()), - {"x": 123}, + parameters={"x": 123}, ) ) == 'option[var * unknown, parameters={"x": 123}]' @@ -1056,7 +1099,7 @@ def test_OptionType(): ak.types.regulartype.RegularType( ak.types.unknowntype.UnknownType(), 10 ), - {"x": 123}, + parameters={"x": 123}, ) ) == 'option[10 * unknown, parameters={"x": 123}]' @@ -1064,7 +1107,7 @@ def test_OptionType(): assert ( str( ak.types.optiontype.OptionType( - ak.types.unknowntype.UnknownType(), None, typestr="override" + ak.types.unknowntype.UnknownType(), parameters=None, typestr="override" ) ) == "override" @@ -1073,7 +1116,7 @@ def test_OptionType(): str( ak.types.optiontype.OptionType( ak.types.listtype.ListType(ak.types.unknowntype.UnknownType()), - None, + parameters=None, typestr="override", ) ) @@ -1085,7 +1128,7 @@ def test_OptionType(): ak.types.regulartype.RegularType( ak.types.unknowntype.UnknownType(), 10 ), - None, + parameters=None, typestr="override", ) ) @@ -1094,7 +1137,9 @@ def test_OptionType(): assert ( str( ak.types.optiontype.OptionType( - ak.types.unknowntype.UnknownType(), {"x": 123}, typestr="override" + ak.types.unknowntype.UnknownType(), + parameters={"x": 123}, + typestr="override", ) ) == "override" @@ -1103,7 +1148,7 @@ def test_OptionType(): str( ak.types.optiontype.OptionType( ak.types.listtype.ListType(ak.types.unknowntype.UnknownType()), - {"x": 123}, + parameters={"x": 123}, typestr="override", ) ) @@ -1115,7 +1160,7 @@ def test_OptionType(): ak.types.regulartype.RegularType( ak.types.unknowntype.UnknownType(), 10 ), - {"x": 123}, + parameters={"x": 123}, typestr="override", ) ) @@ -1124,7 +1169,7 @@ def test_OptionType(): assert ( str( ak.types.optiontype.OptionType( - ak.types.unknowntype.UnknownType(), {"__categorical__": True} + ak.types.unknowntype.UnknownType(), parameters={"__categorical__": True} ) ) == "?categorical[type=unknown]" @@ -1133,7 +1178,7 @@ def test_OptionType(): str( ak.types.optiontype.OptionType( ak.types.listtype.ListType(ak.types.unknowntype.UnknownType()), - {"__categorical__": True}, + parameters={"__categorical__": True}, ) ) == "option[categorical[type=var * unknown]]" @@ -1144,7 +1189,7 @@ def test_OptionType(): ak.types.regulartype.RegularType( ak.types.unknowntype.UnknownType(), 10 ), - {"__categorical__": True}, + parameters={"__categorical__": True}, ) ) == "option[categorical[type=10 * unknown]]" @@ -1153,7 +1198,7 @@ def test_OptionType(): str( ak.types.optiontype.OptionType( ak.types.unknowntype.UnknownType(), - {"x": 123, "__categorical__": True}, + parameters={"x": 123, "__categorical__": True}, ) ) == 'option[categorical[type=unknown], parameters={"x": 123}]' @@ -1162,7 +1207,7 @@ def test_OptionType(): str( ak.types.optiontype.OptionType( ak.types.listtype.ListType(ak.types.unknowntype.UnknownType()), - {"x": 123, "__categorical__": True}, + parameters={"x": 123, "__categorical__": True}, ) ) == 'option[categorical[type=var * unknown], parameters={"x": 123}]' @@ -1173,7 +1218,7 @@ def test_OptionType(): ak.types.regulartype.RegularType( ak.types.unknowntype.UnknownType(), 10 ), - {"x": 123, "__categorical__": True}, + parameters={"x": 123, "__categorical__": True}, ) ) == 'option[categorical[type=10 * unknown], parameters={"x": 123}]' @@ -1182,7 +1227,7 @@ def test_OptionType(): str( ak.types.optiontype.OptionType( ak.types.unknowntype.UnknownType(), - {"__categorical__": True}, + parameters={"__categorical__": True}, typestr="override", ) ) @@ -1192,7 +1237,7 @@ def test_OptionType(): str( ak.types.optiontype.OptionType( ak.types.listtype.ListType(ak.types.unknowntype.UnknownType()), - {"__categorical__": True}, + parameters={"__categorical__": True}, typestr="override", ) ) @@ -1204,7 +1249,7 @@ def test_OptionType(): ak.types.regulartype.RegularType( ak.types.unknowntype.UnknownType(), 10 ), - {"__categorical__": True}, + parameters={"__categorical__": True}, typestr="override", ) ) @@ -1214,7 +1259,7 @@ def test_OptionType(): str( ak.types.optiontype.OptionType( ak.types.unknowntype.UnknownType(), - {"x": 123, "__categorical__": True}, + parameters={"x": 123, "__categorical__": True}, typestr="override", ) ) @@ -1224,7 +1269,7 @@ def test_OptionType(): str( ak.types.optiontype.OptionType( ak.types.listtype.ListType(ak.types.unknowntype.UnknownType()), - {"x": 123, "__categorical__": True}, + parameters={"x": 123, "__categorical__": True}, typestr="override", ) ) @@ -1236,7 +1281,7 @@ def test_OptionType(): ak.types.regulartype.RegularType( ak.types.unknowntype.UnknownType(), 10 ), - {"x": 123, "__categorical__": True}, + parameters={"x": 123, "__categorical__": True}, typestr="override", ) ) @@ -1288,7 +1333,7 @@ def test_UnionType(): ak.types.unknowntype.UnknownType(), ak.types.numpytype.NumpyType("bool"), ], - {"x": 123}, + parameters={"x": 123}, ) ) == 'union[unknown, bool, parameters={"x": 123}]' @@ -1300,7 +1345,7 @@ def test_UnionType(): ak.types.unknowntype.UnknownType(), ak.types.numpytype.NumpyType("bool"), ], - None, + parameters=None, typestr="override", ) ) @@ -1313,7 +1358,7 @@ def test_UnionType(): ak.types.unknowntype.UnknownType(), ak.types.numpytype.NumpyType("bool"), ], - {"x": 123}, + parameters={"x": 123}, typestr="override", ) ) @@ -1326,7 +1371,7 @@ def test_UnionType(): ak.types.unknowntype.UnknownType(), ak.types.numpytype.NumpyType("bool"), ], - {"__categorical__": True}, + parameters={"__categorical__": True}, ) ) == "categorical[type=union[unknown, bool]]" @@ -1338,7 +1383,7 @@ def test_UnionType(): ak.types.unknowntype.UnknownType(), ak.types.numpytype.NumpyType("bool"), ], - {"x": 123, "__categorical__": True}, + parameters={"x": 123, "__categorical__": True}, ) ) == 'categorical[type=union[unknown, bool, parameters={"x": 123}]]' @@ -1350,7 +1395,7 @@ def test_UnionType(): ak.types.unknowntype.UnknownType(), ak.types.numpytype.NumpyType("bool"), ], - {"__categorical__": True}, + parameters={"__categorical__": True}, typestr="override", ) ) @@ -1363,7 +1408,7 @@ def test_UnionType(): ak.types.unknowntype.UnknownType(), ak.types.numpytype.NumpyType("bool"), ], - {"x": 123, "__categorical__": True}, + parameters={"x": 123, "__categorical__": True}, typestr="override", ) )