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 #145 from scikit-hep/issue-144
Browse files Browse the repository at this point in the history
Work-around Numpy's ufunc.reduceat
  • Loading branch information
jpivarski authored Jun 17, 2019
2 parents 1c3cf87 + 827d9fe commit dcab91f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions awkward/array/jagged.py
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,11 @@ def _reduce(self, ufunc, identity, dtype, regularaxis):
content = ufunc.reduce(content, axis=axis)

out = ufunc.reduceat(content, nonterminal)[:len(out)]
if len(out) < len(thyself):
tmp = self.numpy.empty((len(thyself),) + out.shape[1:], dtype=out.dtype)
tmp[:len(out)] = out
out = tmp

out[thyself.starts == thyself.stops] = identity

if regularaxis is None:
Expand Down
2 changes: 1 addition & 1 deletion awkward/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import re

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

Expand Down
6 changes: 6 additions & 0 deletions tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ def test_issue49(self):
a = JaggedArray([2], [5], [1, 2, 3, 4, 5])
m = JaggedArray([0], [3], [False, False, True])
assert a[m].tolist() == [[5]]

def test_issue144(self):
x = fromiter([[], [0.5], [0.6], []])
isloose = fromiter([[], [False], [True], []])
assert x[isloose].tolist() == [[], [], [0.6], []]
assert x.sum().tolist() == [0.0, 0.5, 0.6, 0.0]

0 comments on commit dcab91f

Please sign in to comment.