Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request #77 from lgray/topic_recurse_speed
Browse files Browse the repository at this point in the history
Modifications to speed up recurse in when certain information is known
  • Loading branch information
jpivarski authored Feb 5, 2019
2 parents bcc5954 + cc5f895 commit faa909f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion awkward/array/jagged.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion awkward/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import re

__version__ = "0.8.2"
__version__ = "0.8.3"
version = __version__
version_info = tuple(re.split(r"[-\.]", __version__))

Expand Down

0 comments on commit faa909f

Please sign in to comment.