diff --git a/.ci/azure-buildtest-awkward.yml b/.ci/azure-buildtest-awkward.yml index 4d3688e3aa..3f763f9a00 100644 --- a/.ci/azure-buildtest-awkward.yml +++ b/.ci/azure-buildtest-awkward.yml @@ -28,11 +28,11 @@ jobs: "py27-32bit": python.version: "2.7" python.architecture: "x86" - numpy.version: "latest" + numpy.version: "1.16.5" "py27-64bit": python.version: "2.7" python.architecture: "x64" - numpy.version: "latest" + numpy.version: "1.16.5" "py35-32bit": python.version: "3.5" python.architecture: "x86" @@ -57,6 +57,14 @@ jobs: python.version: "3.7" python.architecture: "x64" numpy.version: "latest" + "py38-32bit": + python.version: "3.8" + python.architecture: "x86" + numpy.version: "latest" + "py38-64bit": + python.version: "3.8" + python.architecture: "x64" + numpy.version: "latest" steps: - checkout: self @@ -90,11 +98,7 @@ jobs: "py27": python.version: "2.7" python.architecture: "x64" - numpy.version: "latest" - "py34": - python.version: "3.4" - python.architecture: "x64" - numpy.version: "latest" + numpy.version: "1.16.5" "py35": python.version: "3.5" python.architecture: "x64" @@ -107,6 +111,10 @@ jobs: python.version: "3.7" python.architecture: "x64" numpy.version: "latest" + "py38": + python.version: "3.8" + python.architecture: "x64" + numpy.version: "latest" steps: - checkout: self @@ -141,18 +149,18 @@ jobs: python.version: "2.7" python.architecture: "x64" numpy.version: "1.13.1" - "py27-np*": + "py27-np16": python.version: "2.7" python.architecture: "x64" - numpy.version: "latest" + numpy.version: "1.16.5" "py34-np13": python.version: "3.4" python.architecture: "x64" numpy.version: "1.13.1" - "py34-np*": + "py34-np16": python.version: "3.4" python.architecture: "x64" - numpy.version: "latest" + numpy.version: "1.16.5" "py35-np13": python.version: "3.5" python.architecture: "x64" @@ -177,6 +185,10 @@ jobs: python.version: "3.7" python.architecture: "x64" numpy.version: "latest" + "py38-np*": + python.version: "3.8" + python.architecture: "x64" + numpy.version: "latest" steps: - checkout: self diff --git a/.ci/azure-deploy-awkward.yml b/.ci/azure-deploy-awkward.yml index 7ff43aa703..daaecc3f01 100644 --- a/.ci/azure-deploy-awkward.yml +++ b/.ci/azure-deploy-awkward.yml @@ -72,11 +72,11 @@ jobs: "py27-32bit": python.version: "2.7" python.architecture: "x86" - numpy.version: "latest" + numpy.version: "1.16.5" "py27-64bit": python.version: "2.7" python.architecture: "x64" - numpy.version: "latest" + numpy.version: "1.16.5" "py35-32bit": python.version: "3.5" python.architecture: "x86" @@ -101,6 +101,14 @@ jobs: python.version: "3.7" python.architecture: "x64" numpy.version: "latest" + "py38-32bit": + python.version: "3.8" + python.architecture: "x86" + numpy.version: "latest" + "py38-64bit": + python.version: "3.8" + python.architecture: "x64" + numpy.version: "latest" steps: - checkout: self @@ -150,6 +158,10 @@ jobs: python.version: "3.7" python.architecture: "x64" numpy.version: "latest" + "py38": + python.version: "3.8" + python.architecture: "x64" + numpy.version: "latest" steps: - checkout: self @@ -164,13 +176,16 @@ jobs: - script: | case $(python.version) in 2.7) - FULL_VERSION=2.7.16 + FULL_VERSION=2.7.17 ;; 3.6) - FULL_VERSION=3.6.8 + FULL_VERSION=3.6.9 ;; 3.7) - FULL_VERSION=3.7.3 + FULL_VERSION=3.7.5 + ;; + 3.8) + FULL_VERSION=3.8.0 ;; esac diff --git a/VERSION_INFO b/VERSION_INFO index d8a023ec10..baa9837854 100644 --- a/VERSION_INFO +++ b/VERSION_INFO @@ -1 +1 @@ -0.1.19 +0.1.20 diff --git a/awkward1/_numba/array/listarray.py b/awkward1/_numba/array/listarray.py index 2056d47b61..7524765c0a 100644 --- a/awkward1/_numba/array/listarray.py +++ b/awkward1/_numba/array/listarray.py @@ -11,6 +11,7 @@ from ..._numba import cpu, util, content @numba.extending.typeof_impl.register(awkward1.layout.ListArray32) +@numba.extending.typeof_impl.register(awkward1.layout.ListArrayU32) @numba.extending.typeof_impl.register(awkward1.layout.ListArray64) def typeof(val, c): return ListArrayType(numba.typeof(numpy.asarray(val.starts)), numba.typeof(numpy.asarray(val.stops)), numba.typeof(val.content), numba.typeof(val.id)) @@ -18,7 +19,7 @@ def typeof(val, c): class ListArrayType(content.ContentType): def __init__(self, startstpe, stopstpe, contenttpe, idtpe): assert startstpe == stopstpe - super(ListArrayType, self).__init__(name="ListArray{}Type({}, id={})".format(startstpe.dtype.bitwidth, contenttpe.name, idtpe.name)) + super(ListArrayType, self).__init__(name="ListArray{}{}Type({}, id={})".format("" if startstpe.dtype.signed else "U", startstpe.dtype.bitwidth, contenttpe.name, idtpe.name)) self.startstpe = startstpe self.contenttpe = contenttpe self.idtpe = idtpe @@ -31,6 +32,10 @@ def stopstpe(self): def bitwidth(self): return self.startstpe.dtype.bitwidth + @property + def indexname(self): + return ("" if self.startstpe.dtype.signed else "U") + str(self.startstpe.dtype.bitwidth) + @property def ndim(self): return 1 + self.contenttpe.ndim @@ -58,7 +63,7 @@ def getitem_next(self, wheretpe, isadvanced): elif isinstance(headtpe, numba.types.SliceType): contenttpe = self.contenttpe.carry().getitem_next(tailtpe, isadvanced) - return awkward1._numba.array.listoffsetarray.ListOffsetArrayType(util.indextpe(self.bitwidth), contenttpe, self.idtpe) + return awkward1._numba.array.listoffsetarray.ListOffsetArrayType(util.indextpe(self.indexname), contenttpe, self.idtpe) elif isinstance(headtpe, numba.types.EllipsisType): raise NotImplementedError("ellipsis") @@ -71,7 +76,7 @@ def getitem_next(self, wheretpe, isadvanced): raise NotImplementedError("array.ndim != 1") contenttpe = self.contenttpe.carry().getitem_next(tailtpe, True) if not isadvanced: - return awkward1._numba.array.listoffsetarray.ListOffsetArrayType(util.indextpe(self.bitwidth), contenttpe, self.idtpe) + return awkward1._numba.array.listoffsetarray.ListOffsetArrayType(util.indextpe(self.indexname), contenttpe, self.idtpe) else: return contenttpe @@ -138,14 +143,17 @@ def unbox(tpe, obj, c): @numba.extending.box(ListArrayType) def box(tpe, val, c): - if tpe.bitwidth == 32: - Index_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.Index32)) - ListArray_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.ListArray32)) - elif tpe.bitwidth == 64: + if tpe.indexname == "64": Index_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.Index64)) ListArray_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.ListArray64)) + elif tpe.indexname == "32": + Index_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.Index32)) + ListArray_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.ListArray32)) + elif tpe.indexname == "U32": + Index_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.IndexU32)) + ListArray_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.ListArrayU32)) else: - raise AssertionError("unrecognized bitwidth") + raise AssertionError("unrecognized index type: {}".format(tpe.indexname)) proxyin = numba.cgutils.create_struct_proxy(tpe)(c.context, c.builder, value=val) startsarray_obj = c.pyapi.from_native_value(tpe.startstpe, proxyin.starts, c.env_manager) stopsarray_obj = c.pyapi.from_native_value(tpe.stopstpe, proxyin.stops, c.env_manager) @@ -258,12 +266,14 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, if isinstance(headtpe, numba.types.Integer): assert advanced is None - if arraytpe.bitwidth == 64: + if arraytpe.indexname == "64": kernel = cpu.kernels.awkward_listarray64_getitem_next_at_64 - elif arraytpe.bitwidth == 32: + elif arraytpe.indexname == "32": kernel = cpu.kernels.awkward_listarray32_getitem_next_at_64 + elif arraytpe.indexname == "U32": + kernel = cpu.kernels.awkward_listarrayU32_getitem_next_at_64 else: - raise AssertionError("unrecognized bitwidth") + raise AssertionError("unrecognized index type: {}".format(arraytpe.indexname)) nextcarry = util.newindex64(context, builder, numba.int64, lenstarts) util.call(context, builder, kernel, @@ -282,18 +292,23 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, elif isinstance(headtpe, numba.types.SliceType): proxyslicein = numba.cgutils.create_struct_proxy(headtpe)(context, builder, value=headval) - if arraytpe.bitwidth == 64: + if arraytpe.indexname == "64": determine_carrylength = cpu.kernels.awkward_listarray64_getitem_next_range_carrylength fill_carry = cpu.kernels.awkward_listarray64_getitem_next_range_64 determine_total = cpu.kernels.awkward_listarray64_getitem_next_range_counts_64 fill_nextadvanced = cpu.kernels.awkward_listarray64_getitem_next_range_spreadadvanced_64 - elif arraytpe.bitwidth == 32: + elif arraytpe.indexname == "32": determine_carrylength = cpu.kernels.awkward_listarray32_getitem_next_range_carrylength fill_carry = cpu.kernels.awkward_listarray32_getitem_next_range_64 determine_total = cpu.kernels.awkward_listarray32_getitem_next_range_counts_64 fill_nextadvanced = cpu.kernels.awkward_listarray32_getitem_next_range_spreadadvanced_64 + elif arraytpe.indexname == "U32": + determine_carrylength = cpu.kernels.awkward_listarrayU32_getitem_next_range_carrylength + fill_carry = cpu.kernels.awkward_listarrayU32_getitem_next_range_64 + determine_total = cpu.kernels.awkward_listarrayU32_getitem_next_range_counts_64 + fill_nextadvanced = cpu.kernels.awkward_listarrayU32_getitem_next_range_spreadadvanced_64 else: - raise AssertionError("unrecognized bitwidth") + raise AssertionError("unrecognized index type: {}".format(arraytpe.indexname)) carrylength = numba.cgutils.alloca_once(builder, context.get_value_type(numba.int64)) util.call(context, builder, determine_carrylength, @@ -308,10 +323,10 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, util.cast(context, builder, numba.intp, numba.int64, proxyslicein.step)), "in {}, indexing error".format(arraytpe.shortname)) - nextoffsets = util.newindex(arraytpe.bitwidth, context, builder, numba.int64, builder.add(lenstarts, context.get_constant(numba.int64, 1))) + nextoffsets = util.newindex(arraytpe.indexname, context, builder, numba.int64, builder.add(lenstarts, context.get_constant(numba.int64, 1))) nextcarry = util.newindex64(context, builder, numba.int64, builder.load(carrylength)) util.call(context, builder, fill_carry, - (util.arrayptr(context, builder, util.indextpe(arraytpe.bitwidth), nextoffsets), + (util.arrayptr(context, builder, util.indextpe(arraytpe.indexname), nextoffsets), util.arrayptr(context, builder, util.index64tpe, nextcarry), util.arrayptr(context, builder, arraytpe.startstpe, proxyin.starts), util.arrayptr(context, builder, arraytpe.stopstpe, proxyin.stops), @@ -334,7 +349,7 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, total = numba.cgutils.alloca_once(builder, context.get_value_type(numba.int64)) util.call(context, builder, determine_total, (total, - util.arrayptr(context, builder, util.indextpe(arraytpe.bitwidth), nextoffsets), + util.arrayptr(context, builder, util.indextpe(arraytpe.indexname), nextoffsets), lenstarts), "in {}, indexing error".format(arraytpe.shortname)) @@ -342,14 +357,14 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, util.call(context, builder, fill_nextadvanced, (util.arrayptr(context, builder, util.index64tpe, nextadvanced), util.arrayptr(context, builder, util.index64tpe, advanced), - util.arrayptr(context, builder, util.indextpe(arraytpe.bitwidth), nextoffsets), + util.arrayptr(context, builder, util.indextpe(arraytpe.indexname), nextoffsets), lenstarts), "in {}, indexing error".format(arraytpe.shortname)) outcontenttpe = nextcontenttpe.getitem_next(tailtpe, True) outcontentval = nextcontenttpe.lower_getitem_next(context, builder, nextcontenttpe, tailtpe, nextcontentval, tailval, nextadvanced) - outtpe = awkward1._numba.array.listoffsetarray.ListOffsetArrayType(util.indextpe(arraytpe.bitwidth), outcontenttpe, arraytpe.idtpe) + outtpe = awkward1._numba.array.listoffsetarray.ListOffsetArrayType(util.indextpe(arraytpe.indexname), outcontenttpe, arraytpe.idtpe) proxyout = numba.cgutils.create_struct_proxy(outtpe)(context, builder) proxyout.offsets = nextoffsets proxyout.content = outcontentval @@ -371,21 +386,23 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, lenflathead = util.arraylen(context, builder, util.index64tpe, flathead, totpe=numba.int64) if advanced is None: - if arraytpe.bitwidth == 64: + if arraytpe.indexname == "64": kernel = cpu.kernels.awkward_listarray64_getitem_next_array_64 - elif arraytpe.bitwidth == 32: + elif arraytpe.indexname == "32": kernel = cpu.kernels.awkward_listarray32_getitem_next_array_64 + elif arraytpe.indexname == "U32": + kernel = cpu.kernels.awkward_listarrayU32_getitem_next_array_64 else: - raise AssertionError("unrecognized bitwidth") + raise AssertionError("unrecognized index type: {}".format(arraytpe.indexname)) lencarry = builder.mul(lenstarts, lenflathead) lenoffsets = builder.add(lenstarts, context.get_constant(numba.int64, 1)) nextcarry = util.newindex64(context, builder, numba.int64, lencarry) nextadvanced = util.newindex64(context, builder, numba.int64, lencarry) - nextoffsets = util.newindex(arraytpe.bitwidth, context, builder, numba.int64, lenoffsets) + nextoffsets = util.newindex(arraytpe.indexname, context, builder, numba.int64, lenoffsets) util.call(context, builder, kernel, - (util.arrayptr(context, builder, util.indextpe(arraytpe.bitwidth), nextoffsets), + (util.arrayptr(context, builder, util.indextpe(arraytpe.indexname), nextoffsets), util.arrayptr(context, builder, util.index64tpe, nextcarry), util.arrayptr(context, builder, util.index64tpe, nextadvanced), util.arrayptr(context, builder, arraytpe.startstpe, proxyin.starts), @@ -404,7 +421,7 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, contenttpe = nexttpe.getitem_next(tailtpe, True) contentval = nexttpe.lower_getitem_next(context, builder, nexttpe, tailtpe, nextval, tailval, nextadvanced) - outtpe = awkward1._numba.array.listoffsetarray.ListOffsetArrayType(util.indextpe(arraytpe.bitwidth), contenttpe, arraytpe.idtpe) + outtpe = awkward1._numba.array.listoffsetarray.ListOffsetArrayType(util.indextpe(arraytpe.indexname), contenttpe, arraytpe.idtpe) proxyout = numba.cgutils.create_struct_proxy(outtpe)(context, builder) proxyout.offsets = nextoffsets proxyout.content = contentval @@ -413,12 +430,14 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, return proxyout._getvalue() else: - if arraytpe.bitwidth == 64: + if arraytpe.indexname == "64": kernel = cpu.kernels.awkward_listarray64_getitem_next_array_advanced_64 - elif arraytpe.bitwidth == 32: + elif arraytpe.indexname == "32": kernel = cpu.kernels.awkward_listarray32_getitem_next_array_advanced_64 + elif arraytpe.indexname == "U32": + kernel = cpu.kernels.awkward_listarrayU32_getitem_next_array_advanced_64 else: - raise AssertionError("unrecognized bitwidth") + raise AssertionError("unrecognized index type: {}".format(arraytpe.indexname)) nextcarry = util.newindex64(context, builder, numba.int64, lenstarts) nextadvanced = util.newindex64(context, builder, numba.int64, lenstarts) diff --git a/awkward1/_numba/array/listoffsetarray.py b/awkward1/_numba/array/listoffsetarray.py index e6c3098f94..745bbfe50b 100644 --- a/awkward1/_numba/array/listoffsetarray.py +++ b/awkward1/_numba/array/listoffsetarray.py @@ -10,13 +10,14 @@ from ..._numba import cpu, util, content @numba.extending.typeof_impl.register(awkward1.layout.ListOffsetArray32) +@numba.extending.typeof_impl.register(awkward1.layout.ListOffsetArrayU32) @numba.extending.typeof_impl.register(awkward1.layout.ListOffsetArray64) def typeof(val, c): return ListOffsetArrayType(numba.typeof(numpy.asarray(val.offsets)), numba.typeof(val.content), numba.typeof(val.id)) class ListOffsetArrayType(content.ContentType): def __init__(self, offsetstpe, contenttpe, idtpe): - super(ListOffsetArrayType, self).__init__(name="ListOffsetArray{}Type({}, id={})".format(offsetstpe.dtype.bitwidth, contenttpe.name, idtpe.name)) + super(ListOffsetArrayType, self).__init__(name="ListOffsetArray{}{}Type({}, id={})".format("" if offsetstpe.dtype.signed else "U", offsetstpe.dtype.bitwidth, contenttpe.name, idtpe.name)) self.offsetstpe = offsetstpe self.contenttpe = contenttpe self.idtpe = idtpe @@ -25,6 +26,10 @@ def __init__(self, offsetstpe, contenttpe, idtpe): def bitwidth(self): return self.offsetstpe.dtype.bitwidth + @property + def indexname(self): + return ("" if self.offsetstpe.dtype.signed else "U") + str(self.offsetstpe.dtype.bitwidth) + @property def ndim(self): return 1 + self.contenttpe.ndim @@ -52,7 +57,7 @@ def getitem_next(self, wheretpe, isadvanced): elif isinstance(headtpe, numba.types.SliceType): contenttpe = self.contenttpe.carry().getitem_next(tailtpe, isadvanced) - return ListOffsetArrayType(util.indextpe(self.bitwidth), contenttpe, self.idtpe) + return ListOffsetArrayType(util.indextpe(self.indexname), contenttpe, self.idtpe) elif isinstance(headtpe, numba.types.EllipsisType): raise NotImplementedError("ellipsis") @@ -65,7 +70,7 @@ def getitem_next(self, wheretpe, isadvanced): raise NotImplementedError("array.ndim != 1") contenttpe = self.contenttpe.carry().getitem_next(tailtpe, True) if not isadvanced: - return ListOffsetArrayType(util.indextpe(self.bitwidth), contenttpe, self.idtpe) + return ListOffsetArrayType(util.indextpe(self.indexname), contenttpe, self.idtpe) else: return contenttpe @@ -127,14 +132,17 @@ def unbox(tpe, obj, c): @numba.extending.box(ListOffsetArrayType) def box(tpe, val, c): - if tpe.bitwidth == 32: - Index_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.Index32)) - ListOffsetArray_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.ListOffsetArray32)) - elif tpe.bitwidth == 64: + if tpe.indexname == "64": Index_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.Index64)) ListOffsetArray_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.ListOffsetArray64)) + elif tpe.indexname == "32": + Index_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.Index32)) + ListOffsetArray_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.ListOffsetArray32)) + elif tpe.indexname == "U32": + Index_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.IndexU32)) + ListOffsetArray_obj = c.pyapi.unserialize(c.pyapi.serialize_object(awkward1.layout.ListOffsetArrayU32)) else: - raise AssertionError("unrecognized bitwidth") + raise AssertionError("unrecognized index type: {}".format(tpe.indexname)) proxyin = numba.cgutils.create_struct_proxy(tpe)(c.context, c.builder, value=val) offsetsarray_obj = c.pyapi.from_native_value(tpe.offsetstpe, proxyin.offsets, c.env_manager) content_obj = c.pyapi.from_native_value(tpe.contenttpe, proxyin.content, c.env_manager) @@ -270,12 +278,14 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, if isinstance(headtpe, numba.types.Integer): assert advanced is None - if arraytpe.bitwidth == 64: + if arraytpe.indexname == "64": kernel = cpu.kernels.awkward_listarray64_getitem_next_at_64 - elif arraytpe.bitwidth == 32: + elif arraytpe.indexname == "32": kernel = cpu.kernels.awkward_listarray32_getitem_next_at_64 + elif arraytpe.indexname == "U32": + kernel = cpu.kernels.awkward_listarrayU32_getitem_next_at_64 else: - raise AssertionError("unrecognized bitwidth") + raise AssertionError("unrecognized index type: {}".format(arraytpe.indexname)) nextcarry = util.newindex64(context, builder, numba.int64, lenstarts) util.call(context, builder, kernel, @@ -294,18 +304,23 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, elif isinstance(headtpe, numba.types.SliceType): proxyslicein = numba.cgutils.create_struct_proxy(headtpe)(context, builder, value=headval) - if arraytpe.bitwidth == 64: + if arraytpe.indexname == "64": determine_carrylength = cpu.kernels.awkward_listarray64_getitem_next_range_carrylength fill_carry = cpu.kernels.awkward_listarray64_getitem_next_range_64 determine_total = cpu.kernels.awkward_listarray64_getitem_next_range_counts_64 fill_nextadvanced = cpu.kernels.awkward_listarray64_getitem_next_range_spreadadvanced_64 - elif arraytpe.bitwidth == 32: + elif arraytpe.indexname == "32": determine_carrylength = cpu.kernels.awkward_listarray32_getitem_next_range_carrylength fill_carry = cpu.kernels.awkward_listarray32_getitem_next_range_64 determine_total = cpu.kernels.awkward_listarray32_getitem_next_range_counts_64 fill_nextadvanced = cpu.kernels.awkward_listarray32_getitem_next_range_spreadadvanced_64 + elif arraytpe.indexname == "U32": + determine_carrylength = cpu.kernels.awkward_listarrayU32_getitem_next_range_carrylength + fill_carry = cpu.kernels.awkward_listarrayU32_getitem_next_range_64 + determine_total = cpu.kernels.awkward_listarrayU32_getitem_next_range_counts_64 + fill_nextadvanced = cpu.kernels.awkward_listarrayU32_getitem_next_range_spreadadvanced_64 else: - raise AssertionError("unrecognized bitwidth") + raise AssertionError("unrecognized index type: {}".format(arraytpe.indexname)) carrylength = numba.cgutils.alloca_once(builder, context.get_value_type(numba.int64)) util.call(context, builder, determine_carrylength, @@ -320,10 +335,10 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, util.cast(context, builder, numba.intp, numba.int64, proxyslicein.step)), "in {}, indexing error".format(arraytpe.shortname)) - nextoffsets = util.newindex(arraytpe.bitwidth, context, builder, numba.int64, builder.add(lenstarts, context.get_constant(numba.int64, 1))) + nextoffsets = util.newindex(arraytpe.indexname, context, builder, numba.int64, builder.add(lenstarts, context.get_constant(numba.int64, 1))) nextcarry = util.newindex64(context, builder, numba.int64, builder.load(carrylength)) util.call(context, builder, fill_carry, - (util.arrayptr(context, builder, util.indextpe(arraytpe.bitwidth), nextoffsets), + (util.arrayptr(context, builder, util.indextpe(arraytpe.indexname), nextoffsets), util.arrayptr(context, builder, util.index64tpe, nextcarry), util.arrayptr(context, builder, arraytpe.offsetstpe, starts), util.arrayptr(context, builder, arraytpe.offsetstpe, stops), @@ -346,7 +361,7 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, total = numba.cgutils.alloca_once(builder, context.get_value_type(numba.int64)) util.call(context, builder, determine_total, (total, - util.arrayptr(context, builder, util.indextpe(arraytpe.bitwidth), nextoffsets), + util.arrayptr(context, builder, util.indextpe(arraytpe.indexname), nextoffsets), lenstarts), "in {}, indexing error".format(arraytpe.shortname)) @@ -354,14 +369,14 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, util.call(context, builder, fill_nextadvanced, (util.arrayptr(context, builder, util.index64tpe, nextadvanced), util.arrayptr(context, builder, util.index64tpe, advanced), - util.arrayptr(context, builder, util.indextpe(arraytpe.bitwidth), nextoffsets), + util.arrayptr(context, builder, util.indextpe(arraytpe.indexname), nextoffsets), lenstarts), "in {}, indexing error".format(arraytpe.shortname)) outcontenttpe = nextcontenttpe.getitem_next(tailtpe, True) outcontentval = nextcontenttpe.lower_getitem_next(context, builder, nextcontenttpe, tailtpe, nextcontentval, tailval, nextadvanced) - outtpe = awkward1._numba.array.listoffsetarray.ListOffsetArrayType(util.indextpe(arraytpe.bitwidth), outcontenttpe, arraytpe.idtpe) + outtpe = awkward1._numba.array.listoffsetarray.ListOffsetArrayType(util.indextpe(arraytpe.indexname), outcontenttpe, arraytpe.idtpe) proxyout = numba.cgutils.create_struct_proxy(outtpe)(context, builder) proxyout.offsets = nextoffsets proxyout.content = outcontentval @@ -383,20 +398,22 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, lenflathead = util.arraylen(context, builder, util.int64tpe, flathead, totpe=numba.int64) if advanced is None: - if arraytpe.bitwidth == 64: + if arraytpe.indexname == "64": kernel = cpu.kernels.awkward_listarray64_getitem_next_array_64 - elif arraytpe.bitwidth == 32: + elif arraytpe.indexname == "32": kernel = cpu.kernels.awkward_listarray32_getitem_next_array_64 + elif arraytpe.indexname == "U32": + kernel = cpu.kernels.awkward_listarrayU32_getitem_next_array_64 else: - raise AssertionError("unrecognized bitwidth") + raise AssertionError("unrecognized index type: {}".format(arraytpe.indexname)) lencarry = builder.mul(lenstarts, lenflathead) nextcarry = util.newindex64(context, builder, numba.int64, lencarry) nextadvanced = util.newindex64(context, builder, numba.int64, lencarry) - nextoffsets = util.newindex(arraytpe.bitwidth, context, builder, numba.int64, lenoffsets) + nextoffsets = util.newindex(arraytpe.indexname, context, builder, numba.int64, lenoffsets) util.call(context, builder, kernel, - (util.arrayptr(context, builder, util.indextpe(arraytpe.bitwidth), nextoffsets), + (util.arrayptr(context, builder, util.indextpe(arraytpe.indexname), nextoffsets), util.arrayptr(context, builder, util.index64tpe, nextcarry), util.arrayptr(context, builder, util.index64tpe, nextadvanced), util.arrayptr(context, builder, arraytpe.offsetstpe, starts), @@ -415,7 +432,7 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, contenttpe = nexttpe.getitem_next(tailtpe, True) contentval = nexttpe.lower_getitem_next(context, builder, nexttpe, tailtpe, nextval, tailval, nextadvanced) - outtpe = ListOffsetArrayType(util.indextpe(arraytpe.bitwidth), contenttpe, arraytpe.idtpe) + outtpe = ListOffsetArrayType(util.indextpe(arraytpe.indexname), contenttpe, arraytpe.idtpe) proxyout = numba.cgutils.create_struct_proxy(outtpe)(context, builder) proxyout.offsets = nextoffsets proxyout.content = contentval @@ -424,12 +441,14 @@ def lower_getitem_next(context, builder, arraytpe, wheretpe, arrayval, whereval, return proxyout._getvalue() else: - if arraytpe.bitwidth == 64: + if arraytpe.indexname == "64": kernel = cpu.kernels.awkward_listarray64_getitem_next_array_advanced_64 - elif arraytpe.bitwidth == 32: + elif arraytpe.indexname == "32": kernel = cpu.kernels.awkward_listarray32_getitem_next_array_advanced_64 + elif arraytpe.indexname == "U32": + kernel = cpu.kernels.awkward_listarrayU32_getitem_next_array_advanced_64 else: - raise AssertionError("unrecognized bitwidth") + raise AssertionError("unrecognized index type: {}".format(arraytpe.indexname)) nextcarry = util.newindex64(context, builder, numba.int64, lenstarts) nextadvanced = util.newindex64(context, builder, numba.int64, lenstarts) diff --git a/awkward1/_numba/cpu.py b/awkward1/_numba/cpu.py index 660001d5c3..64b903940c 100644 --- a/awkward1/_numba/cpu.py +++ b/awkward1/_numba/cpu.py @@ -46,10 +46,14 @@ def __init__(self, dmm, fe_type): "int32_t": ctypes.c_int32, "int32_t *": ctypes.POINTER(ctypes.c_int32), "const int32_t *": ctypes.POINTER(ctypes.c_int32), + "uint32_t": ctypes.c_uint32, + "uint32_t *": ctypes.POINTER(ctypes.c_uint32), + "const uint32_t *": ctypes.POINTER(ctypes.c_uint32), "int64_t": ctypes.c_int64, "int64_t *": ctypes.POINTER(ctypes.c_int64), "const int64_t *": ctypes.POINTER(ctypes.c_int64), "Error": Error, + "ERROR": Error, "void": None, } @@ -63,7 +67,7 @@ def __init__(self, dmm, fe_type): params = [(x.find("./declname").text, x.find("./type").text) for x in xfcn.findall("./param")] getattr(kernels, name).name = name getattr(kernels, name).argtypes = [h2ctypes[t] for n, t in params] - if rettype == "Error": + if rettype == "Error" or rettype == "ERROR": getattr(kernels, name).restype = None tmp = numba.typing.ctypes_utils.make_function_type(getattr(kernels, name)) getattr(kernels, name).numbatpe = numba.types.functions.ExternalFunctionPointer(Error.numbatpe(*tmp.sig.args), tmp.get_pointer, cconv=tmp.cconv) diff --git a/awkward1/_numba/util.py b/awkward1/_numba/util.py index c11852b1cc..12e73cc5ed 100644 --- a/awkward1/_numba/util.py +++ b/awkward1/_numba/util.py @@ -13,17 +13,23 @@ RefType = numba.int64 index8tpe = numba.types.Array(numba.int8, 1, "C") +indexU8tpe = numba.types.Array(numba.uint8, 1, "C") index32tpe = numba.types.Array(numba.int32, 1, "C") +indexU32tpe = numba.types.Array(numba.uint32, 1, "C") index64tpe = numba.types.Array(numba.int64, 1, "C") -def indextpe(bitwidth): - if bitwidth == 8: - return index8tpe - elif bitwidth == 32: - return index32tpe - elif bitwidth == 64: +def indextpe(indexname): + if indexname == "64": return index64tpe + elif indexname == "32": + return index32tpe + elif indexname == "U32": + return indexU32tpe + elif indexname == "8": + return index8tpe + elif indexname == "U8": + return indexU8tpe else: - raise AssertionError(bitwidth) + raise AssertionError("unrecognized index type: {}".format(indexname)) if not py27: exec(""" @@ -92,19 +98,27 @@ def call(context, builder, fcn, args, errormessage=None): def newindex8(context, builder, lentpe, lenval): return numba.targets.arrayobj.numpy_empty_nd(context, builder, index8tpe(lentpe), (lenval,)) +def newindexU8(context, builder, lentpe, lenval): + return numba.targets.arrayobj.numpy_empty_nd(context, builder, indexU8tpe(lentpe), (lenval,)) def newindex32(context, builder, lentpe, lenval): return numba.targets.arrayobj.numpy_empty_nd(context, builder, index32tpe(lentpe), (lenval,)) +def newindexU32(context, builder, lentpe, lenval): + return numba.targets.arrayobj.numpy_empty_nd(context, builder, indexU32tpe(lentpe), (lenval,)) def newindex64(context, builder, lentpe, lenval): return numba.targets.arrayobj.numpy_empty_nd(context, builder, index64tpe(lentpe), (lenval,)) -def newindex(bitwidth, context, builder, lentpe, lenval): - if bitwidth == 8: - return newindex8(context, builder, lentpe, lenval) - elif bitwidth == 32: - return newindex32(context, builder, lentpe, lenval) - elif bitwidth == 64: +def newindex(indexname, context, builder, lentpe, lenval): + if indexname == "64": return newindex64(context, builder, lentpe, lenval) + elif indexname == "32": + return newindex32(context, builder, lentpe, lenval) + elif indexname == "U32": + return newindexU32(context, builder, lentpe, lenval) + elif indexname == "8": + return newindex8(context, builder, lentpe, lenval) + elif indexname == "U8": + return newindexU8(context, builder, lentpe, lenval) else: - raise AssertionError(bitwidth) + raise AssertionError("unrecognized index type: {}".format(indexname)) @numba.jit(nopython=True) def shapeat(shapeat, array, at, ndim): diff --git a/awkward1/signatures/ListOffsetArray_8cpp.xml b/awkward1/signatures/ListOffsetArray_8cpp.xml index 865e812ee9..ddf87c5c4b 100644 --- a/awkward1/signatures/ListOffsetArray_8cpp.xml +++ b/awkward1/signatures/ListOffsetArray_8cpp.xml @@ -72,7 +72,7 @@ - + @@ -94,7 +94,7 @@ - + diff --git a/awkward1/signatures/NumpyArray_8cpp.xml b/awkward1/signatures/NumpyArray_8cpp.xml index b291b6cf56..308a9755f2 100644 --- a/awkward1/signatures/NumpyArray_8cpp.xml +++ b/awkward1/signatures/NumpyArray_8cpp.xml @@ -74,7 +74,92 @@ - + + + + void + void awkward::tojson_boolean + (ToJson &builder, bool *array, int64_t length) + tojson_boolean + + ToJson & + builder + + + bool * + array + + + int64_t + length + + + + + + + + + + + + + typename T + + + void + void awkward::tojson_integer + (ToJson &builder, T *array, int64_t length) + tojson_integer + + ToJson & + builder + + + T * + array + + + int64_t + length + + + + + + + + + + + + + typename T + + + void + void awkward::tojson_real + (ToJson &builder, T *array, int64_t length) + tojson_real + + ToJson & + builder + + + T * + array + + + int64_t + length + + + + + + + + const std::vector< ssize_t > @@ -91,7 +176,7 @@ - + const std::vector< ssize_t > @@ -108,7 +193,7 @@ - + diff --git a/awkward1/signatures/cpu-kernels_2util_8cpp.xml b/awkward1/signatures/cpu-kernels_2util_8cpp.xml index 6ed44e0983..ee1767ce62 100644 --- a/awkward1/signatures/cpu-kernels_2util_8cpp.xml +++ b/awkward1/signatures/cpu-kernels_2util_8cpp.xml @@ -21,9 +21,9 @@ - - Error - Error success + + struct Error + struct Error success () success @@ -32,11 +32,11 @@ - + - - Error - Error failure + + struct Error + struct Error failure (const char *str, int64_t location, int64_t attempt) failure @@ -57,7 +57,7 @@ - + diff --git a/awkward1/signatures/getitem_8cpp.xml b/awkward1/signatures/getitem_8cpp.xml index 34ea78f08e..1932861a39 100644 --- a/awkward1/signatures/getitem_8cpp.xml +++ b/awkward1/signatures/getitem_8cpp.xml @@ -58,14 +58,14 @@ - + typename T - Error - Error awkward_regularize_arrayslice + ERROR + ERROR awkward_regularize_arrayslice (T *flatheadptr, int64_t lenflathead, int64_t length) awkward_regularize_arrayslice @@ -88,9 +88,9 @@ - - Error - Error awkward_regularize_arrayslice_64 + + ERROR + ERROR awkward_regularize_arrayslice_64 (int64_t *flatheadptr, int64_t lenflathead, int64_t length) awkward_regularize_arrayslice_64 @@ -113,14 +113,14 @@ - + typename T - Error - Error awkward_slicearray_ravel + ERROR + ERROR awkward_slicearray_ravel (T *toptr, const T *fromptr, int64_t ndim, const int64_t *shape, const int64_t *strides) awkward_slicearray_ravel @@ -151,9 +151,9 @@ - - Error - Error awkward_slicearray_ravel_64 + + ERROR + ERROR awkward_slicearray_ravel_64 (int64_t *toptr, const int64_t *fromptr, int64_t ndim, const int64_t *shape, const int64_t *strides) awkward_slicearray_ravel_64 @@ -184,14 +184,14 @@ - + typename T - Error - Error awkward_carry_arange + ERROR + ERROR awkward_carry_arange (T *toptr, int64_t length) awkward_carry_arange @@ -210,9 +210,9 @@ - - Error - Error awkward_carry_arange_64 + + ERROR + ERROR awkward_carry_arange_64 (int64_t *toptr, int64_t length) awkward_carry_arange_64 @@ -231,7 +231,7 @@ - + typename ID @@ -240,8 +240,8 @@ typename T - Error - Error awkward_identity_getitem_carry + ERROR + ERROR awkward_identity_getitem_carry (ID *newidentityptr, const ID *identityptr, const T *carryptr, int64_t lencarry, int64_t offset, int64_t width, int64_t length) awkward_identity_getitem_carry @@ -280,9 +280,9 @@ - - Error - Error awkward_identity32_getitem_carry_64 + + ERROR + ERROR awkward_identity32_getitem_carry_64 (int32_t *newidentityptr, const int32_t *identityptr, const int64_t *carryptr, int64_t lencarry, int64_t offset, int64_t width, int64_t length) awkward_identity32_getitem_carry_64 @@ -321,9 +321,9 @@ - - Error - Error awkward_identity64_getitem_carry_64 + + ERROR + ERROR awkward_identity64_getitem_carry_64 (int64_t *newidentityptr, const int64_t *identityptr, const int64_t *carryptr, int64_t lencarry, int64_t offset, int64_t width, int64_t length) awkward_identity64_getitem_carry_64 @@ -362,14 +362,14 @@ - + typename T - Error - Error awkward_numpyarray_contiguous_init + ERROR + ERROR awkward_numpyarray_contiguous_init (T *toptr, int64_t skip, int64_t stride) awkward_numpyarray_contiguous_init @@ -392,9 +392,9 @@ - - Error - Error awkward_numpyarray_contiguous_init_64 + + ERROR + ERROR awkward_numpyarray_contiguous_init_64 (int64_t *toptr, int64_t skip, int64_t stride) awkward_numpyarray_contiguous_init_64 @@ -417,14 +417,14 @@ - + typename T - Error - Error awkward_numpyarray_contiguous_copy + ERROR + ERROR awkward_numpyarray_contiguous_copy (uint8_t *toptr, const uint8_t *fromptr, int64_t len, int64_t stride, int64_t offset, const T *pos) awkward_numpyarray_contiguous_copy @@ -459,9 +459,9 @@ - - Error - Error awkward_numpyarray_contiguous_copy_64 + + ERROR + ERROR awkward_numpyarray_contiguous_copy_64 (uint8_t *toptr, const uint8_t *fromptr, int64_t len, int64_t stride, int64_t offset, const int64_t *pos) awkward_numpyarray_contiguous_copy_64 @@ -496,14 +496,14 @@ - + typename T - Error - Error awkward_numpyarray_contiguous_next + ERROR + ERROR awkward_numpyarray_contiguous_next (T *topos, const T *frompos, int64_t len, int64_t skip, int64_t stride) awkward_numpyarray_contiguous_next @@ -534,9 +534,9 @@ - - Error - Error awkward_numpyarray_contiguous_next_64 + + ERROR + ERROR awkward_numpyarray_contiguous_next_64 (int64_t *topos, const int64_t *frompos, int64_t len, int64_t skip, int64_t stride) awkward_numpyarray_contiguous_next_64 @@ -567,14 +567,14 @@ - + typename T - Error - Error awkward_numpyarray_getitem_next_null + ERROR + ERROR awkward_numpyarray_getitem_next_null (uint8_t *toptr, const uint8_t *fromptr, int64_t len, int64_t stride, int64_t offset, const T *pos) awkward_numpyarray_getitem_next_null @@ -609,9 +609,9 @@ - - Error - Error awkward_numpyarray_getitem_next_null_64 + + ERROR + ERROR awkward_numpyarray_getitem_next_null_64 (uint8_t *toptr, const uint8_t *fromptr, int64_t len, int64_t stride, int64_t offset, const int64_t *pos) awkward_numpyarray_getitem_next_null_64 @@ -646,14 +646,14 @@ - + typename T - Error - Error awkward_numpyarray_getitem_next_at + ERROR + ERROR awkward_numpyarray_getitem_next_at (T *nextcarryptr, const T *carryptr, int64_t lencarry, int64_t skip, int64_t at) awkward_numpyarray_getitem_next_at @@ -684,9 +684,9 @@ - - Error - Error awkward_numpyarray_getitem_next_at_64 + + ERROR + ERROR awkward_numpyarray_getitem_next_at_64 (int64_t *nextcarryptr, const int64_t *carryptr, int64_t lencarry, int64_t skip, int64_t at) awkward_numpyarray_getitem_next_at_64 @@ -717,14 +717,14 @@ - + typename T - Error - Error awkward_numpyarray_getitem_next_range + ERROR + ERROR awkward_numpyarray_getitem_next_range (T *nextcarryptr, const T *carryptr, int64_t lencarry, int64_t lenhead, int64_t skip, int64_t start, int64_t step) awkward_numpyarray_getitem_next_range @@ -763,9 +763,9 @@ - - Error - Error awkward_numpyarray_getitem_next_range_64 + + ERROR + ERROR awkward_numpyarray_getitem_next_range_64 (int64_t *nextcarryptr, const int64_t *carryptr, int64_t lencarry, int64_t lenhead, int64_t skip, int64_t start, int64_t step) awkward_numpyarray_getitem_next_range_64 @@ -804,14 +804,14 @@ - + typename T - Error - Error awkward_numpyarray_getitem_next_range_advanced + ERROR + ERROR awkward_numpyarray_getitem_next_range_advanced (T *nextcarryptr, T *nextadvancedptr, const T *carryptr, const T *advancedptr, int64_t lencarry, int64_t lenhead, int64_t skip, int64_t start, int64_t step) awkward_numpyarray_getitem_next_range_advanced @@ -858,9 +858,9 @@ - - Error - Error awkward_numpyarray_getitem_next_range_advanced_64 + + ERROR + ERROR awkward_numpyarray_getitem_next_range_advanced_64 (int64_t *nextcarryptr, int64_t *nextadvancedptr, const int64_t *carryptr, const int64_t *advancedptr, int64_t lencarry, int64_t lenhead, int64_t skip, int64_t start, int64_t step) awkward_numpyarray_getitem_next_range_advanced_64 @@ -907,14 +907,14 @@ - + typename T - Error - Error awkward_numpyarray_getitem_next_array + ERROR + ERROR awkward_numpyarray_getitem_next_array (T *nextcarryptr, T *nextadvancedptr, const T *carryptr, const T *flatheadptr, int64_t lencarry, int64_t lenflathead, int64_t skip) awkward_numpyarray_getitem_next_array @@ -953,9 +953,9 @@ - - Error - Error awkward_numpyarray_getitem_next_array_64 + + ERROR + ERROR awkward_numpyarray_getitem_next_array_64 (int64_t *nextcarryptr, int64_t *nextadvancedptr, const int64_t *carryptr, const int64_t *flatheadptr, int64_t lencarry, int64_t lenflathead, int64_t skip) awkward_numpyarray_getitem_next_array_64 @@ -994,14 +994,14 @@ - + typename T - Error - Error awkward_numpyarray_getitem_next_array_advanced + ERROR + ERROR awkward_numpyarray_getitem_next_array_advanced (T *nextcarryptr, const T *carryptr, const T *advancedptr, const T *flatheadptr, int64_t lencarry, int64_t skip) awkward_numpyarray_getitem_next_array_advanced @@ -1036,9 +1036,9 @@ - - Error - Error awkward_numpyarray_getitem_next_array_advanced_64 + + ERROR + ERROR awkward_numpyarray_getitem_next_array_advanced_64 (int64_t *nextcarryptr, const int64_t *carryptr, const int64_t *advancedptr, const int64_t *flatheadptr, int64_t lencarry, int64_t skip) awkward_numpyarray_getitem_next_array_advanced_64 @@ -1073,7 +1073,7 @@ - + typename C @@ -1082,8 +1082,8 @@ typename T - Error - Error awkward_listarray_getitem_next_at + ERROR + ERROR awkward_listarray_getitem_next_at (T *tocarry, const C *fromstarts, const C *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at) awkward_listarray_getitem_next_at @@ -1122,9 +1122,9 @@ - - Error - Error awkward_listarray32_getitem_next_at_64 + + ERROR + ERROR awkward_listarray32_getitem_next_at_64 (int64_t *tocarry, const int32_t *fromstarts, const int32_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at) awkward_listarray32_getitem_next_at_64 @@ -1163,9 +1163,50 @@ - - Error - Error awkward_listarray64_getitem_next_at_64 + + ERROR + ERROR awkward_listarrayU32_getitem_next_at_64 + (int64_t *tocarry, const uint32_t *fromstarts, const uint32_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at) + awkward_listarrayU32_getitem_next_at_64 + + int64_t * + tocarry + + + const uint32_t * + fromstarts + + + const uint32_t * + fromstops + + + int64_t + lenstarts + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + at + + + + + + + + + + + ERROR + ERROR awkward_listarray64_getitem_next_at_64 (int64_t *tocarry, const int64_t *fromstarts, const int64_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at) awkward_listarray64_getitem_next_at_64 @@ -1202,16 +1243,16 @@ - + - + typename C - Error - Error awkward_listarray_getitem_next_range_carrylength + ERROR + ERROR awkward_listarray_getitem_next_range_carrylength (int64_t *carrylength, const C *fromstarts, const C *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) awkward_listarray_getitem_next_range_carrylength @@ -1256,11 +1297,11 @@ - + - - Error - Error awkward_listarray32_getitem_next_range_carrylength + + ERROR + ERROR awkward_listarray32_getitem_next_range_carrylength (int64_t *carrylength, const int32_t *fromstarts, const int32_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) awkward_listarray32_getitem_next_range_carrylength @@ -1305,11 +1346,60 @@ - + - - Error - Error awkward_listarray64_getitem_next_range_carrylength + + ERROR + ERROR awkward_listarrayU32_getitem_next_range_carrylength + (int64_t *carrylength, const uint32_t *fromstarts, const uint32_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) + awkward_listarrayU32_getitem_next_range_carrylength + + int64_t * + carrylength + + + const uint32_t * + fromstarts + + + const uint32_t * + fromstops + + + int64_t + lenstarts + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + start + + + int64_t + stop + + + int64_t + step + + + + + + + + + + + ERROR + ERROR awkward_listarray64_getitem_next_range_carrylength (int64_t *carrylength, const int64_t *fromstarts, const int64_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) awkward_listarray64_getitem_next_range_carrylength @@ -1354,9 +1444,9 @@ - + - + typename C @@ -1365,8 +1455,8 @@ typename T - Error - Error awkward_listarray_getitem_next_range + ERROR + ERROR awkward_listarray_getitem_next_range (C *tooffsets, T *tocarry, const C *fromstarts, const C *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) awkward_listarray_getitem_next_range @@ -1415,11 +1505,11 @@ - + - - Error - Error awkward_listarray32_getitem_next_range_64 + + ERROR + ERROR awkward_listarray32_getitem_next_range_64 (int32_t *tooffsets, int64_t *tocarry, const int32_t *fromstarts, const int32_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) awkward_listarray32_getitem_next_range_64 @@ -1468,11 +1558,64 @@ - + - - Error - Error awkward_listarray64_getitem_next_range_64 + + ERROR + ERROR awkward_listarrayU32_getitem_next_range_64 + (uint32_t *tooffsets, int64_t *tocarry, const uint32_t *fromstarts, const uint32_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) + awkward_listarrayU32_getitem_next_range_64 + + uint32_t * + tooffsets + + + int64_t * + tocarry + + + const uint32_t * + fromstarts + + + const uint32_t * + fromstops + + + int64_t + lenstarts + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + start + + + int64_t + stop + + + int64_t + step + + + + + + + + + + + ERROR + ERROR awkward_listarray64_getitem_next_range_64 (int64_t *tooffsets, int64_t *tocarry, const int64_t *fromstarts, const int64_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) awkward_listarray64_getitem_next_range_64 @@ -1521,9 +1664,9 @@ - + - + typename C @@ -1532,8 +1675,8 @@ typename T - Error - Error awkward_listarray_getitem_next_range_counts + ERROR + ERROR awkward_listarray_getitem_next_range_counts (int64_t *total, const C *fromoffsets, int64_t lenstarts) awkward_listarray_getitem_next_range_counts @@ -1554,11 +1697,11 @@ - + - - Error - Error awkward_listarray32_getitem_next_range_counts_64 + + ERROR + ERROR awkward_listarray32_getitem_next_range_counts_64 (int64_t *total, const int32_t *fromoffsets, int64_t lenstarts) awkward_listarray32_getitem_next_range_counts_64 @@ -1579,11 +1722,36 @@ - + - - Error - Error awkward_listarray64_getitem_next_range_counts_64 + + ERROR + ERROR awkward_listarrayU32_getitem_next_range_counts_64 + (int64_t *total, const uint32_t *fromoffsets, int64_t lenstarts) + awkward_listarrayU32_getitem_next_range_counts_64 + + int64_t * + total + + + const uint32_t * + fromoffsets + + + int64_t + lenstarts + + + + + + + + + + + ERROR + ERROR awkward_listarray64_getitem_next_range_counts_64 (int64_t *total, const int64_t *fromoffsets, int64_t lenstarts) awkward_listarray64_getitem_next_range_counts_64 @@ -1604,9 +1772,9 @@ - + - + typename C @@ -1615,8 +1783,8 @@ typename T - Error - Error awkward_listarray_getitem_next_range_spreadadvanced + ERROR + ERROR awkward_listarray_getitem_next_range_spreadadvanced (T *toadvanced, const T *fromadvanced, const C *fromoffsets, int64_t lenstarts) awkward_listarray_getitem_next_range_spreadadvanced @@ -1641,11 +1809,11 @@ - + - - Error - Error awkward_listarray32_getitem_next_range_spreadadvanced_64 + + ERROR + ERROR awkward_listarray32_getitem_next_range_spreadadvanced_64 (int64_t *toadvanced, const int64_t *fromadvanced, const int32_t *fromoffsets, int64_t lenstarts) awkward_listarray32_getitem_next_range_spreadadvanced_64 @@ -1670,11 +1838,40 @@ - + + + + ERROR + ERROR awkward_listarrayU32_getitem_next_range_spreadadvanced_64 + (int64_t *toadvanced, const int64_t *fromadvanced, const uint32_t *fromoffsets, int64_t lenstarts) + awkward_listarrayU32_getitem_next_range_spreadadvanced_64 + + int64_t * + toadvanced + + + const int64_t * + fromadvanced + + + const uint32_t * + fromoffsets + + + int64_t + lenstarts + + + + + + + + - - Error - Error awkward_listarray64_getitem_next_range_spreadadvanced_64 + + ERROR + ERROR awkward_listarray64_getitem_next_range_spreadadvanced_64 (int64_t *toadvanced, const int64_t *fromadvanced, const int64_t *fromoffsets, int64_t lenstarts) awkward_listarray64_getitem_next_range_spreadadvanced_64 @@ -1699,9 +1896,9 @@ - + - + typename C @@ -1710,8 +1907,8 @@ typename T - Error - Error awkward_listarray_getitem_next_array + ERROR + ERROR awkward_listarray_getitem_next_array (C *tooffsets, T *tocarry, T *toadvanced, const C *fromstarts, const C *fromstops, const T *fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) awkward_listarray_getitem_next_array @@ -1764,11 +1961,11 @@ - + - - Error - Error awkward_listarray32_getitem_next_array_64 + + ERROR + ERROR awkward_listarray32_getitem_next_array_64 (int32_t *tooffsets, int64_t *tocarry, int64_t *toadvanced, const int32_t *fromstarts, const int32_t *fromstops, const int64_t *fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) awkward_listarray32_getitem_next_array_64 @@ -1821,11 +2018,68 @@ - + + + + ERROR + ERROR awkward_listarrayU32_getitem_next_array_64 + (uint32_t *tooffsets, int64_t *tocarry, int64_t *toadvanced, const uint32_t *fromstarts, const uint32_t *fromstops, const int64_t *fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) + awkward_listarrayU32_getitem_next_array_64 + + uint32_t * + tooffsets + + + int64_t * + tocarry + + + int64_t * + toadvanced + + + const uint32_t * + fromstarts + + + const uint32_t * + fromstops + + + const int64_t * + fromarray + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + lenstarts + + + int64_t + lenarray + + + int64_t + lencontent + + + + + + + + - - Error - Error awkward_listarray64_getitem_next_array_64 + + ERROR + ERROR awkward_listarray64_getitem_next_array_64 (int64_t *tooffsets, int64_t *tocarry, int64_t *toadvanced, const int64_t *fromstarts, const int64_t *fromstops, const int64_t *fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) awkward_listarray64_getitem_next_array_64 @@ -1878,9 +2132,9 @@ - + - + typename C @@ -1889,8 +2143,8 @@ typename T - Error - Error awkward_listarray_getitem_next_array_advanced + ERROR + ERROR awkward_listarray_getitem_next_array_advanced (T *tocarry, T *toadvanced, const C *fromstarts, const C *fromstops, const T *fromarray, const T *fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) awkward_listarray_getitem_next_array_advanced @@ -1943,11 +2197,11 @@ - + - - Error - Error awkward_listarray32_getitem_next_array_advanced_64 + + ERROR + ERROR awkward_listarray32_getitem_next_array_advanced_64 (int64_t *tocarry, int64_t *toadvanced, const int32_t *fromstarts, const int32_t *fromstops, const int64_t *fromarray, const int64_t *fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) awkward_listarray32_getitem_next_array_advanced_64 @@ -2000,11 +2254,68 @@ - + - - Error - Error awkward_listarray64_getitem_next_array_advanced_64 + + ERROR + ERROR awkward_listarrayU32_getitem_next_array_advanced_64 + (int64_t *tocarry, int64_t *toadvanced, const uint32_t *fromstarts, const uint32_t *fromstops, const int64_t *fromarray, const int64_t *fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) + awkward_listarrayU32_getitem_next_array_advanced_64 + + int64_t * + tocarry + + + int64_t * + toadvanced + + + const uint32_t * + fromstarts + + + const uint32_t * + fromstops + + + const int64_t * + fromarray + + + const int64_t * + fromadvanced + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + lenstarts + + + int64_t + lenarray + + + int64_t + lencontent + + + + + + + + + + + ERROR + ERROR awkward_listarray64_getitem_next_array_advanced_64 (int64_t *tocarry, int64_t *toadvanced, const int64_t *fromstarts, const int64_t *fromstops, const int64_t *fromarray, const int64_t *fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) awkward_listarray64_getitem_next_array_advanced_64 @@ -2057,9 +2368,9 @@ - + - + typename C @@ -2068,8 +2379,8 @@ typename T - Error - Error awkward_listarray_getitem_carry + ERROR + ERROR awkward_listarray_getitem_carry (C *tostarts, C *tostops, const C *fromstarts, const C *fromstops, const T *fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry) awkward_listarray_getitem_carry @@ -2114,11 +2425,11 @@ - + - - Error - Error awkward_listarray32_getitem_carry_64 + + ERROR + ERROR awkward_listarray32_getitem_carry_64 (int32_t *tostarts, int32_t *tostops, const int32_t *fromstarts, const int32_t *fromstops, const int64_t *fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry) awkward_listarray32_getitem_carry_64 @@ -2163,11 +2474,60 @@ - + - - Error - Error awkward_listarray64_getitem_carry_64 + + ERROR + ERROR awkward_listarrayU32_getitem_carry_64 + (uint32_t *tostarts, uint32_t *tostops, const uint32_t *fromstarts, const uint32_t *fromstops, const int64_t *fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry) + awkward_listarrayU32_getitem_carry_64 + + uint32_t * + tostarts + + + uint32_t * + tostops + + + const uint32_t * + fromstarts + + + const uint32_t * + fromstops + + + const int64_t * + fromcarry + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + lenstarts + + + int64_t + lencarry + + + + + + + + + + + ERROR + ERROR awkward_listarray64_getitem_carry_64 (int64_t *tostarts, int64_t *tostops, const int64_t *fromstarts, const int64_t *fromstops, const int64_t *fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry) awkward_listarray64_getitem_carry_64 @@ -2212,7 +2572,7 @@ - + diff --git a/awkward1/signatures/identity_8cpp.xml b/awkward1/signatures/identity_8cpp.xml index a6cf3d5f96..9b068899b2 100644 --- a/awkward1/signatures/identity_8cpp.xml +++ b/awkward1/signatures/identity_8cpp.xml @@ -15,14 +15,14 @@ - + typename T - Error - Error awkward_new_identity + ERROR + ERROR awkward_new_identity (T *toptr, int64_t length) awkward_new_identity @@ -41,9 +41,9 @@ - - Error - Error awkward_new_identity32 + + ERROR + ERROR awkward_new_identity32 (int32_t *toptr, int64_t length) awkward_new_identity32 @@ -62,9 +62,9 @@ - - Error - Error awkward_new_identity64 + + ERROR + ERROR awkward_new_identity64 (int64_t *toptr, int64_t length) awkward_new_identity64 @@ -83,9 +83,9 @@ - - Error - Error awkward_identity32_to_identity64 + + ERROR + ERROR awkward_identity32_to_identity64 (int64_t *toptr, const int32_t *fromptr, int64_t length) awkward_identity32_to_identity64 @@ -108,7 +108,7 @@ - + typename ID @@ -117,8 +117,8 @@ typename T - Error - Error awkward_identity_from_listarray + ERROR + ERROR awkward_identity_from_listarray (ID *toptr, const ID *fromptr, const T *fromstarts, const T *fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth) awkward_identity_from_listarray @@ -169,9 +169,9 @@ - - Error - Error awkward_identity32_from_listarray32 + + ERROR + ERROR awkward_identity32_from_listarray32 (int32_t *toptr, const int32_t *fromptr, const int32_t *fromstarts, const int32_t *fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth) awkward_identity32_from_listarray32 @@ -222,9 +222,9 @@ - - Error - Error awkward_identity64_from_listarray32 + + ERROR + ERROR awkward_identity64_from_listarray32 (int64_t *toptr, const int64_t *fromptr, const int32_t *fromstarts, const int32_t *fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth) awkward_identity64_from_listarray32 @@ -275,9 +275,62 @@ - - Error - Error awkward_identity64_from_listarray64 + + ERROR + ERROR awkward_identity64_from_listarrayU32 + (int64_t *toptr, const int64_t *fromptr, const uint32_t *fromstarts, const uint32_t *fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth) + awkward_identity64_from_listarrayU32 + + int64_t * + toptr + + + const int64_t * + fromptr + + + const uint32_t * + fromstarts + + + const uint32_t * + fromstops + + + int64_t + fromptroffset + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + tolength + + + int64_t + fromlength + + + int64_t + fromwidth + + + + + + + + + + + ERROR + ERROR awkward_identity64_from_listarray64 (int64_t *toptr, const int64_t *fromptr, const int64_t *fromstarts, const int64_t *fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth) awkward_identity64_from_listarray64 @@ -326,7 +379,7 @@ - + diff --git a/awkward1/signatures/libawkward_2util_8cpp.xml b/awkward1/signatures/libawkward_2util_8cpp.xml index 08ce2c20bb..f917759b77 100644 --- a/awkward1/signatures/libawkward_2util_8cpp.xml +++ b/awkward1/signatures/libawkward_2util_8cpp.xml @@ -4,6 +4,8 @@ util.cpp cassert sstream + awkward/cpu-kernels/identity.h + awkward/cpu-kernels/getitem.h awkward/util.h awkward/Identity.h @@ -18,14 +20,24 @@ + + + + - + + + + + + + @@ -35,13 +47,13 @@ awkward awkward::util - + void void awkward::util::handle_error - (const Error &err, const std::string classname, const Identity *id) + (const struct Error &err, const std::string classname, const Identity *id) handle_error - const Error & + const struct Error & err @@ -58,7 +70,1245 @@ - + + + + + + Error + Error awkward::util::awkward_identity64_from_listarray< uint32_t > + (int64_t *toptr, const int64_t *fromptr, const uint32_t *fromstarts, const uint32_t *fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth) + awkward_identity64_from_listarray< uint32_t > + + int64_t * + toptr + + + const int64_t * + fromptr + + + const uint32_t * + fromstarts + + + const uint32_t * + fromstops + + + int64_t + fromptroffset + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + tolength + + + int64_t + fromlength + + + int64_t + fromwidth + + + + + + + + + + + + + Error + Error awkward::util::awkward_identity64_from_listarray< int64_t > + (int64_t *toptr, const int64_t *fromptr, const int64_t *fromstarts, const int64_t *fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth) + awkward_identity64_from_listarray< int64_t > + + int64_t * + toptr + + + const int64_t * + fromptr + + + const int64_t * + fromstarts + + + const int64_t * + fromstops + + + int64_t + fromptroffset + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + tolength + + + int64_t + fromlength + + + int64_t + fromwidth + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_at_64< int32_t > + (int64_t *tocarry, const int32_t *fromstarts, const int32_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at) + awkward_listarray_getitem_next_at_64< int32_t > + + int64_t * + tocarry + + + const int32_t * + fromstarts + + + const int32_t * + fromstops + + + int64_t + lenstarts + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + at + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_at_64< uint32_t > + (int64_t *tocarry, const uint32_t *fromstarts, const uint32_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at) + awkward_listarray_getitem_next_at_64< uint32_t > + + int64_t * + tocarry + + + const uint32_t * + fromstarts + + + const uint32_t * + fromstops + + + int64_t + lenstarts + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + at + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_at_64< int64_t > + (int64_t *tocarry, const int64_t *fromstarts, const int64_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at) + awkward_listarray_getitem_next_at_64< int64_t > + + int64_t * + tocarry + + + const int64_t * + fromstarts + + + const int64_t * + fromstops + + + int64_t + lenstarts + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + at + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_range_carrylength< int32_t > + (int64_t *carrylength, const int32_t *fromstarts, const int32_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) + awkward_listarray_getitem_next_range_carrylength< int32_t > + + int64_t * + carrylength + + + const int32_t * + fromstarts + + + const int32_t * + fromstops + + + int64_t + lenstarts + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + start + + + int64_t + stop + + + int64_t + step + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_range_carrylength< uint32_t > + (int64_t *carrylength, const uint32_t *fromstarts, const uint32_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) + awkward_listarray_getitem_next_range_carrylength< uint32_t > + + int64_t * + carrylength + + + const uint32_t * + fromstarts + + + const uint32_t * + fromstops + + + int64_t + lenstarts + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + start + + + int64_t + stop + + + int64_t + step + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_range_carrylength< int64_t > + (int64_t *carrylength, const int64_t *fromstarts, const int64_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) + awkward_listarray_getitem_next_range_carrylength< int64_t > + + int64_t * + carrylength + + + const int64_t * + fromstarts + + + const int64_t * + fromstops + + + int64_t + lenstarts + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + start + + + int64_t + stop + + + int64_t + step + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_range_64< int32_t > + (int32_t *tooffsets, int64_t *tocarry, const int32_t *fromstarts, const int32_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) + awkward_listarray_getitem_next_range_64< int32_t > + + int32_t * + tooffsets + + + int64_t * + tocarry + + + const int32_t * + fromstarts + + + const int32_t * + fromstops + + + int64_t + lenstarts + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + start + + + int64_t + stop + + + int64_t + step + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_range_64< uint32_t > + (uint32_t *tooffsets, int64_t *tocarry, const uint32_t *fromstarts, const uint32_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) + awkward_listarray_getitem_next_range_64< uint32_t > + + uint32_t * + tooffsets + + + int64_t * + tocarry + + + const uint32_t * + fromstarts + + + const uint32_t * + fromstops + + + int64_t + lenstarts + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + start + + + int64_t + stop + + + int64_t + step + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_range_64< int64_t > + (int64_t *tooffsets, int64_t *tocarry, const int64_t *fromstarts, const int64_t *fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) + awkward_listarray_getitem_next_range_64< int64_t > + + int64_t * + tooffsets + + + int64_t * + tocarry + + + const int64_t * + fromstarts + + + const int64_t * + fromstops + + + int64_t + lenstarts + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + start + + + int64_t + stop + + + int64_t + step + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_range_counts_64< int32_t > + (int64_t *total, const int32_t *fromoffsets, int64_t lenstarts) + awkward_listarray_getitem_next_range_counts_64< int32_t > + + int64_t * + total + + + const int32_t * + fromoffsets + + + int64_t + lenstarts + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_range_counts_64< uint32_t > + (int64_t *total, const uint32_t *fromoffsets, int64_t lenstarts) + awkward_listarray_getitem_next_range_counts_64< uint32_t > + + int64_t * + total + + + const uint32_t * + fromoffsets + + + int64_t + lenstarts + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_range_counts_64< int64_t > + (int64_t *total, const int64_t *fromoffsets, int64_t lenstarts) + awkward_listarray_getitem_next_range_counts_64< int64_t > + + int64_t * + total + + + const int64_t * + fromoffsets + + + int64_t + lenstarts + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_range_spreadadvanced_64< int32_t > + (int64_t *toadvanced, const int64_t *fromadvanced, const int32_t *fromoffsets, int64_t lenstarts) + awkward_listarray_getitem_next_range_spreadadvanced_64< int32_t > + + int64_t * + toadvanced + + + const int64_t * + fromadvanced + + + const int32_t * + fromoffsets + + + int64_t + lenstarts + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_range_spreadadvanced_64< uint32_t > + (int64_t *toadvanced, const int64_t *fromadvanced, const uint32_t *fromoffsets, int64_t lenstarts) + awkward_listarray_getitem_next_range_spreadadvanced_64< uint32_t > + + int64_t * + toadvanced + + + const int64_t * + fromadvanced + + + const uint32_t * + fromoffsets + + + int64_t + lenstarts + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_range_spreadadvanced_64< int64_t > + (int64_t *toadvanced, const int64_t *fromadvanced, const int64_t *fromoffsets, int64_t lenstarts) + awkward_listarray_getitem_next_range_spreadadvanced_64< int64_t > + + int64_t * + toadvanced + + + const int64_t * + fromadvanced + + + const int64_t * + fromoffsets + + + int64_t + lenstarts + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_array_64< int32_t > + (int32_t *tooffsets, int64_t *tocarry, int64_t *toadvanced, const int32_t *fromstarts, const int32_t *fromstops, const int64_t *fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) + awkward_listarray_getitem_next_array_64< int32_t > + + int32_t * + tooffsets + + + int64_t * + tocarry + + + int64_t * + toadvanced + + + const int32_t * + fromstarts + + + const int32_t * + fromstops + + + const int64_t * + fromarray + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + lenstarts + + + int64_t + lenarray + + + int64_t + lencontent + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_array_64< uint32_t > + (uint32_t *tooffsets, int64_t *tocarry, int64_t *toadvanced, const uint32_t *fromstarts, const uint32_t *fromstops, const int64_t *fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) + awkward_listarray_getitem_next_array_64< uint32_t > + + uint32_t * + tooffsets + + + int64_t * + tocarry + + + int64_t * + toadvanced + + + const uint32_t * + fromstarts + + + const uint32_t * + fromstops + + + const int64_t * + fromarray + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + lenstarts + + + int64_t + lenarray + + + int64_t + lencontent + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_array_64< int64_t > + (int64_t *tooffsets, int64_t *tocarry, int64_t *toadvanced, const int64_t *fromstarts, const int64_t *fromstops, const int64_t *fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) + awkward_listarray_getitem_next_array_64< int64_t > + + int64_t * + tooffsets + + + int64_t * + tocarry + + + int64_t * + toadvanced + + + const int64_t * + fromstarts + + + const int64_t * + fromstops + + + const int64_t * + fromarray + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + lenstarts + + + int64_t + lenarray + + + int64_t + lencontent + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_array_advanced_64< int32_t > + (int64_t *tocarry, int64_t *toadvanced, const int32_t *fromstarts, const int32_t *fromstops, const int64_t *fromarray, const int64_t *fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) + awkward_listarray_getitem_next_array_advanced_64< int32_t > + + int64_t * + tocarry + + + int64_t * + toadvanced + + + const int32_t * + fromstarts + + + const int32_t * + fromstops + + + const int64_t * + fromarray + + + const int64_t * + fromadvanced + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + lenstarts + + + int64_t + lenarray + + + int64_t + lencontent + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_array_advanced_64< uint32_t > + (int64_t *tocarry, int64_t *toadvanced, const uint32_t *fromstarts, const uint32_t *fromstops, const int64_t *fromarray, const int64_t *fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) + awkward_listarray_getitem_next_array_advanced_64< uint32_t > + + int64_t * + tocarry + + + int64_t * + toadvanced + + + const uint32_t * + fromstarts + + + const uint32_t * + fromstops + + + const int64_t * + fromarray + + + const int64_t * + fromadvanced + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + lenstarts + + + int64_t + lenarray + + + int64_t + lencontent + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_next_array_advanced_64< int64_t > + (int64_t *tocarry, int64_t *toadvanced, const int64_t *fromstarts, const int64_t *fromstops, const int64_t *fromarray, const int64_t *fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) + awkward_listarray_getitem_next_array_advanced_64< int64_t > + + int64_t * + tocarry + + + int64_t * + toadvanced + + + const int64_t * + fromstarts + + + const int64_t * + fromstops + + + const int64_t * + fromarray + + + const int64_t * + fromadvanced + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + lenstarts + + + int64_t + lenarray + + + int64_t + lencontent + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_carry_64< int32_t > + (int32_t *tostarts, int32_t *tostops, const int32_t *fromstarts, const int32_t *fromstops, const int64_t *fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry) + awkward_listarray_getitem_carry_64< int32_t > + + int32_t * + tostarts + + + int32_t * + tostops + + + const int32_t * + fromstarts + + + const int32_t * + fromstops + + + const int64_t * + fromcarry + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + lenstarts + + + int64_t + lencarry + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_carry_64< uint32_t > + (uint32_t *tostarts, uint32_t *tostops, const uint32_t *fromstarts, const uint32_t *fromstops, const int64_t *fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry) + awkward_listarray_getitem_carry_64< uint32_t > + + uint32_t * + tostarts + + + uint32_t * + tostops + + + const uint32_t * + fromstarts + + + const uint32_t * + fromstops + + + const int64_t * + fromcarry + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + lenstarts + + + int64_t + lencarry + + + + + + + + + + + + + Error + Error awkward::util::awkward_listarray_getitem_carry_64< int64_t > + (int64_t *tostarts, int64_t *tostops, const int64_t *fromstarts, const int64_t *fromstops, const int64_t *fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry) + awkward_listarray_getitem_carry_64< int64_t > + + int64_t * + tostarts + + + int64_t * + tostops + + + const int64_t * + fromstarts + + + const int64_t * + fromstops + + + const int64_t * + fromcarry + + + int64_t + startsoffset + + + int64_t + stopsoffset + + + int64_t + lenstarts + + + int64_t + lencarry + + + + + + + + diff --git a/include/awkward/Index.h b/include/awkward/Index.h index 8b740e84af..9c69e79937 100644 --- a/include/awkward/Index.h +++ b/include/awkward/Index.h @@ -46,9 +46,11 @@ namespace awkward { const int64_t length_; }; - typedef IndexOf Index8; - typedef IndexOf Index32; - typedef IndexOf Index64; + typedef IndexOf Index8; + typedef IndexOf IndexU8; + typedef IndexOf Index32; + typedef IndexOf IndexU32; + typedef IndexOf Index64; } #endif // AWKWARD_INDEX_H_ diff --git a/include/awkward/array/ListArray.h b/include/awkward/array/ListArray.h index b5d9ac92fc..f2cac9a424 100644 --- a/include/awkward/array/ListArray.h +++ b/include/awkward/array/ListArray.h @@ -48,8 +48,9 @@ namespace awkward { const std::shared_ptr content_; }; - typedef ListArrayOf ListArray32; - typedef ListArrayOf ListArray64; + typedef ListArrayOf ListArray32; + typedef ListArrayOf ListArrayU32; + typedef ListArrayOf ListArray64; } #endif // AWKWARD_LISTARRAY_H_ diff --git a/include/awkward/array/ListOffsetArray.h b/include/awkward/array/ListOffsetArray.h index f09b7cf8a6..48037b314f 100644 --- a/include/awkward/array/ListOffsetArray.h +++ b/include/awkward/array/ListOffsetArray.h @@ -45,8 +45,9 @@ namespace awkward { const std::shared_ptr content_; }; - typedef ListOffsetArrayOf ListOffsetArray32; - typedef ListOffsetArrayOf ListOffsetArray64; + typedef ListOffsetArrayOf ListOffsetArray32; + typedef ListOffsetArrayOf ListOffsetArrayU32; + typedef ListOffsetArrayOf ListOffsetArray64; } #endif // AWKWARD_LISTOFFSETARRAY_H_ diff --git a/include/awkward/cpu-kernels/getitem.h b/include/awkward/cpu-kernels/getitem.h index 4f9dcf9ffa..95ed22f232 100644 --- a/include/awkward/cpu-kernels/getitem.h +++ b/include/awkward/cpu-kernels/getitem.h @@ -28,27 +28,35 @@ extern "C" { struct Error awkward_numpyarray_getitem_next_array_advanced_64(int64_t* nextcarryptr, const int64_t* carryptr, const int64_t* advancedptr, const int64_t* flatheadptr, int64_t lencarry, int64_t skip); struct Error awkward_listarray32_getitem_next_at_64(int64_t* tocarry, const int32_t* fromstarts, const int32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at); + struct Error awkward_listarrayU32_getitem_next_at_64(int64_t* tocarry, const uint32_t* fromstarts, const uint32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at); struct Error awkward_listarray64_getitem_next_at_64(int64_t* tocarry, const int64_t* fromstarts, const int64_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at); struct Error awkward_listarray32_getitem_next_range_carrylength(int64_t* carrylength, const int32_t* fromstarts, const int32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step); + struct Error awkward_listarrayU32_getitem_next_range_carrylength(int64_t* carrylength, const uint32_t* fromstarts, const uint32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step); struct Error awkward_listarray64_getitem_next_range_carrylength(int64_t* carrylength, const int64_t* fromstarts, const int64_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step); struct Error awkward_listarray32_getitem_next_range_64(int32_t* tooffsets, int64_t* tocarry, const int32_t* fromstarts, const int32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step); + struct Error awkward_listarrayU32_getitem_next_range_64(uint32_t* tooffsets, int64_t* tocarry, const uint32_t* fromstarts, const uint32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step); struct Error awkward_listarray64_getitem_next_range_64(int64_t* tooffsets, int64_t* tocarry, const int64_t* fromstarts, const int64_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step); struct Error awkward_listarray32_getitem_next_range_counts_64(int64_t* total, const int32_t* fromoffsets, int64_t lenstarts); + struct Error awkward_listarrayU32_getitem_next_range_counts_64(int64_t* total, const uint32_t* fromoffsets, int64_t lenstarts); struct Error awkward_listarray64_getitem_next_range_counts_64(int64_t* total, const int64_t* fromoffsets, int64_t lenstarts); struct Error awkward_listarray32_getitem_next_range_spreadadvanced_64(int64_t* toadvanced, const int64_t* fromadvanced, const int32_t* fromoffsets, int64_t lenstarts); + struct Error awkward_listarrayU32_getitem_next_range_spreadadvanced_64(int64_t* toadvanced, const int64_t* fromadvanced, const uint32_t* fromoffsets, int64_t lenstarts); struct Error awkward_listarray64_getitem_next_range_spreadadvanced_64(int64_t* toadvanced, const int64_t* fromadvanced, const int64_t* fromoffsets, int64_t lenstarts); struct Error awkward_listarray32_getitem_next_array_64(int32_t* tooffsets, int64_t* tocarry, int64_t* toadvanced, const int32_t* fromstarts, const int32_t* fromstops, const int64_t* fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent); + struct Error awkward_listarrayU32_getitem_next_array_64(uint32_t* tooffsets, int64_t* tocarry, int64_t* toadvanced, const uint32_t* fromstarts, const uint32_t* fromstops, const int64_t* fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent); struct Error awkward_listarray64_getitem_next_array_64(int64_t* tooffsets, int64_t* tocarry, int64_t* toadvanced, const int64_t* fromstarts, const int64_t* fromstops, const int64_t* fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent); struct Error awkward_listarray32_getitem_next_array_advanced_64(int64_t* tocarry, int64_t* toadvanced, const int32_t* fromstarts, const int32_t* fromstops, const int64_t* fromarray, const int64_t* fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent); + struct Error awkward_listarrayU32_getitem_next_array_advanced_64(int64_t* tocarry, int64_t* toadvanced, const uint32_t* fromstarts, const uint32_t* fromstops, const int64_t* fromarray, const int64_t* fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent); struct Error awkward_listarray64_getitem_next_array_advanced_64(int64_t* tocarry, int64_t* toadvanced, const int64_t* fromstarts, const int64_t* fromstops, const int64_t* fromarray, const int64_t* fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent); struct Error awkward_listarray32_getitem_carry_64(int32_t* tostarts, int32_t* tostops, const int32_t* fromstarts, const int32_t* fromstops, const int64_t* fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry); + struct Error awkward_listarrayU32_getitem_carry_64(uint32_t* tostarts, uint32_t* tostops, const uint32_t* fromstarts, const uint32_t* fromstops, const int64_t* fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry); struct Error awkward_listarray64_getitem_carry_64(int64_t* tostarts, int64_t* tostops, const int64_t* fromstarts, const int64_t* fromstops, const int64_t* fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry); } diff --git a/include/awkward/cpu-kernels/identity.h b/include/awkward/cpu-kernels/identity.h index c6c8506306..25d9ed0276 100644 --- a/include/awkward/cpu-kernels/identity.h +++ b/include/awkward/cpu-kernels/identity.h @@ -13,6 +13,7 @@ extern "C" { struct Error awkward_identity32_from_listarray32(int32_t* toptr, const int32_t* fromptr, const int32_t* fromstarts, const int32_t* fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth); struct Error awkward_identity64_from_listarray32(int64_t* toptr, const int64_t* fromptr, const int32_t* fromstarts, const int32_t* fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth); + struct Error awkward_identity64_from_listarrayU32(int64_t* toptr, const int64_t* fromptr, const uint32_t* fromstarts, const uint32_t* fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth); struct Error awkward_identity64_from_listarray64(int64_t* toptr, const int64_t* fromptr, const int64_t* fromstarts, const int64_t* fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth); } diff --git a/include/awkward/cpu-kernels/util.h b/include/awkward/cpu-kernels/util.h index efc1cc5d79..33325b001b 100644 --- a/include/awkward/cpu-kernels/util.h +++ b/include/awkward/cpu-kernels/util.h @@ -38,11 +38,12 @@ extern "C" { struct Error success(); struct Error failure(const char* str, int64_t location, int64_t attempt); - const int8_t kMaxInt8 = 127; // 2**7 - 1 - const uint8_t kMaxUInt8 = 255; // 2**8 - 1 - const int32_t kMaxInt32 = 2147483647; // 2**31 - 1 - const int64_t kMaxInt64 = 9223372036854775806; // 2**63 - 2: see below - const int64_t kSliceNone = kMaxInt64 + 1; // reserved for Slice::none() + const int8_t kMaxInt8 = 127; // 2**7 - 1 + const uint8_t kMaxUInt8 = 255; // 2**8 - 1 + const int32_t kMaxInt32 = 2147483647; // 2**31 - 1 + const uint32_t kMaxUInt32 = 4294967295; // 2**32 - 1 + const int64_t kMaxInt64 = 9223372036854775806; // 2**63 - 2: see below + const int64_t kSliceNone = kMaxInt64 + 1; // reserved for Slice::none() } #endif // AWKWARDCPU_UTIL_H_ diff --git a/include/awkward/util.h b/include/awkward/util.h index 03959bb5ba..77030bc032 100644 --- a/include/awkward/util.h +++ b/include/awkward/util.h @@ -26,6 +26,26 @@ namespace awkward { public: void operator()(T const *p) { } }; + + template + Error awkward_identity64_from_listarray(int64_t* toptr, const int64_t* fromptr, const T* fromstarts, const T* fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth); + template + Error awkward_listarray_getitem_next_at_64(int64_t* tocarry, const T* fromstarts, const T* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at); + template + Error awkward_listarray_getitem_next_range_carrylength(int64_t* carrylength, const T* fromstarts, const T* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step); + template + Error awkward_listarray_getitem_next_range_64(T* tooffsets, int64_t* tocarry, const T* fromstarts, const T* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step); + template + Error awkward_listarray_getitem_next_range_counts_64(int64_t* total, const T* fromoffsets, int64_t lenstarts); + template + Error awkward_listarray_getitem_next_range_spreadadvanced_64(int64_t* toadvanced, const int64_t* fromadvanced, const T* fromoffsets, int64_t lenstarts); + template + Error awkward_listarray_getitem_next_array_64(T* tooffsets, int64_t* tocarry, int64_t* toadvanced, const T* fromstarts, const T* fromstops, const int64_t* fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent); + template + Error awkward_listarray_getitem_next_array_advanced_64(int64_t* tocarry, int64_t* toadvanced, const T* fromstarts, const T* fromstops, const int64_t* fromarray, const int64_t* fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent); + template + Error awkward_listarray_getitem_carry_64(T* tostarts, T* tostops, const T* fromstarts, const T* fromstops, const int64_t* fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry); + } } diff --git a/src/cpu-kernels/getitem.cpp b/src/cpu-kernels/getitem.cpp index e33e38665c..0141cb17e2 100644 --- a/src/cpu-kernels/getitem.cpp +++ b/src/cpu-kernels/getitem.cpp @@ -227,6 +227,9 @@ ERROR awkward_listarray_getitem_next_at(T* tocarry, const C* fromstarts, const C ERROR awkward_listarray32_getitem_next_at_64(int64_t* tocarry, const int32_t* fromstarts, const int32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at) { return awkward_listarray_getitem_next_at(tocarry, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, at); } +ERROR awkward_listarrayU32_getitem_next_at_64(int64_t* tocarry, const uint32_t* fromstarts, const uint32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at) { + return awkward_listarray_getitem_next_at(tocarry, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, at); +} ERROR awkward_listarray64_getitem_next_at_64(int64_t* tocarry, const int64_t* fromstarts, const int64_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at) { return awkward_listarray_getitem_next_at(tocarry, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, at); } @@ -255,6 +258,9 @@ ERROR awkward_listarray_getitem_next_range_carrylength(int64_t* carrylength, con ERROR awkward_listarray32_getitem_next_range_carrylength(int64_t* carrylength, const int32_t* fromstarts, const int32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) { return awkward_listarray_getitem_next_range_carrylength(carrylength, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, start, stop, step); } +ERROR awkward_listarrayU32_getitem_next_range_carrylength(int64_t* carrylength, const uint32_t* fromstarts, const uint32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) { + return awkward_listarray_getitem_next_range_carrylength(carrylength, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, start, stop, step); +} ERROR awkward_listarray64_getitem_next_range_carrylength(int64_t* carrylength, const int64_t* fromstarts, const int64_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) { return awkward_listarray_getitem_next_range_carrylength(carrylength, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, start, stop, step); } @@ -287,6 +293,9 @@ ERROR awkward_listarray_getitem_next_range(C* tooffsets, T* tocarry, const C* fr ERROR awkward_listarray32_getitem_next_range_64(int32_t* tooffsets, int64_t* tocarry, const int32_t* fromstarts, const int32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) { return awkward_listarray_getitem_next_range(tooffsets, tocarry, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, start, stop, step); } +ERROR awkward_listarrayU32_getitem_next_range_64(uint32_t* tooffsets, int64_t* tocarry, const uint32_t* fromstarts, const uint32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) { + return awkward_listarray_getitem_next_range(tooffsets, tocarry, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, start, stop, step); +} ERROR awkward_listarray64_getitem_next_range_64(int64_t* tooffsets, int64_t* tocarry, const int64_t* fromstarts, const int64_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) { return awkward_listarray_getitem_next_range(tooffsets, tocarry, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, start, stop, step); } @@ -302,6 +311,9 @@ ERROR awkward_listarray_getitem_next_range_counts(int64_t* total, const C* fromo ERROR awkward_listarray32_getitem_next_range_counts_64(int64_t* total, const int32_t* fromoffsets, int64_t lenstarts) { return awkward_listarray_getitem_next_range_counts(total, fromoffsets, lenstarts); } +ERROR awkward_listarrayU32_getitem_next_range_counts_64(int64_t* total, const uint32_t* fromoffsets, int64_t lenstarts) { + return awkward_listarray_getitem_next_range_counts(total, fromoffsets, lenstarts); +} ERROR awkward_listarray64_getitem_next_range_counts_64(int64_t* total, const int64_t* fromoffsets, int64_t lenstarts) { return awkward_listarray_getitem_next_range_counts(total, fromoffsets, lenstarts); } @@ -319,6 +331,9 @@ ERROR awkward_listarray_getitem_next_range_spreadadvanced(T* toadvanced, const T ERROR awkward_listarray32_getitem_next_range_spreadadvanced_64(int64_t* toadvanced, const int64_t* fromadvanced, const int32_t* fromoffsets, int64_t lenstarts) { return awkward_listarray_getitem_next_range_spreadadvanced(toadvanced, fromadvanced, fromoffsets, lenstarts); } +ERROR awkward_listarrayU32_getitem_next_range_spreadadvanced_64(int64_t* toadvanced, const int64_t* fromadvanced, const uint32_t* fromoffsets, int64_t lenstarts) { + return awkward_listarray_getitem_next_range_spreadadvanced(toadvanced, fromadvanced, fromoffsets, lenstarts); +} ERROR awkward_listarray64_getitem_next_range_spreadadvanced_64(int64_t* toadvanced, const int64_t* fromadvanced, const int64_t* fromoffsets, int64_t lenstarts) { return awkward_listarray_getitem_next_range_spreadadvanced(toadvanced, fromadvanced, fromoffsets, lenstarts); } @@ -352,6 +367,9 @@ ERROR awkward_listarray_getitem_next_array(C* tooffsets, T* tocarry, T* toadvanc ERROR awkward_listarray32_getitem_next_array_64(int32_t* tooffsets, int64_t* tocarry, int64_t* toadvanced, const int32_t* fromstarts, const int32_t* fromstops, const int64_t* fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) { return awkward_listarray_getitem_next_array(tooffsets, tocarry, toadvanced, fromstarts, fromstops, fromarray, startsoffset, stopsoffset, lenstarts, lenarray, lencontent); } +ERROR awkward_listarrayU32_getitem_next_array_64(uint32_t* tooffsets, int64_t* tocarry, int64_t* toadvanced, const uint32_t* fromstarts, const uint32_t* fromstops, const int64_t* fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) { + return awkward_listarray_getitem_next_array(tooffsets, tocarry, toadvanced, fromstarts, fromstops, fromarray, startsoffset, stopsoffset, lenstarts, lenarray, lencontent); +} ERROR awkward_listarray64_getitem_next_array_64(int64_t* tooffsets, int64_t* tocarry, int64_t* toadvanced, const int64_t* fromstarts, const int64_t* fromstops, const int64_t* fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) { return awkward_listarray_getitem_next_array(tooffsets, tocarry, toadvanced, fromstarts, fromstops, fromarray, startsoffset, stopsoffset, lenstarts, lenarray, lencontent); } @@ -384,6 +402,9 @@ ERROR awkward_listarray_getitem_next_array_advanced(T* tocarry, T* toadvanced, c ERROR awkward_listarray32_getitem_next_array_advanced_64(int64_t* tocarry, int64_t* toadvanced, const int32_t* fromstarts, const int32_t* fromstops, const int64_t* fromarray, const int64_t* fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) { return awkward_listarray_getitem_next_array_advanced(tocarry, toadvanced, fromstarts, fromstops, fromarray, fromadvanced, startsoffset, stopsoffset, lenstarts, lenarray, lencontent); } +ERROR awkward_listarrayU32_getitem_next_array_advanced_64(int64_t* tocarry, int64_t* toadvanced, const uint32_t* fromstarts, const uint32_t* fromstops, const int64_t* fromarray, const int64_t* fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) { + return awkward_listarray_getitem_next_array_advanced(tocarry, toadvanced, fromstarts, fromstops, fromarray, fromadvanced, startsoffset, stopsoffset, lenstarts, lenarray, lencontent); +} ERROR awkward_listarray64_getitem_next_array_advanced_64(int64_t* tocarry, int64_t* toadvanced, const int64_t* fromstarts, const int64_t* fromstops, const int64_t* fromarray, const int64_t* fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) { return awkward_listarray_getitem_next_array_advanced(tocarry, toadvanced, fromstarts, fromstops, fromarray, fromadvanced, startsoffset, stopsoffset, lenstarts, lenarray, lencontent); } @@ -402,6 +423,9 @@ ERROR awkward_listarray_getitem_carry(C* tostarts, C* tostops, const C* fromstar ERROR awkward_listarray32_getitem_carry_64(int32_t* tostarts, int32_t* tostops, const int32_t* fromstarts, const int32_t* fromstops, const int64_t* fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry) { return awkward_listarray_getitem_carry(tostarts, tostops, fromstarts, fromstops, fromcarry, startsoffset, stopsoffset, lenstarts, lencarry); } +ERROR awkward_listarrayU32_getitem_carry_64(uint32_t* tostarts, uint32_t* tostops, const uint32_t* fromstarts, const uint32_t* fromstops, const int64_t* fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry) { + return awkward_listarray_getitem_carry(tostarts, tostops, fromstarts, fromstops, fromcarry, startsoffset, stopsoffset, lenstarts, lencarry); +} ERROR awkward_listarray64_getitem_carry_64(int64_t* tostarts, int64_t* tostops, const int64_t* fromstarts, const int64_t* fromstops, const int64_t* fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry) { return awkward_listarray_getitem_carry(tostarts, tostops, fromstarts, fromstops, fromcarry, startsoffset, stopsoffset, lenstarts, lencarry); } diff --git a/src/cpu-kernels/identity.cpp b/src/cpu-kernels/identity.cpp index a74c4e4ff2..4292442da1 100644 --- a/src/cpu-kernels/identity.cpp +++ b/src/cpu-kernels/identity.cpp @@ -49,6 +49,9 @@ ERROR awkward_identity32_from_listarray32(int32_t* toptr, const int32_t* fromptr ERROR awkward_identity64_from_listarray32(int64_t* toptr, const int64_t* fromptr, const int32_t* fromstarts, const int32_t* fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth) { return awkward_identity_from_listarray(toptr, fromptr, fromstarts, fromstops, fromptroffset, startsoffset, stopsoffset, tolength, fromlength, fromwidth); } +ERROR awkward_identity64_from_listarrayU32(int64_t* toptr, const int64_t* fromptr, const uint32_t* fromstarts, const uint32_t* fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth) { + return awkward_identity_from_listarray(toptr, fromptr, fromstarts, fromstops, fromptroffset, startsoffset, stopsoffset, tolength, fromlength, fromwidth); +} ERROR awkward_identity64_from_listarray64(int64_t* toptr, const int64_t* fromptr, const int64_t* fromstarts, const int64_t* fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth) { return awkward_identity_from_listarray(toptr, fromptr, fromstarts, fromstops, fromptroffset, startsoffset, stopsoffset, tolength, fromlength, fromwidth); } diff --git a/src/libawkward/Index.cpp b/src/libawkward/Index.cpp index 0c8d10600e..4cc76051b8 100644 --- a/src/libawkward/Index.cpp +++ b/src/libawkward/Index.cpp @@ -11,12 +11,18 @@ namespace awkward { template const std::string IndexOf::classname() const { - if (std::is_same::value) { + if (std::is_same::value) { return "Index8"; } + else if (std::is_same::value) { + return "IndexU8"; + } else if (std::is_same::value) { return "Index32"; } + else if (std::is_same::value) { + return "IndexU32"; + } else if (std::is_same::value) { return "Index64"; } @@ -106,6 +112,8 @@ namespace awkward { } template class IndexOf; + template class IndexOf; template class IndexOf; + template class IndexOf; template class IndexOf; } diff --git a/src/libawkward/array/ListArray.cpp b/src/libawkward/array/ListArray.cpp index 445cb83689..d8ba03e5d2 100644 --- a/src/libawkward/array/ListArray.cpp +++ b/src/libawkward/array/ListArray.cpp @@ -16,6 +16,9 @@ namespace awkward { if (std::is_same::value) { return "ListArray32"; } + else if (std::is_same::value) { + return "ListArrayU32"; + } else if (std::is_same::value) { return "ListArray64"; } @@ -78,8 +81,8 @@ namespace awkward { id_ = id; } - template <> - void ListArrayOf::setid(const std::shared_ptr id) { + template + void ListArrayOf::setid(const std::shared_ptr id) { if (id.get() == nullptr) { content_.get()->setid(id); } @@ -91,7 +94,7 @@ namespace awkward { if (Identity64* rawid = dynamic_cast(bigid.get())) { Identity64* rawsubid = new Identity64(Identity::newref(), rawid->fieldloc(), rawid->width() + 1, content_.get()->length()); std::shared_ptr subid(rawsubid); - struct Error err = awkward_identity64_from_listarray64( + struct Error err = util::awkward_identity64_from_listarray( rawsubid->ptr().get(), rawid->ptr().get(), starts_.ptr().get(), @@ -225,156 +228,8 @@ namespace awkward { return std::shared_ptr(new ListArrayOf(id, starts_.getitem_range_unsafe(start, stop), stops_.getitem_range_unsafe(start, stop), content_)); } - template <> - const std::shared_ptr ListArrayOf::getitem_next(const std::shared_ptr head, const Slice& tail, const Index64& advanced) const { - int64_t lenstarts = starts_.length(); - if (stops_.length() < lenstarts) { - util::handle_error(failure("len(stops) < len(starts)", kSliceNone, kSliceNone), classname(), id_.get()); - } - - if (head.get() == nullptr) { - return shallow_copy(); - } - - else if (SliceAt* at = dynamic_cast(head.get())) { - assert(advanced.length() == 0); - std::shared_ptr nexthead = tail.head(); - Slice nexttail = tail.tail(); - Index64 nextcarry(lenstarts); - struct Error err = awkward_listarray32_getitem_next_at_64( - nextcarry.ptr().get(), - starts_.ptr().get(), - stops_.ptr().get(), - lenstarts, - starts_.offset(), - stops_.offset(), - at->at()); - util::handle_error(err, classname(), id_.get()); - std::shared_ptr nextcontent = content_.get()->carry(nextcarry); - return nextcontent.get()->getitem_next(nexthead, nexttail, advanced); - } - - else if (SliceRange* range = dynamic_cast(head.get())) { - std::shared_ptr nexthead = tail.head(); - Slice nexttail = tail.tail(); - int64_t start = range->start(); - int64_t stop = range->stop(); - int64_t step = range->step(); - if (step == Slice::none()) { - step = 1; - } - int64_t carrylength; - struct Error err1 = awkward_listarray32_getitem_next_range_carrylength( - &carrylength, - starts_.ptr().get(), - stops_.ptr().get(), - lenstarts, - starts_.offset(), - stops_.offset(), - start, - stop, - step); - util::handle_error(err1, classname(), id_.get()); - - Index32 nextoffsets(lenstarts + 1); - Index64 nextcarry(carrylength); - - struct Error err2 = awkward_listarray32_getitem_next_range_64( - nextoffsets.ptr().get(), - nextcarry.ptr().get(), - starts_.ptr().get(), - stops_.ptr().get(), - lenstarts, - starts_.offset(), - stops_.offset(), - start, - stop, - step); - util::handle_error(err2, classname(), id_.get()); - std::shared_ptr nextcontent = content_.get()->carry(nextcarry); - - if (advanced.length() == 0) { - return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, advanced))); - } - else { - int64_t total; - struct Error err1 = awkward_listarray32_getitem_next_range_counts_64( - &total, - nextoffsets.ptr().get(), - lenstarts); - util::handle_error(err1, classname(), id_.get()); - Index64 nextadvanced(total); - struct Error err2 = awkward_listarray32_getitem_next_range_spreadadvanced_64( - nextadvanced.ptr().get(), - advanced.ptr().get(), - nextoffsets.ptr().get(), - lenstarts); - util::handle_error(err2, classname(), id_.get()); - return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, nextadvanced))); - } - } - - else if (SliceEllipsis* ellipsis = dynamic_cast(head.get())) { - return getitem_ellipsis(tail, advanced); - } - - else if (SliceNewAxis* newaxis = dynamic_cast(head.get())) { - return getitem_newaxis(tail, advanced); - } - - else if (SliceArray64* array = dynamic_cast(head.get())) { - std::shared_ptr nexthead = tail.head(); - Slice nexttail = tail.tail(); - Index64 flathead = array->ravel(); - if (advanced.length() == 0) { - Index64 nextcarry(lenstarts*flathead.length()); - Index64 nextadvanced(lenstarts*flathead.length()); - Index32 nextoffsets(lenstarts + 1); - struct Error err = awkward_listarray32_getitem_next_array_64( - nextoffsets.ptr().get(), - nextcarry.ptr().get(), - nextadvanced.ptr().get(), - starts_.ptr().get(), - stops_.ptr().get(), - flathead.ptr().get(), - starts_.offset(), - stops_.offset(), - lenstarts, - flathead.length(), - content_.get()->length()); - util::handle_error(err, classname(), id_.get()); - std::shared_ptr nextcontent = content_.get()->carry(nextcarry); - // FIXME: if the head is not flat, you'll need to wrap the ListArray output in a RegularArray - return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, nextadvanced))); - } - else { - Index64 nextcarry(lenstarts); - Index64 nextadvanced(lenstarts); - struct Error err = awkward_listarray32_getitem_next_array_advanced_64( - nextcarry.ptr().get(), - nextadvanced.ptr().get(), - starts_.ptr().get(), - stops_.ptr().get(), - flathead.ptr().get(), - advanced.ptr().get(), - starts_.offset(), - stops_.offset(), - lenstarts, - flathead.length(), - content_.get()->length()); - util::handle_error(err, classname(), id_.get()); - std::shared_ptr nextcontent = content_.get()->carry(nextcarry); - return nextcontent.get()->getitem_next(nexthead, nexttail, nextadvanced); - } - } - - else { - throw std::runtime_error("unrecognized slice item type"); - } - } - - template <> - const std::shared_ptr ListArrayOf::getitem_next(const std::shared_ptr head, const Slice& tail, const Index64& advanced) const { + template + const std::shared_ptr ListArrayOf::getitem_next(const std::shared_ptr head, const Slice& tail, const Index64& advanced) const { int64_t lenstarts = starts_.length(); if (stops_.length() < lenstarts) { util::handle_error(failure("len(stops) < len(starts)", kSliceNone, kSliceNone), classname(), id_.get()); @@ -389,7 +244,7 @@ namespace awkward { std::shared_ptr nexthead = tail.head(); Slice nexttail = tail.tail(); Index64 nextcarry(lenstarts); - struct Error err = awkward_listarray64_getitem_next_at_64( + struct Error err = util::awkward_listarray_getitem_next_at_64( nextcarry.ptr().get(), starts_.ptr().get(), stops_.ptr().get(), @@ -412,7 +267,7 @@ namespace awkward { step = 1; } int64_t carrylength; - struct Error err1 = awkward_listarray64_getitem_next_range_carrylength( + struct Error err1 = util::awkward_listarray_getitem_next_range_carrylength( &carrylength, starts_.ptr().get(), stops_.ptr().get(), @@ -424,10 +279,10 @@ namespace awkward { step); util::handle_error(err1, classname(), id_.get()); - Index64 nextoffsets(lenstarts + 1); + IndexOf nextoffsets(lenstarts + 1); Index64 nextcarry(carrylength); - struct Error err2 = awkward_listarray64_getitem_next_range_64( + struct Error err2 = util::awkward_listarray_getitem_next_range_64( nextoffsets.ptr().get(), nextcarry.ptr().get(), starts_.ptr().get(), @@ -442,23 +297,23 @@ namespace awkward { std::shared_ptr nextcontent = content_.get()->carry(nextcarry); if (advanced.length() == 0) { - return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, advanced))); + return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, advanced))); } else { int64_t total; - struct Error err1 = awkward_listarray64_getitem_next_range_counts_64( + struct Error err1 = util::awkward_listarray_getitem_next_range_counts_64( &total, nextoffsets.ptr().get(), lenstarts); util::handle_error(err1, classname(), id_.get()); Index64 nextadvanced(total); - struct Error err2 = awkward_listarray64_getitem_next_range_spreadadvanced_64( + struct Error err2 = util::awkward_listarray_getitem_next_range_spreadadvanced_64( nextadvanced.ptr().get(), advanced.ptr().get(), nextoffsets.ptr().get(), lenstarts); util::handle_error(err2, classname(), id_.get()); - return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, nextadvanced))); + return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, nextadvanced))); } } @@ -477,8 +332,8 @@ namespace awkward { if (advanced.length() == 0) { Index64 nextcarry(lenstarts*flathead.length()); Index64 nextadvanced(lenstarts*flathead.length()); - Index64 nextoffsets(lenstarts + 1); - struct Error err = awkward_listarray64_getitem_next_array_64( + IndexOf nextoffsets(lenstarts + 1); + struct Error err = util::awkward_listarray_getitem_next_array_64( nextoffsets.ptr().get(), nextcarry.ptr().get(), nextadvanced.ptr().get(), @@ -493,12 +348,12 @@ namespace awkward { util::handle_error(err, classname(), id_.get()); std::shared_ptr nextcontent = content_.get()->carry(nextcarry); // FIXME: if the head is not flat, you'll need to wrap the ListArray output in a RegularArray - return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, nextadvanced))); + return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, nextadvanced))); } else { Index64 nextcarry(lenstarts); Index64 nextadvanced(lenstarts); - struct Error err = awkward_listarray64_getitem_next_array_advanced_64( + struct Error err = util::awkward_listarray_getitem_next_array_advanced_64( nextcarry.ptr().get(), nextadvanced.ptr().get(), starts_.ptr().get(), @@ -521,41 +376,15 @@ namespace awkward { } } - template <> - const std::shared_ptr ListArrayOf::carry(const Index64& carry) const { - int64_t lenstarts = starts_.length(); - if (stops_.length() < lenstarts) { - util::handle_error(failure("len(stops) < len(starts)", kSliceNone, kSliceNone), classname(), id_.get()); - } - Index32 nextstarts(carry.length()); - Index32 nextstops(carry.length()); - struct Error err = awkward_listarray32_getitem_carry_64( - nextstarts.ptr().get(), - nextstops.ptr().get(), - starts_.ptr().get(), - stops_.ptr().get(), - carry.ptr().get(), - starts_.offset(), - stops_.offset(), - lenstarts, - carry.length()); - util::handle_error(err, classname(), id_.get()); - std::shared_ptr id(nullptr); - if (id_.get() != nullptr) { - id = id_.get()->getitem_carry_64(carry); - } - return std::shared_ptr(new ListArrayOf(id, nextstarts, nextstops, content_)); - } - - template <> - const std::shared_ptr ListArrayOf::carry(const Index64& carry) const { + template + const std::shared_ptr ListArrayOf::carry(const Index64& carry) const { int64_t lenstarts = starts_.length(); if (stops_.length() < lenstarts) { util::handle_error(failure("len(stops) < len(starts)", kSliceNone, kSliceNone), classname(), id_.get()); } - Index64 nextstarts(carry.length()); - Index64 nextstops(carry.length()); - struct Error err = awkward_listarray64_getitem_carry_64( + IndexOf nextstarts(carry.length()); + IndexOf nextstops(carry.length()); + struct Error err = util::awkward_listarray_getitem_carry_64( nextstarts.ptr().get(), nextstops.ptr().get(), starts_.ptr().get(), @@ -570,7 +399,7 @@ namespace awkward { if (id_.get() != nullptr) { id = id_.get()->getitem_carry_64(carry); } - return std::shared_ptr(new ListArrayOf(id, nextstarts, nextstops, content_)); + return std::shared_ptr(new ListArrayOf(id, nextstarts, nextstops, content_)); } template @@ -580,5 +409,6 @@ namespace awkward { } template class ListArrayOf; + template class ListArrayOf; template class ListArrayOf; } diff --git a/src/libawkward/array/ListOffsetArray.cpp b/src/libawkward/array/ListOffsetArray.cpp index a1d818ba3b..0257864065 100644 --- a/src/libawkward/array/ListOffsetArray.cpp +++ b/src/libawkward/array/ListOffsetArray.cpp @@ -16,6 +16,9 @@ namespace awkward { if (std::is_same::value) { return "ListOffsetArray32"; } + else if (std::is_same::value) { + return "ListOffsetArrayU32"; + } else if (std::is_same::value) { return "ListOffsetArray64"; } @@ -90,8 +93,8 @@ namespace awkward { id_ = id; } - template <> - void ListOffsetArrayOf::setid(const std::shared_ptr id) { + template + void ListOffsetArrayOf::setid(const std::shared_ptr id) { if (id.get() == nullptr) { content_.get()->setid(id); } @@ -99,13 +102,13 @@ namespace awkward { if (length() != id.get()->length()) { util::handle_error(failure("content and its id must have the same length", kSliceNone, kSliceNone), classname(), id_.get()); } - Index64 starts = make_starts(offsets_); - Index64 stops = make_stops(offsets_); + IndexOf starts = make_starts(offsets_); + IndexOf stops = make_stops(offsets_); std::shared_ptr bigid = id.get()->to64(); if (Identity64* rawid = dynamic_cast(bigid.get())) { Identity64* rawsubid = new Identity64(Identity::newref(), rawid->fieldloc(), rawid->width() + 1, content_.get()->length()); std::shared_ptr subid(rawsubid); - struct Error err = awkward_identity64_from_listarray64( + struct Error err = util::awkward_identity64_from_listarray( rawsubid->ptr().get(), rawid->ptr().get(), starts.ptr().get(), @@ -229,160 +232,8 @@ namespace awkward { return std::shared_ptr(new ListOffsetArrayOf(id, offsets_.getitem_range_unsafe(start, stop + 1), content_)); } - template <> - const std::shared_ptr ListOffsetArrayOf::getitem_next(const std::shared_ptr head, const Slice& tail, const Index64& advanced) const { - int64_t lenstarts = offsets_.length() - 1; - - if (head.get() == nullptr) { - return shallow_copy(); - } - - else if (SliceAt* at = dynamic_cast(head.get())) { - assert(advanced.length() == 0); - Index32 starts = make_starts(offsets_); - Index32 stops = make_stops(offsets_); - std::shared_ptr nexthead = tail.head(); - Slice nexttail = tail.tail(); - Index64 nextcarry(lenstarts); - struct Error err = awkward_listarray32_getitem_next_at_64( - nextcarry.ptr().get(), - starts.ptr().get(), - stops.ptr().get(), - lenstarts, - starts.offset(), - stops.offset(), - at->at()); - util::handle_error(err, classname(), id_.get()); - std::shared_ptr nextcontent = content_.get()->carry(nextcarry); - return nextcontent.get()->getitem_next(nexthead, nexttail, advanced); - } - - else if (SliceRange* range = dynamic_cast(head.get())) { - Index32 starts = make_starts(offsets_); - Index32 stops = make_stops(offsets_); - std::shared_ptr nexthead = tail.head(); - Slice nexttail = tail.tail(); - int64_t start = range->start(); - int64_t stop = range->stop(); - int64_t step = range->step(); - if (step == Slice::none()) { - step = 1; - } - int64_t carrylength; - struct Error err1 = awkward_listarray32_getitem_next_range_carrylength( - &carrylength, - starts.ptr().get(), - stops.ptr().get(), - lenstarts, - starts.offset(), - stops.offset(), - start, - stop, - step); - util::handle_error(err1, classname(), id_.get()); - - Index32 nextoffsets(lenstarts + 1); - Index64 nextcarry(carrylength); - - struct Error err2 = awkward_listarray32_getitem_next_range_64( - nextoffsets.ptr().get(), - nextcarry.ptr().get(), - starts.ptr().get(), - stops.ptr().get(), - lenstarts, - starts.offset(), - stops.offset(), - start, - stop, - step); - util::handle_error(err2, classname(), id_.get()); - std::shared_ptr nextcontent = content_.get()->carry(nextcarry); - - if (advanced.length() == 0) { - return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, advanced))); - } - else { - int64_t total; - struct Error err1 = awkward_listarray32_getitem_next_range_counts_64( - &total, - nextoffsets.ptr().get(), - lenstarts); - util::handle_error(err1, classname(), id_.get()); - Index64 nextadvanced(total); - struct Error err2 = awkward_listarray32_getitem_next_range_spreadadvanced_64( - nextadvanced.ptr().get(), - advanced.ptr().get(), - nextoffsets.ptr().get(), - lenstarts); - util::handle_error(err2, classname(), id_.get()); - return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, nextadvanced))); - } - } - - else if (SliceEllipsis* ellipsis = dynamic_cast(head.get())) { - return getitem_ellipsis(tail, advanced); - } - - else if (SliceNewAxis* newaxis = dynamic_cast(head.get())) { - return getitem_newaxis(tail, advanced); - } - - else if (SliceArray64* array = dynamic_cast(head.get())) { - Index32 starts = make_starts(offsets_); - Index32 stops = make_stops(offsets_); - std::shared_ptr nexthead = tail.head(); - Slice nexttail = tail.tail(); - Index64 flathead = array->ravel(); - if (advanced.length() == 0) { - Index64 nextcarry(lenstarts*flathead.length()); - Index64 nextadvanced(lenstarts*flathead.length()); - Index32 nextoffsets(lenstarts + 1); - Index32 nextstops(lenstarts); - struct Error err = awkward_listarray32_getitem_next_array_64( - nextoffsets.ptr().get(), - nextcarry.ptr().get(), - nextadvanced.ptr().get(), - starts.ptr().get(), - stops.ptr().get(), - flathead.ptr().get(), - starts.offset(), - stops.offset(), - lenstarts, - flathead.length(), - content_.get()->length()); - util::handle_error(err, classname(), id_.get()); - std::shared_ptr nextcontent = content_.get()->carry(nextcarry); - // FIXME: if the head is not flat, you'll need to wrap the ListArray output in a RegularArray - return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, nextadvanced))); - } - else { - Index64 nextcarry(lenstarts); - Index64 nextadvanced(lenstarts); - struct Error err = awkward_listarray32_getitem_next_array_advanced_64( - nextcarry.ptr().get(), - nextadvanced.ptr().get(), - starts.ptr().get(), - stops.ptr().get(), - flathead.ptr().get(), - advanced.ptr().get(), - starts.offset(), - stops.offset(), - lenstarts, - flathead.length(), - content_.get()->length()); - util::handle_error(err, classname(), id_.get()); - std::shared_ptr nextcontent = content_.get()->carry(nextcarry); - return nextcontent.get()->getitem_next(nexthead, nexttail, nextadvanced); - } - } - - else { - throw std::runtime_error("unrecognized slice item type"); - } - } - - template <> - const std::shared_ptr ListOffsetArrayOf::getitem_next(const std::shared_ptr head, const Slice& tail, const Index64& advanced) const { + template + const std::shared_ptr ListOffsetArrayOf::getitem_next(const std::shared_ptr head, const Slice& tail, const Index64& advanced) const { int64_t lenstarts = offsets_.length() - 1; if (head.get() == nullptr) { @@ -391,12 +242,12 @@ namespace awkward { else if (SliceAt* at = dynamic_cast(head.get())) { assert(advanced.length() == 0); - Index64 starts = make_starts(offsets_); - Index64 stops = make_stops(offsets_); + IndexOf starts = make_starts(offsets_); + IndexOf stops = make_stops(offsets_); std::shared_ptr nexthead = tail.head(); Slice nexttail = tail.tail(); Index64 nextcarry(lenstarts); - struct Error err = awkward_listarray64_getitem_next_at_64( + struct Error err = util::awkward_listarray_getitem_next_at_64( nextcarry.ptr().get(), starts.ptr().get(), stops.ptr().get(), @@ -410,8 +261,8 @@ namespace awkward { } else if (SliceRange* range = dynamic_cast(head.get())) { - Index64 starts = make_starts(offsets_); - Index64 stops = make_stops(offsets_); + IndexOf starts = make_starts(offsets_); + IndexOf stops = make_stops(offsets_); std::shared_ptr nexthead = tail.head(); Slice nexttail = tail.tail(); int64_t start = range->start(); @@ -421,7 +272,7 @@ namespace awkward { step = 1; } int64_t carrylength; - struct Error err1 = awkward_listarray64_getitem_next_range_carrylength( + struct Error err1 = util::awkward_listarray_getitem_next_range_carrylength( &carrylength, starts.ptr().get(), stops.ptr().get(), @@ -433,10 +284,10 @@ namespace awkward { step); util::handle_error(err1, classname(), id_.get()); - Index64 nextoffsets(lenstarts + 1); + IndexOf nextoffsets(lenstarts + 1); Index64 nextcarry(carrylength); - struct Error err2 = awkward_listarray64_getitem_next_range_64( + struct Error err2 = util::awkward_listarray_getitem_next_range_64( nextoffsets.ptr().get(), nextcarry.ptr().get(), starts.ptr().get(), @@ -451,23 +302,23 @@ namespace awkward { std::shared_ptr nextcontent = content_.get()->carry(nextcarry); if (advanced.length() == 0) { - return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, advanced))); + return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, advanced))); } else { int64_t total; - struct Error err1 = awkward_listarray64_getitem_next_range_counts_64( + struct Error err1 = util::awkward_listarray_getitem_next_range_counts_64( &total, nextoffsets.ptr().get(), lenstarts); util::handle_error(err1, classname(), id_.get()); Index64 nextadvanced(total); - struct Error err2 = awkward_listarray64_getitem_next_range_spreadadvanced_64( + struct Error err2 = util::awkward_listarray_getitem_next_range_spreadadvanced_64( nextadvanced.ptr().get(), advanced.ptr().get(), nextoffsets.ptr().get(), lenstarts); util::handle_error(err2, classname(), id_.get()); - return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, nextadvanced))); + return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, nextadvanced))); } } @@ -480,17 +331,17 @@ namespace awkward { } else if (SliceArray64* array = dynamic_cast(head.get())) { - Index64 starts = make_starts(offsets_); - Index64 stops = make_stops(offsets_); + IndexOf starts = make_starts(offsets_); + IndexOf stops = make_stops(offsets_); std::shared_ptr nexthead = tail.head(); Slice nexttail = tail.tail(); Index64 flathead = array->ravel(); if (advanced.length() == 0) { Index64 nextcarry(lenstarts*flathead.length()); Index64 nextadvanced(lenstarts*flathead.length()); - Index64 nextoffsets(lenstarts + 1); - Index64 nextstops(lenstarts); - struct Error err = awkward_listarray64_getitem_next_array_64( + IndexOf nextoffsets(lenstarts + 1); + IndexOf nextstops(lenstarts); + struct Error err = util::awkward_listarray_getitem_next_array_64( nextoffsets.ptr().get(), nextcarry.ptr().get(), nextadvanced.ptr().get(), @@ -505,12 +356,12 @@ namespace awkward { util::handle_error(err, classname(), id_.get()); std::shared_ptr nextcontent = content_.get()->carry(nextcarry); // FIXME: if the head is not flat, you'll need to wrap the ListArray output in a RegularArray - return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, nextadvanced))); + return std::shared_ptr(new ListOffsetArrayOf(id_, nextoffsets, nextcontent.get()->getitem_next(nexthead, nexttail, nextadvanced))); } else { Index64 nextcarry(lenstarts); Index64 nextadvanced(lenstarts); - struct Error err = awkward_listarray64_getitem_next_array_advanced_64( + struct Error err = util::awkward_listarray_getitem_next_array_advanced_64( nextcarry.ptr().get(), nextadvanced.ptr().get(), starts.ptr().get(), @@ -533,37 +384,13 @@ namespace awkward { } } - template <> - const std::shared_ptr ListOffsetArrayOf::carry(const Index64& carry) const { - Index32 starts = make_starts(offsets_); - Index32 stops = make_stops(offsets_); - Index32 nextstarts(carry.length()); - Index32 nextstops(carry.length()); - struct Error err = awkward_listarray32_getitem_carry_64( - nextstarts.ptr().get(), - nextstops.ptr().get(), - starts.ptr().get(), - stops.ptr().get(), - carry.ptr().get(), - starts.offset(), - stops.offset(), - offsets_.length() - 1, - carry.length()); - util::handle_error(err, classname(), id_.get()); - std::shared_ptr id(nullptr); - if (id_.get() != nullptr) { - id = id_.get()->getitem_carry_64(carry); - } - return std::shared_ptr(new ListArrayOf(id, nextstarts, nextstops, content_)); - } - - template <> - const std::shared_ptr ListOffsetArrayOf::carry(const Index64& carry) const { - Index64 starts = make_starts(offsets_); - Index64 stops = make_stops(offsets_); - Index64 nextstarts(carry.length()); - Index64 nextstops(carry.length()); - struct Error err = awkward_listarray64_getitem_carry_64( + template + const std::shared_ptr ListOffsetArrayOf::carry(const Index64& carry) const { + IndexOf starts = make_starts(offsets_); + IndexOf stops = make_stops(offsets_); + IndexOf nextstarts(carry.length()); + IndexOf nextstops(carry.length()); + struct Error err = util::awkward_listarray_getitem_carry_64( nextstarts.ptr().get(), nextstops.ptr().get(), starts.ptr().get(), @@ -578,7 +405,7 @@ namespace awkward { if (id_.get() != nullptr) { id = id_.get()->getitem_carry_64(carry); } - return std::shared_ptr(new ListArrayOf(id, nextstarts, nextstops, content_)); + return std::shared_ptr(new ListArrayOf(id, nextstarts, nextstops, content_)); } template @@ -588,5 +415,6 @@ namespace awkward { } template class ListOffsetArrayOf; + template class ListOffsetArrayOf; template class ListOffsetArrayOf; } diff --git a/src/libawkward/util.cpp b/src/libawkward/util.cpp index 3f51fe6c1e..cf4438f557 100644 --- a/src/libawkward/util.cpp +++ b/src/libawkward/util.cpp @@ -3,6 +3,9 @@ #include #include +#include "awkward/cpu-kernels/identity.h" +#include "awkward/cpu-kernels/getitem.h" + #include "awkward/util.h" #include "awkward/Identity.h" @@ -28,5 +31,119 @@ namespace awkward { throw std::invalid_argument(out.str()); } } + + template <> + Error awkward_identity64_from_listarray(int64_t* toptr, const int64_t* fromptr, const uint32_t* fromstarts, const uint32_t* fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth) { + return awkward_identity64_from_listarrayU32(toptr, fromptr, fromstarts, fromstops, fromptroffset, startsoffset, stopsoffset, tolength, fromlength, fromwidth); + } + template <> + Error awkward_identity64_from_listarray(int64_t* toptr, const int64_t* fromptr, const int64_t* fromstarts, const int64_t* fromstops, int64_t fromptroffset, int64_t startsoffset, int64_t stopsoffset, int64_t tolength, int64_t fromlength, int64_t fromwidth) { + return awkward_identity64_from_listarray64(toptr, fromptr, fromstarts, fromstops, fromptroffset, startsoffset, stopsoffset, tolength, fromlength, fromwidth); + } + + template <> + Error awkward_listarray_getitem_next_at_64(int64_t* tocarry, const int32_t* fromstarts, const int32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at) { + return awkward_listarray32_getitem_next_at_64(tocarry, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, at); + } + template <> + Error awkward_listarray_getitem_next_at_64(int64_t* tocarry, const uint32_t* fromstarts, const uint32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at) { + return awkward_listarrayU32_getitem_next_at_64(tocarry, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, at); + } + template <> + Error awkward_listarray_getitem_next_at_64(int64_t* tocarry, const int64_t* fromstarts, const int64_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t at) { + return awkward_listarray64_getitem_next_at_64(tocarry, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, at); + } + + template <> + Error awkward_listarray_getitem_next_range_carrylength(int64_t* carrylength, const int32_t* fromstarts, const int32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) { + return awkward_listarray32_getitem_next_range_carrylength(carrylength, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, start, stop, step); + } + template <> + Error awkward_listarray_getitem_next_range_carrylength(int64_t* carrylength, const uint32_t* fromstarts, const uint32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) { + return awkward_listarrayU32_getitem_next_range_carrylength(carrylength, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, start, stop, step); + } + template <> + Error awkward_listarray_getitem_next_range_carrylength(int64_t* carrylength, const int64_t* fromstarts, const int64_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) { + return awkward_listarray64_getitem_next_range_carrylength(carrylength, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, start, stop, step); + } + + template <> + Error awkward_listarray_getitem_next_range_64(int32_t* tooffsets, int64_t* tocarry, const int32_t* fromstarts, const int32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) { + return awkward_listarray32_getitem_next_range_64(tooffsets, tocarry, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, start, stop, step); + } + template <> + Error awkward_listarray_getitem_next_range_64(uint32_t* tooffsets, int64_t* tocarry, const uint32_t* fromstarts, const uint32_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) { + return awkward_listarrayU32_getitem_next_range_64(tooffsets, tocarry, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, start, stop, step); + } + template <> + Error awkward_listarray_getitem_next_range_64(int64_t* tooffsets, int64_t* tocarry, const int64_t* fromstarts, const int64_t* fromstops, int64_t lenstarts, int64_t startsoffset, int64_t stopsoffset, int64_t start, int64_t stop, int64_t step) { + return awkward_listarray64_getitem_next_range_64(tooffsets, tocarry, fromstarts, fromstops, lenstarts, startsoffset, stopsoffset, start, stop, step); + } + + template <> + Error awkward_listarray_getitem_next_range_counts_64(int64_t* total, const int32_t* fromoffsets, int64_t lenstarts) { + return awkward_listarray32_getitem_next_range_counts_64(total, fromoffsets, lenstarts); + } + template <> + Error awkward_listarray_getitem_next_range_counts_64(int64_t* total, const uint32_t* fromoffsets, int64_t lenstarts) { + return awkward_listarrayU32_getitem_next_range_counts_64(total, fromoffsets, lenstarts); + } + template <> + Error awkward_listarray_getitem_next_range_counts_64(int64_t* total, const int64_t* fromoffsets, int64_t lenstarts) { + return awkward_listarray64_getitem_next_range_counts_64(total, fromoffsets, lenstarts); + } + + template <> + Error awkward_listarray_getitem_next_range_spreadadvanced_64(int64_t* toadvanced, const int64_t* fromadvanced, const int32_t* fromoffsets, int64_t lenstarts) { + return awkward_listarray32_getitem_next_range_spreadadvanced_64(toadvanced, fromadvanced, fromoffsets, lenstarts); + } + template <> + Error awkward_listarray_getitem_next_range_spreadadvanced_64(int64_t* toadvanced, const int64_t* fromadvanced, const uint32_t* fromoffsets, int64_t lenstarts) { + return awkward_listarrayU32_getitem_next_range_spreadadvanced_64(toadvanced, fromadvanced, fromoffsets, lenstarts); + } + template <> + Error awkward_listarray_getitem_next_range_spreadadvanced_64(int64_t* toadvanced, const int64_t* fromadvanced, const int64_t* fromoffsets, int64_t lenstarts) { + return awkward_listarray64_getitem_next_range_spreadadvanced_64(toadvanced, fromadvanced, fromoffsets, lenstarts); + } + + template <> + Error awkward_listarray_getitem_next_array_64(int32_t* tooffsets, int64_t* tocarry, int64_t* toadvanced, const int32_t* fromstarts, const int32_t* fromstops, const int64_t* fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) { + return awkward_listarray32_getitem_next_array_64(tooffsets, tocarry, toadvanced, fromstarts, fromstops, fromarray, startsoffset, stopsoffset, lenstarts, lenarray, lencontent); + } + template <> + Error awkward_listarray_getitem_next_array_64(uint32_t* tooffsets, int64_t* tocarry, int64_t* toadvanced, const uint32_t* fromstarts, const uint32_t* fromstops, const int64_t* fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) { + return awkward_listarrayU32_getitem_next_array_64(tooffsets, tocarry, toadvanced, fromstarts, fromstops, fromarray, startsoffset, stopsoffset, lenstarts, lenarray, lencontent); + } + template <> + Error awkward_listarray_getitem_next_array_64(int64_t* tooffsets, int64_t* tocarry, int64_t* toadvanced, const int64_t* fromstarts, const int64_t* fromstops, const int64_t* fromarray, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) { + return awkward_listarray64_getitem_next_array_64(tooffsets, tocarry, toadvanced, fromstarts, fromstops, fromarray, startsoffset, stopsoffset, lenstarts, lenarray, lencontent); + } + + template <> + Error awkward_listarray_getitem_next_array_advanced_64(int64_t* tocarry, int64_t* toadvanced, const int32_t* fromstarts, const int32_t* fromstops, const int64_t* fromarray, const int64_t* fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) { + return awkward_listarray32_getitem_next_array_advanced_64(tocarry, toadvanced, fromstarts, fromstops, fromarray, fromadvanced, startsoffset, stopsoffset, lenstarts, lenarray, lencontent); + } + template <> + Error awkward_listarray_getitem_next_array_advanced_64(int64_t* tocarry, int64_t* toadvanced, const uint32_t* fromstarts, const uint32_t* fromstops, const int64_t* fromarray, const int64_t* fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) { + return awkward_listarrayU32_getitem_next_array_advanced_64(tocarry, toadvanced, fromstarts, fromstops, fromarray, fromadvanced, startsoffset, stopsoffset, lenstarts, lenarray, lencontent); + } + template <> + Error awkward_listarray_getitem_next_array_advanced_64(int64_t* tocarry, int64_t* toadvanced, const int64_t* fromstarts, const int64_t* fromstops, const int64_t* fromarray, const int64_t* fromadvanced, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lenarray, int64_t lencontent) { + return awkward_listarray64_getitem_next_array_advanced_64(tocarry, toadvanced, fromstarts, fromstops, fromarray, fromadvanced, startsoffset, stopsoffset, lenstarts, lenarray, lencontent); + } + + template <> + Error awkward_listarray_getitem_carry_64(int32_t* tostarts, int32_t* tostops, const int32_t* fromstarts, const int32_t* fromstops, const int64_t* fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry) { + return awkward_listarray32_getitem_carry_64(tostarts, tostops, fromstarts, fromstops, fromcarry, startsoffset, stopsoffset, lenstarts, lencarry); + } + template <> + Error awkward_listarray_getitem_carry_64(uint32_t* tostarts, uint32_t* tostops, const uint32_t* fromstarts, const uint32_t* fromstops, const int64_t* fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry) { + return awkward_listarrayU32_getitem_carry_64(tostarts, tostops, fromstarts, fromstops, fromcarry, startsoffset, stopsoffset, lenstarts, lencarry); + } + template <> + Error awkward_listarray_getitem_carry_64(int64_t* tostarts, int64_t* tostops, const int64_t* fromstarts, const int64_t* fromstops, const int64_t* fromcarry, int64_t startsoffset, int64_t stopsoffset, int64_t lenstarts, int64_t lencarry) { + return awkward_listarray64_getitem_carry_64(tostarts, tostops, fromstarts, fromstops, fromcarry, startsoffset, stopsoffset, lenstarts, lencarry); + } + } } diff --git a/src/pyawkward.cpp b/src/pyawkward.cpp index 9bedf1b1d8..23b6c490c8 100644 --- a/src/pyawkward.cpp +++ b/src/pyawkward.cpp @@ -80,12 +80,18 @@ py::object box(std::shared_ptr content) { else if (ak::ListArray32* raw = dynamic_cast(content.get())) { return py::cast(*raw); } + else if (ak::ListArrayU32* raw = dynamic_cast(content.get())) { + return py::cast(*raw); + } else if (ak::ListArray64* raw = dynamic_cast(content.get())) { return py::cast(*raw); } else if (ak::ListOffsetArray32* raw = dynamic_cast(content.get())) { return py::cast(*raw); } + else if (ak::ListOffsetArrayU32* raw = dynamic_cast(content.get())) { + return py::cast(*raw); + } else if (ak::ListOffsetArray64* raw = dynamic_cast(content.get())) { return py::cast(*raw); } @@ -146,6 +152,10 @@ std::shared_ptr unbox_content(py::object obj) { return obj.cast()->shallow_copy(); } catch (py::cast_error err) { } + try { + return obj.cast()->shallow_copy(); + } + catch (py::cast_error err) { } try { return obj.cast()->shallow_copy(); } @@ -154,6 +164,10 @@ std::shared_ptr unbox_content(py::object obj) { return obj.cast()->shallow_copy(); } catch (py::cast_error err) { } + try { + return obj.cast()->shallow_copy(); + } + catch (py::cast_error err) { } try { return obj.cast()->shallow_copy(); } @@ -777,9 +791,11 @@ PYBIND11_MODULE(layout, m) { m.attr("__version__") = "dev"; #endif - make_IndexOf(m, "Index8"); - make_IndexOf(m, "Index32"); - make_IndexOf(m, "Index64"); + make_IndexOf(m, "Index8"); + make_IndexOf(m, "IndexU8"); + make_IndexOf(m, "Index32"); + make_IndexOf(m, "IndexU32"); + make_IndexOf(m, "Index64"); make_IdentityOf(m, "Identity32"); make_IdentityOf(m, "Identity64"); @@ -802,11 +818,13 @@ PYBIND11_MODULE(layout, m) { make_NumpyArray(m, "NumpyArray"); - make_ListArrayOf(m, "ListArray32"); - make_ListArrayOf(m, "ListArray64"); + make_ListArrayOf(m, "ListArray32"); + make_ListArrayOf(m, "ListArrayU32"); + make_ListArrayOf(m, "ListArray64"); - make_ListOffsetArrayOf(m, "ListOffsetArray32"); - make_ListOffsetArrayOf(m, "ListOffsetArray64"); + make_ListOffsetArrayOf(m, "ListOffsetArray32"); + make_ListOffsetArrayOf(m, "ListOffsetArrayU32"); + make_ListOffsetArrayOf(m, "ListOffsetArray64"); m.def("fromjson", [](std::string source, int64_t initial, double resize, int64_t buffersize) -> py::object { bool isarray = false; diff --git a/tests/test_PR020_support_unsigned_indexes.py b/tests/test_PR020_support_unsigned_indexes.py new file mode 100644 index 0000000000..d2a5c317c4 --- /dev/null +++ b/tests/test_PR020_support_unsigned_indexes.py @@ -0,0 +1,327 @@ +# BSD 3-Clause License; see https://github.com/jpivarski/awkward-1.0/blob/master/LICENSE + +import sys +import os +import json + +import pytest +import numpy +numba = pytest.importorskip("numba") + +import awkward1 + +py27 = (sys.version_info[0] < 3) + +def test_index(): + array_i1 = numpy.array([numpy.iinfo("i1").min, -1, 0, 1, numpy.iinfo("i1").max], dtype="i1") + array_u1 = numpy.array([numpy.iinfo("u1").min, -1, 0, 1, numpy.iinfo("u1").max], dtype="u1") + array_li2 = numpy.array([numpy.iinfo("i2").min, -1, 0, 1, numpy.iinfo(">i2").max], dtype=">i2") + array_bu2 = numpy.array([numpy.iinfo(">u2").min, -1, 0, 1, numpy.iinfo(">u2").max], dtype=">u2") + array_bi4 = numpy.array([numpy.iinfo(">i4").min, -1, 0, 1, numpy.iinfo(">i4").max], dtype=">i4") + array_bu4 = numpy.array([numpy.iinfo(">u4").min, -1, 0, 1, numpy.iinfo(">u4").max], dtype=">u4") + array_bi8 = numpy.array([numpy.iinfo(">i8").min, -1, 0, 1, numpy.iinfo(">i8").max], dtype=">i8") + array_bu8 = numpy.array([numpy.iinfo(">u8").min, -1, 0, 1, numpy.iinfo(">u8").max], dtype=">u8") + + index_i1 = awkward1.layout.Index8(array_i1) + index_u1 = awkward1.layout.IndexU8(array_u1) + index_li2 = awkward1.layout.Index32(array_li2) + index_lu2 = awkward1.layout.Index32(array_lu2) + index_li4 = awkward1.layout.Index32(array_li4) + index_lu4 = awkward1.layout.IndexU32(array_lu4) + index_li8 = awkward1.layout.Index64(array_li8) + index_lu8 = awkward1.layout.Index64(array_lu8) + index_bi2 = awkward1.layout.Index32(array_bi2) + index_bu2 = awkward1.layout.Index32(array_bu2) + index_bi4 = awkward1.layout.Index32(array_bi4) + index_bu4 = awkward1.layout.IndexU32(array_bu4) + index_bi8 = awkward1.layout.Index64(array_bi8) + index_bu8 = awkward1.layout.Index64(array_bu8) + + assert index_i1[2] == 0 + assert index_u1[2] == 0 + assert index_li2[2] == 0 + assert index_lu2[2] == 0 + assert index_li4[2] == 0 + assert index_lu4[2] == 0 + assert index_li8[2] == 0 + assert index_lu8[2] == 0 + assert index_bi2[2] == 0 + assert index_bu2[2] == 0 + assert index_bi4[2] == 0 + assert index_bu4[2] == 0 + assert index_bi8[2] == 0 + assert index_bu8[2] == 0 + + array_i1[2] = 10 + array_u1[2] = 10 + array_li2[2] = 10 + array_lu2[2] = 10 + array_li4[2] = 10 + array_lu4[2] = 10 + array_li8[2] = 10 + array_lu8[2] = 10 + array_bi2[2] = 10 + array_bu2[2] = 10 + array_bi4[2] = 10 + array_bu4[2] = 10 + array_bi8[2] = 10 + array_bu8[2] = 10 + + assert index_i1[2] == 10 + assert index_u1[2] == 10 + assert index_li2[2] == 0 + assert index_lu2[2] == 0 + assert index_li4[2] == 10 + assert index_lu4[2] == 10 + assert index_li8[2] == 10 + assert index_lu8[2] == 0 + assert index_bi2[2] == 0 + assert index_bu2[2] == 0 + assert index_bi4[2] == 0 + assert index_bu4[2] == 0 + assert index_bi8[2] == 0 + assert index_bu8[2] == 0 + +content = awkward1.layout.NumpyArray(numpy.array([1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9])) +starts1 = awkward1.layout.IndexU32(numpy.array([0, 3, 3, 5, 6], numpy.uint32)) +stops1 = awkward1.layout.IndexU32(numpy.array([3, 3, 5, 6, 9], numpy.uint32)) +offsets1 = awkward1.layout.IndexU32(numpy.array([0, 3, 3, 5, 6, 9], numpy.uint32)) +starts2 = awkward1.layout.IndexU32(numpy.array([0, 2, 3, 3], numpy.uint32)) +stops2 = awkward1.layout.IndexU32(numpy.array([2, 3, 3, 5], numpy.uint32)) +offsets2 = awkward1.layout.IndexU32(numpy.array([0, 2, 3, 3, 5], numpy.uint32)) + +def test_listarray_basic(): + array1 = awkward1.layout.ListArrayU32(starts1, stops1, content) + array2 = awkward1.layout.ListArrayU32(starts2, stops2, array1) + assert awkward1.tolist(array1) == [[1.1, 2.2, 3.3], [], [4.4, 5.5], [6.6], [7.7, 8.8, 9.9]] + assert awkward1.tolist(array1[2]) == [4.4, 5.5] + assert awkward1.tolist(array1[1:-1]) == [[], [4.4, 5.5], [6.6]] + assert awkward1.tolist(array2) == [[[1.1, 2.2, 3.3], []], [[4.4, 5.5]], [], [[6.6], [7.7, 8.8, 9.9]]] + assert awkward1.tolist(array2[1]) == [[4.4, 5.5]] + assert awkward1.tolist(array2[1:-1]) == [[[4.4, 5.5]], []] + +def test_listoffsetarray_basic(): + array1 = awkward1.layout.ListOffsetArrayU32(offsets1, content) + array2 = awkward1.layout.ListOffsetArrayU32(offsets2, array1) + assert awkward1.tolist(array1) == [[1.1, 2.2, 3.3], [], [4.4, 5.5], [6.6], [7.7, 8.8, 9.9]] + assert awkward1.tolist(array1[2]) == [4.4, 5.5] + assert awkward1.tolist(array1[1:-1]) == [[], [4.4, 5.5], [6.6]] + assert awkward1.tolist(array2) == [[[1.1, 2.2, 3.3], []], [[4.4, 5.5]], [], [[6.6], [7.7, 8.8, 9.9]]] + assert awkward1.tolist(array2[1]) == [[4.4, 5.5]] + assert awkward1.tolist(array2[1:-1]) == [[[4.4, 5.5]], []] + +def test_listarray_at(): + array1 = awkward1.layout.ListArrayU32(starts1, stops1, content) + array2 = awkward1.layout.ListArrayU32(starts2, stops2, array1) + assert awkward1.tolist(array1[2]) == [4.4, 5.5] + assert awkward1.tolist(array1[2,]) == [4.4, 5.5] + assert awkward1.tolist(array1[2, 1:]) == [5.5] + assert awkward1.tolist(array1[2:, 0]) == [4.4, 6.6, 7.7] + assert awkward1.tolist(array1[2:, -1]) == [5.5, 6.6, 9.9] + +def test_listoffsetarray_at(): + array1 = awkward1.layout.ListOffsetArrayU32(offsets1, content) + array2 = awkward1.layout.ListOffsetArrayU32(offsets2, array1) + assert awkward1.tolist(array1[2,]) == [4.4, 5.5] + assert awkward1.tolist(array1[2, 1:]) == [5.5] + assert awkward1.tolist(array1[2:, 0]) == [4.4, 6.6, 7.7] + assert awkward1.tolist(array1[2:, -1]) == [5.5, 6.6, 9.9] + +def test_listarray_slice(): + array1 = awkward1.layout.ListArrayU32(starts1, stops1, content) + array2 = awkward1.layout.ListArrayU32(starts2, stops2, array1) + assert awkward1.tolist(array1[1:-1]) == [[], [4.4, 5.5], [6.6]] + assert awkward1.tolist(array1[1:-1,]) == [[], [4.4, 5.5], [6.6]] + assert awkward1.tolist(array2[1:-1]) == [[[4.4, 5.5]], []] + assert awkward1.tolist(array2[1:-1,]) == [[[4.4, 5.5]], []] + +def test_listoffsetarray_slice(): + array1 = awkward1.layout.ListOffsetArrayU32(offsets1, content) + array2 = awkward1.layout.ListOffsetArrayU32(offsets2, array1) + assert awkward1.tolist(array1[1:-1]) == [[], [4.4, 5.5], [6.6]] + assert awkward1.tolist(array1[1:-1,]) == [[], [4.4, 5.5], [6.6]] + assert awkward1.tolist(array2[1:-1]) == [[[4.4, 5.5]], []] + assert awkward1.tolist(array2[1:-1,]) == [[[4.4, 5.5]], []] + +def test_listarray_slice_slice(): + array1 = awkward1.layout.ListArrayU32(starts1, stops1, content) + array2 = awkward1.layout.ListArrayU32(starts2, stops2, array1) + assert awkward1.tolist(array1[2:]) == [[4.4, 5.5], [6.6], [7.7, 8.8, 9.9]] + assert awkward1.tolist(array1[2:, 1:]) == [[5.5], [], [8.8, 9.9]] + assert awkward1.tolist(array1[2:,:-1]) == [[4.4], [], [7.7, 8.8]] + +def test_listoffsetarray_slice_slice(): + array1 = awkward1.layout.ListOffsetArrayU32(offsets1, content) + array2 = awkward1.layout.ListOffsetArrayU32(offsets2, array1) + assert awkward1.tolist(array1[2:]) == [[4.4, 5.5], [6.6], [7.7, 8.8, 9.9]] + assert awkward1.tolist(array1[2:, 1:]) == [[5.5], [], [8.8, 9.9]] + assert awkward1.tolist(array1[2:,:-1]) == [[4.4], [], [7.7, 8.8]] + +def test_listarray_ellipsis(): + array1 = awkward1.layout.ListArrayU32(starts1, stops1, content) + array2 = awkward1.layout.ListArrayU32(starts2, stops2, array1) + if not py27: + assert awkward1.tolist(array1[Ellipsis, 1:]) == [[2.2, 3.3], [], [5.5], [], [8.8, 9.9]] + assert awkward1.tolist(array2[Ellipsis, 1:]) == [[[2.2, 3.3], []], [[5.5]], [], [[], [8.8, 9.9]]] + +def test_listoffsetarray_ellipsis(): + array1 = awkward1.layout.ListOffsetArrayU32(offsets1, content) + array2 = awkward1.layout.ListOffsetArrayU32(offsets2, array1) + if not py27: + assert awkward1.tolist(array1[Ellipsis, 1:]) == [[2.2, 3.3], [], [5.5], [], [8.8, 9.9]] + assert awkward1.tolist(array2[Ellipsis, 1:]) == [[[2.2, 3.3], []], [[5.5]], [], [[], [8.8, 9.9]]] + +def test_listarray_array_slice(): + array1 = awkward1.layout.ListArrayU32(starts1, stops1, content) + array2 = awkward1.layout.ListArrayU32(starts2, stops2, array1) + assert awkward1.tolist(array2[[0, 0, 1, 1, 1, 0]]) == [[[1.1, 2.2, 3.3], []], [[1.1, 2.2, 3.3], []], [[4.4, 5.5]], [[4.4, 5.5]], [[4.4, 5.5]], [[1.1, 2.2, 3.3], []]] + assert awkward1.tolist(array2[[0, 0, 1, 1, 1, 0], :]) == [[[1.1, 2.2, 3.3], []], [[1.1, 2.2, 3.3], []], [[4.4, 5.5]], [[4.4, 5.5]], [[4.4, 5.5]], [[1.1, 2.2, 3.3], []]] + assert awkward1.tolist(array2[[0, 0, 1, 1, 1, 0], :, 1:]) == [[[2.2, 3.3], []], [[2.2, 3.3], []], [[5.5]], [[5.5]], [[5.5]], [[2.2, 3.3], []]] + +def test_listoffsetarray_array_slice(): + array1 = awkward1.layout.ListOffsetArrayU32(offsets1, content) + array2 = awkward1.layout.ListOffsetArrayU32(offsets2, array1) + assert awkward1.tolist(array2[[0, 0, 1, 1, 1, 0]]) == [[[1.1, 2.2, 3.3], []], [[1.1, 2.2, 3.3], []], [[4.4, 5.5]], [[4.4, 5.5]], [[4.4, 5.5]], [[1.1, 2.2, 3.3], []]] + assert awkward1.tolist(array2[[0, 0, 1, 1, 1, 0], :]) == [[[1.1, 2.2, 3.3], []], [[1.1, 2.2, 3.3], []], [[4.4, 5.5]], [[4.4, 5.5]], [[4.4, 5.5]], [[1.1, 2.2, 3.3], []]] + assert awkward1.tolist(array2[[0, 0, 1, 1, 1, 0], :, 1:]) == [[[2.2, 3.3], []], [[2.2, 3.3], []], [[5.5]], [[5.5]], [[5.5]], [[2.2, 3.3], []]] + +def test_listarray_array(): + array1 = awkward1.layout.ListArrayU32(starts1, stops1, content) + array2 = awkward1.layout.ListArrayU32(starts2, stops2, array1) + assert awkward1.tolist(array1[numpy.array([2, 0, 0, 1, -1])]) == [[4.4, 5.5], [1.1, 2.2, 3.3], [1.1, 2.2, 3.3], [], [7.7, 8.8, 9.9]] + assert awkward1.tolist(array1[numpy.array([2, 0, 0, -1]), numpy.array([1, 1, 0, 0])]) == [5.5, 2.2, 1.1, 7.7] + + content_deep = awkward1.layout.NumpyArray(numpy.array([[0, 0], [1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80]])) + starts1_deep = awkward1.layout.IndexU32(numpy.array([0, 3, 6])) + stops1_deep = awkward1.layout.IndexU32(numpy.array([3, 6, 9])) + array1_deep = awkward1.layout.ListArrayU32(starts1_deep, stops1_deep, content_deep) + + assert awkward1.tolist(array1_deep) == [[[0, 0], [1, 10], [2, 20]], [[3, 30], [4, 40], [5, 50]], [[6, 60], [7, 70], [8, 80]]] + s = (numpy.array([2, 0, 0, -1]), numpy.array([1, 1, 0, 0]), numpy.array([0, 1, 0, 1])) + assert numpy.array([[[0, 0], [1, 10], [2, 20]], [[3, 30], [4, 40], [5, 50]], [[6, 60], [7, 70], [8, 80]]])[s].tolist() == awkward1.tolist(array1_deep[s]) + + s = (numpy.array([2, 0, 0, -1]), numpy.array([1, 1, 0, 0]), slice(1, None)) + assert numpy.array([[[0, 0], [1, 10], [2, 20]], [[3, 30], [4, 40], [5, 50]], [[6, 60], [7, 70], [8, 80]]])[s].tolist() == awkward1.tolist(array1_deep[s]) + +def test_listoffsetarray_array(): + array1 = awkward1.layout.ListOffsetArrayU32(offsets1, content) + array2 = awkward1.layout.ListOffsetArrayU32(offsets2, array1) + assert awkward1.tolist(array1[numpy.array([2, 0, 0, 1, -1])]) == [[4.4, 5.5], [1.1, 2.2, 3.3], [1.1, 2.2, 3.3], [], [7.7, 8.8, 9.9]] + assert awkward1.tolist(array1[numpy.array([2, 0, 0, -1]), numpy.array([1, 1, 0, 0])]) == [5.5, 2.2, 1.1, 7.7] + + content_deep = awkward1.layout.NumpyArray(numpy.array([[0, 0], [1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80]])) + starts1_deep = awkward1.layout.IndexU32(numpy.array([0, 3, 6])) + stops1_deep = awkward1.layout.IndexU32(numpy.array([3, 6, 9])) + array1_deep = awkward1.layout.ListArrayU32(starts1_deep, stops1_deep, content_deep) + + assert awkward1.tolist(array1_deep) == [[[0, 0], [1, 10], [2, 20]], [[3, 30], [4, 40], [5, 50]], [[6, 60], [7, 70], [8, 80]]] + s = (numpy.array([2, 0, 0, -1]), numpy.array([1, 1, 0, 0]), numpy.array([0, 1, 0, 1])) + assert numpy.array([[[0, 0], [1, 10], [2, 20]], [[3, 30], [4, 40], [5, 50]], [[6, 60], [7, 70], [8, 80]]])[s].tolist() == awkward1.tolist(array1_deep[s]) + + s = (numpy.array([2, 0, 0, -1]), numpy.array([1, 1, 0, 0]), slice(1, None)) + assert numpy.array([[[0, 0], [1, 10], [2, 20]], [[3, 30], [4, 40], [5, 50]], [[6, 60], [7, 70], [8, 80]]])[s].tolist() == awkward1.tolist(array1_deep[s]) + +def test_getitem_array_U32(): + content = awkward1.layout.NumpyArray(numpy.array([0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9])) + listarray = awkward1.layout.ListArrayU32(awkward1.layout.IndexU32(numpy.array([0, 3, 3, 5, 6], numpy.uint32)), awkward1.layout.IndexU32(numpy.array([3, 3, 5, 6, 10], numpy.uint32)), content) + + @numba.njit + def f1(q): + return q[[2, 0, 0, 1]] + + assert awkward1.tolist(f1(listarray)) == [[3.3, 4.4], [0.0, 1.1, 2.2], [0.0, 1.1, 2.2], []] + + @numba.njit + def f2(q): + return q[[2, 0, 0, -1], 1] + + assert awkward1.tolist(f2(listarray)) == [4.4, 1.1, 1.1, 7.7] + + @numba.njit + def f3(q): + return q[[2, 0, 0, -1], [-1, -1, 0, 0]] + + assert awkward1.tolist(f3(listarray)) == [4.4, 2.2, 0.0, 6.6] + + listarray.setid() + assert numpy.asarray(f1(listarray).id).tolist() == [[2], [0], [0], [1]] + assert numpy.asarray(f2(listarray).id).tolist() == [[2, 1], [0, 1], [0, 1], [4, 1]] + assert numpy.asarray(f3(listarray).id).tolist() == [[2, 1], [0, 2], [0, 0], [4, 0]] + +def test_deep_listarrayU32(): + content = awkward1.layout.NumpyArray(numpy.arange(2*3*5*7).reshape(-1, 7)) + offsetsA = numpy.arange(0, 2*3*5 + 5, 5) + offsetsB = numpy.arange(0, 2*3 + 3, 3) + startsA, stopsA = offsetsA[:-1], offsetsA[1:] + startsB, stopsB = offsetsB[:-1], offsetsB[1:] + + listarrayAU32 = awkward1.layout.ListArrayU32(awkward1.layout.IndexU32(startsA), awkward1.layout.IndexU32(stopsA), content) + modelA = numpy.arange(2*3*5*7).reshape(2*3, 5, 7) + + listarrayBU32 = awkward1.layout.ListArrayU32(awkward1.layout.IndexU32(startsB), awkward1.layout.IndexU32(stopsB), listarrayAU32) + modelB = numpy.arange(2*3*5*7).reshape(2, 3, 5, 7) + + @numba.njit + def f1(q): + return q[1, 2, 4] + + assert awkward1.tolist(f1(listarrayBU32)) == awkward1.tolist(f1(modelB)) + + @numba.njit + def f2(q): + return q[1, -1, 4, -2] + + assert f2(listarrayBU32) == f2(modelB) + + @numba.njit + def f3(q): + return q[1:, ::2, 1:-1, 5::-1] + + assert awkward1.tolist(f3(listarrayBU32)) == awkward1.tolist(f3(modelB)) + + @numba.njit + def f4(q): + return q[numpy.array([0, 1, 1, 0]), ::2, 1:-1, 5::-1] + + assert awkward1.tolist(f4(listarrayBU32)) == awkward1.tolist(f4(modelB)) + +def test_deep_listoffsetarrayU32(): + content = awkward1.layout.NumpyArray(numpy.arange(2*3*5*7).reshape(-1, 7)) + offsetsA = numpy.arange(0, 2*3*5 + 5, 5) + offsetsB = numpy.arange(0, 2*3 + 3, 3) + + listoffsetarrayAU32 = awkward1.layout.ListOffsetArrayU32(awkward1.layout.IndexU32(offsetsA), content) + modelA = numpy.arange(2*3*5*7).reshape(2*3, 5, 7) + + listoffsetarrayBU32 = awkward1.layout.ListOffsetArrayU32(awkward1.layout.IndexU32(offsetsB), listoffsetarrayAU32) + modelB = numpy.arange(2*3*5*7).reshape(2, 3, 5, 7) + + @numba.njit + def f1(q): + return q[1, 2, 4] + + assert awkward1.tolist(f1(listoffsetarrayBU32)) == awkward1.tolist(f1(modelB)) + + @numba.njit + def f2(q): + return q[1, -1, 4, -2] + + assert f2(listoffsetarrayBU32) == f2(modelB) + + @numba.njit + def f3(q): + return q[1:, ::2, 1:-1, 5::-1] + + assert awkward1.tolist(f3(listoffsetarrayBU32)) == awkward1.tolist(f3(modelB)) + + @numba.njit + def f4(q): + return q[numpy.array([0, 1, 1, 0]), ::2, 1:-1, 5::-1] + + assert awkward1.tolist(f4(listoffsetarrayBU32)) == awkward1.tolist(f4(modelB))