Skip to content

Commit

Permalink
Implemented the type tracer for Awkward-Dask. (#1110)
Browse files Browse the repository at this point in the history
* Starting to implement the type tracer for Awkward-Dask.

* Actually testing it.

* It predicts Forms and Types.

* Convenience methods for making typetracers.

* TypeTracer.instance().

* TypeTracerArray.__getitem__(slice).

* Black.

* Through RecordArray.

* Through BitMaskedArray.

* Added checks throughout 0896.

* Rename test-data.yml to kernel-test-data.yml.

* Instrumented tests from #959.

* Instrumented tests from #1031.

* numpy.broadcast_shapes is too new.

* Through 0011_v2-listarray in the v2 tests.

* Python 2.7 needs Ellipsis to be spelled out.

* Through 0020_v2-support-unsigned-indexes in the v2 tests.

* Through 0023_v2-regular-array in the v2 tests.

* Through all slicing in the v2 tests; next is 0070_v2-argmin-and-argmax.

* Through test_0070_v2-argmin-and-argmax.py in the v2 tests; ak.to_list was wrong, and subsequently the reducer implementation.

* First use of 'fill' (had to split into 'fill_zero', 'fill_other').

* Through 0111_v2-jagged-and-masked-getitem in the v2 tests; added nplike.known_shape.

* Through 0115_v2-generic-reducer-operation in the v2 tests.

* Through 1059_v2-localindex in the v2 tests.

* Added typetracer to all v2 tests (where possible).

* Fixed pre-commit.

* Fixed merge.
  • Loading branch information
jpivarski authored Oct 12, 2021
1 parent 0f49cfd commit 7ce1bb9
Show file tree
Hide file tree
Showing 71 changed files with 3,707 additions and 328 deletions.
4 changes: 2 additions & 2 deletions dev/generate-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def readspec():
loadfile = yaml.safe_load(specfile)
indspec = loadfile["kernels"]
data = yaml.safe_load(
open(os.path.join(CURRENT_DIR, "..", "test-data.yml"), "r")
open(os.path.join(CURRENT_DIR, "..", "kernel-test-data.yml"), "r")
)["tests"]
for spec in indspec:
if "def " in spec["definition"]:
Expand Down Expand Up @@ -704,7 +704,7 @@ class Error(ctypes.Structure):

def genunittests():
print("Generating Unit Tests")
datayml = open(os.path.join(CURRENT_DIR, "..", "test-data.yml"), "r")
datayml = open(os.path.join(CURRENT_DIR, "..", "kernel-test-data.yml"), "r")
data = yaml.safe_load(datayml)["unit-tests"]
for function in data:
num = 0
Expand Down
File renamed without changes.
21 changes: 18 additions & 3 deletions src/awkward/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def isint(x):
Returns True if and only if ``x`` is an integer (including NumPy, not
including bool).
"""
return isinstance(x, (int, numbers.Integral, np.integer)) and not isinstance(
x, (bool, np.bool_)
)
return isinstance(
x, (int, numbers.Integral, np.integer, ak._v2._typetracer.Interval)
) and not isinstance(x, (bool, np.bool_))


def isnum(x):
Expand Down Expand Up @@ -348,6 +348,21 @@ def typestrs(behavior):
return out


def gettypestr(parameters, typestrs):
if parameters is not None:
record = parameters.get("__record__")
if record is not None:
typestr = typestrs.get(record)
if typestr is not None:
return typestr
array = parameters.get("__array__")
if array is not None:
typestr = typestrs.get(array)
if typestr is not None:
return typestr
return None


def numba_record_typer(layouttype, behavior):
behavior = Behavior(ak.behavior, behavior)
rec = layouttype.parameters.get("__record__")
Expand Down
1 change: 1 addition & 0 deletions src/awkward/_v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
import awkward._v2.types # noqa: F401
import awkward._v2.forms # noqa: F401
import awkward._v2._slicing # noqa: F401
import awkward._v2._typetracer # noqa: F401
Loading

0 comments on commit 7ce1bb9

Please sign in to comment.