diff options
author | Egor Panfilov <multicolor.mood@gmail.com> | 2017-06-17 15:11:06 +0300 |
---|---|---|
committer | Egor Panfilov <multicolor.mood@gmail.com> | 2017-06-17 19:51:04 +0300 |
commit | 0bf437fb0ae42fefdb0040692b993f17dedb2e3d (patch) | |
tree | b3b42e6a297537cd50dea01757bbc6c58f2f9ad8 /numpy/lib/function_base.py | |
parent | 1490ccde8215bc6f4720266259672e34ebcda98f (diff) | |
download | numpy-0bf437fb0ae42fefdb0040692b993f17dedb2e3d.tar.gz |
BUG: Switched to xor for bool arrays in diff, added corresponding tests
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 4739b2176..f37d79663 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1,7 +1,6 @@ from __future__ import division, absolute_import, print_function import collections -import operator import re import sys import warnings @@ -1912,10 +1911,16 @@ def diff(a, n=1, axis=-1): slice2[axis] = slice(None, -1) slice1 = tuple(slice1) slice2 = tuple(slice2) + + if a.dtype == np.bool_: + da = a[slice1] ^ a[slice2] + else: + da = a[slice1] - a[slice2] + if n > 1: - return diff(a[slice1]-a[slice2], n-1, axis=axis) + return diff(da, n-1, axis=axis) else: - return a[slice1]-a[slice2] + return da def interp(x, xp, fp, left=None, right=None, period=None): @@ -2061,6 +2066,7 @@ def interp(x, xp, fp, left=None, right=None, period=None): else: return interp_func(x, xp, fp, left, right).item() + def angle(z, deg=0): """ Return the angle of the complex argument. @@ -2083,8 +2089,6 @@ def angle(z, deg=0): arctan2 absolute - - Examples -------- >>> np.angle([1.0, 1.0j, 1+1j]) # in radians |