From 891725dd548afd004a397307cc36b5d271aaa2e2 Mon Sep 17 00:00:00 2001 From: Lindsey Gray Date: Tue, 5 Feb 2019 15:01:03 -0600 Subject: [PATCH 1/3] modifications to speed up recurse --- awkward/array/jagged.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/awkward/array/jagged.py b/awkward/array/jagged.py index fd334209..d31fd6c3 100644 --- a/awkward/array/jagged.py +++ b/awkward/array/jagged.py @@ -879,7 +879,10 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): if parents is None: parents = jaggedarray.parents - good = (parents >= 0) + if self._canuseoffset and len(jaggedarray.starts) > 0 and jaggedarray.starts[0] == 0: + good = None + else: + good = (parents >= 0) def recurse(x): if isinstance(x, awkward.array.objects.ObjectArray): @@ -891,6 +894,13 @@ def recurse(x): content[n] = recurse(x[n]) return content + elif good is None: + if len(x.shape) == 0: + content = self.numpy.full(len(parents), x, dtype=x.dtype) + else: + content = x[parents] + return content + else: content = self.numpy.empty(len(parents), dtype=x.dtype) if len(x.shape) == 0: From be7f9e5586bcee991f45947bc909698aa2ee182f Mon Sep 17 00:00:00 2001 From: Jim Pivarski Date: Tue, 5 Feb 2019 15:23:29 -0600 Subject: [PATCH 2/3] fixed _canuseoffset() --- awkward/array/jagged.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awkward/array/jagged.py b/awkward/array/jagged.py index d31fd6c3..d23b3e34 100644 --- a/awkward/array/jagged.py +++ b/awkward/array/jagged.py @@ -879,7 +879,7 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): if parents is None: parents = jaggedarray.parents - if self._canuseoffset and len(jaggedarray.starts) > 0 and jaggedarray.starts[0] == 0: + if self._canuseoffset() and len(jaggedarray.starts) > 0 and jaggedarray.starts[0] == 0: good = None else: good = (parents >= 0) From cc5f8954c376d464028f56f98b629d10f58ced90 Mon Sep 17 00:00:00 2001 From: Jim Pivarski Date: Tue, 5 Feb 2019 15:33:51 -0600 Subject: [PATCH 3/3] forgot to bump version number --- awkward/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awkward/version.py b/awkward/version.py index c2531635..6ec4af9c 100644 --- a/awkward/version.py +++ b/awkward/version.py @@ -30,7 +30,7 @@ import re -__version__ = "0.8.2" +__version__ = "0.8.3" version = __version__ version_info = tuple(re.split(r"[-\.]", __version__))