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

Commit

Permalink
Why, yes it does. But we'll only do that for Windows, okay?
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski committed Nov 19, 2018
1 parent f90bd0a commit 99c5065
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions awkward/array/jagged.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import math
import numbers
import os

import awkward.array.base
import awkward.persist
Expand Down Expand Up @@ -905,7 +906,9 @@ def any(self):
content = self._content != 0

out = awkward.util.numpy.empty(self._starts.shape + content.shape[1:], dtype=content.dtype)
nonterminal = self.offsets[self.offsets != self.offsets[-1]].astype(awkward.util.numpy.int32)
nonterminal = self.offsets[self.offsets != self.offsets[-1]]
if os.name == "nt": # Windows Numpy reduceat requires 32-bit indexes
nonterminal = nonterminal.astype(awkward.util.numpy.int32)
out[:len(nonterminal)] = awkward.util.numpy.logical_or.reduceat(content[self._starts[0]:self._stops[-1]], nonterminal)
out[self.offsets[1:] == self.offsets[:-1]] = False
return out
Expand All @@ -921,7 +924,9 @@ def all(self):
content = self._content != 0

out = awkward.util.numpy.empty(self._starts.shape + content.shape[1:], dtype=content.dtype)
nonterminal = self.offsets[self.offsets != self.offsets[-1]].astype(awkward.util.numpy.int32)
nonterminal = self.offsets[self.offsets != self.offsets[-1]]
if os.name == "nt": # Windows Numpy reduceat requires 32-bit indexes
nonterminal = nonterminal.astype(awkward.util.numpy.int32)
out[:len(nonterminal)] = awkward.util.numpy.logical_and.reduceat(content[self._starts[0]:self._stops[-1]], nonterminal)
out[self.offsets[1:] == self.offsets[:-1]] = True
return out
Expand All @@ -943,7 +948,9 @@ def sum(self):

if self._canuseoffset():
out = awkward.util.numpy.empty(self._starts.shape + content.shape[1:], dtype=content.dtype)
nonterminal = self.offsets[self.offsets != self.offsets[-1]].astype(awkward.util.numpy.int32)
nonterminal = self.offsets[self.offsets != self.offsets[-1]]
if os.name == "nt": # Windows Numpy reduceat requires 32-bit indexes
nonterminal = nonterminal.astype(awkward.util.numpy.int32)
out[:len(nonterminal)] = awkward.util.numpy.add.reduceat(content[self._starts[0]:self._stops[-1]], nonterminal)
out[self.offsets[1:] == self.offsets[:-1]] = 0
return out
Expand All @@ -967,7 +974,9 @@ def prod(self):

if self._canuseoffset():
out = awkward.util.numpy.empty(self._starts.shape + content.shape[1:], dtype=content.dtype)
nonterminal = self.offsets[self.offsets != self.offsets[-1]].astype(awkward.util.numpy.int32)
nonterminal = self.offsets[self.offsets != self.offsets[-1]]
if os.name == "nt": # Windows Numpy reduceat requires 32-bit indexes
nonterminal = nonterminal.astype(awkward.util.numpy.int32)
out[:len(nonterminal)] = awkward.util.numpy.multiply.reduceat(content[self._starts[0]:self._stops[-1]], nonterminal)
out[self.offsets[1:] == self.offsets[:-1]] = 1
return out
Expand Down Expand Up @@ -1026,7 +1035,9 @@ def argmax(self):

def _minmax_offset(self, ismin):
out = awkward.util.numpy.empty(self._starts.shape + self._content.shape[1:], dtype=self._content.dtype)
nonterminal = self.offsets[self.offsets != self.offsets[-1]].astype(awkward.util.numpy.int32)
nonterminal = self.offsets[self.offsets != self.offsets[-1]]
if os.name == "nt": # Windows Numpy reduceat requires 32-bit indexes
nonterminal = nonterminal.astype(awkward.util.numpy.int32)

if ismin:
out[:len(nonterminal)] = awkward.util.numpy.minimum.reduceat(self._content[self._starts[0]:self._stops[-1]], nonterminal)
Expand Down

0 comments on commit 99c5065

Please sign in to comment.