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

Commit

Permalink
functions of one argument should apply to the whole array, not the fi…
Browse files Browse the repository at this point in the history
…rst Table field
  • Loading branch information
jpivarski committed Aug 30, 2018
1 parent 0391fa7 commit a7350e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions awkward/array/jagged.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import collections
import math
import numbers
import types

import awkward.array.base
import awkward.type
Expand Down Expand Up @@ -343,7 +344,7 @@ def base(self):
return self._content.base

def _argfields(self, function):
if isinstance(self._content, awkward.util.numpy.ndarray):
if (isinstance(function, types.FunctionType) and function.__code__.co_argcount == 1) or isinstance(self._content, awkward.util.numpy.ndarray):
return awkward.util._argfields(function)
else:
return self._content._argfields(function)
Expand Down Expand Up @@ -452,7 +453,10 @@ def __getitem__(self, where):
offsets = counts2offsets(intheadsum)

return self.copy(starts=offsets[:-1].reshape(intheadsum.shape), stops=offsets[1:].reshape(intheadsum.shape), content=thyself._content[head._content])


elif len(head.shape) == 1:
raise TypeError("jagged index must be boolean (mask) or integer (fancy indexing)")

else:
# the other cases are possible, but complicated; the first sets the form
raise NotImplementedError("jagged index content type: {0}".format(head._content.dtype))
Expand Down
3 changes: 2 additions & 1 deletion awkward/array/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import numbers
import types

import awkward.array.base
import awkward.util
Expand Down Expand Up @@ -174,7 +175,7 @@ def base(self):
return self._content.base

def _argfields(self, function):
if isinstance(self._content, awkward.util.numpy.ndarray):
if (isinstance(function, types.FunctionType) and function.__code__.co_argcount == 1) or isinstance(self._content, awkward.util.numpy.ndarray):
return awkward.util._argfields(function)
else:
return self._content._argfields(function)
Expand Down

0 comments on commit a7350e9

Please sign in to comment.