8000 Temporarily disable __numpy_ufunc__ by njsmith · Pull Request #7147 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Temporarily disable __numpy_ufunc__ #7147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions numpy/core/src/private/ufunc_override.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ PyUFunc_CheckOverride(PyUFuncObject *ufunc, char *method,
/* Pos of each override in args */
int with_override_pos[NPY_MAXARGS];

/* 2016-01-29: Disable for now in master -- can re-enable once details are
* sorted out. All commented bits are tagged NUMPY_UFUNC_DISABLED. -njs
*/
result = NULL;
return 0;

/*
* Check inputs
*/
Expand Down
38 changes: 20 additions & 18 deletions numpy/core/tests/test_multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -2136,6 +2136,9 @@ def test_dot(self):
assert_equal(c, np.dot(a, b))

def test_dot_override(self):
# 2016-01-29: NUMPY_UFUNC_DISABLED
return

class A(object):
def __numpy_ufunc__(self, ufunc, method, pos, inputs, **kwargs):
return "A"
Expand Down Expand Up @@ -2543,6 +2546,9 @@ def test_extension_incref_elide_stack(self):
assert_array_equal(res, l[4] + l[4])

def test_ufunc_override_rop_precedence(self):
# 2016-01-29: NUMPY_UFUNC_DISABLED
return

# Check that __rmul__ and other right-hand operations have
# precedence over __numpy_ufunc__

Expand Down Expand Up @@ -2661,6 +2667,9 @@ def __rop__(self, *other):
yield check, op_name, False

def test_ufunc_override_rop_simple(self):
# 2016-01-29: NUMPY_UFUNC_DISABLED
return

8000 # Check parts of the binary op overriding behavior in an
# explicit test case that is easier to understand.
class SomeClass(object):
Expand Down Expand Up @@ -2765,6 +2774,9 @@ def __rsub__(self, other):
assert_(isinstance(res, SomeClass3))

def test_ufunc_override_normalize_signature(self):
# 2016-01-29: NUMPY_UFUNC_DISABLED
return

# gh-5674
class SomeClass(object):
def __numpy_ufunc__(self, ufunc, method, i, inputs, **kw):
Expand All @@ -2781,6 +2793,9 @@ def __numpy_ufunc__(self, ufunc, method, i, inputs, **kw):
assert_equal(kw['signature'], 'ii->i')

def test_numpy_ufunc_index(self):
# 2016-01-29: NUMPY_UFUNC_DISABLED
return

# Check that index is set appropriately, also if only an output
# is passed on (latter is another regression tests for github bug 4753)
class CheckIndex(object):
Expand Down Expand Up @@ -2818,6 +2833,9 @@ def __numpy_ufunc__(self, ufunc, method, i, inputs, **kw):
assert_equal(np.add(a, dummy, out=a), 0)

def test_out_override(self):
# 2016-01-29: NUMPY_UFUNC_DISABLED
return

# regression test for github bug 4753
class OutClass(np.ndarray):
def __numpy_ufunc__(self, ufunc, method, i, inputs, **kw):
Expand Down Expand Up @@ -4615,24 +4633,6 @@ def test_dot_scalar_and_matrix_of_objects(self):
assert_equal(np.dot(arr, 3), desired)
assert_equal(np.dot(3, arr), desired)

def test_dot_override(self):
class A(object):
def __numpy_ufunc__(self, ufunc, method, pos, inputs, **kwargs):
return "A"

class B(object):
def __numpy_ufunc__(self, ufunc, method, pos, inputs, **kwargs):
return NotImplemented

a = A()
b = B()
c = np.array([[1]])

assert_equal(np.dot(a, b), "A")
assert_equal(c.dot(a), "A")
assert_raises(TypeError, np.dot, b, c)
assert_raises(TypeError, c.dot, b)

def test_accelerate_framework_sgemv_fix(self):

def aligned_array(shape, align, dtype, order='C'):
Expand Down Expand Up @@ -4893,6 +4893,8 @@ def test_matrix_matrix_values(self):
assert_equal(res, tgt12_21)

def test_numpy_ufunc_override(self):
# 2016-01-29: NUMPY_UFUNC_DISABLED
return

class A(np.ndarray):
def __new__(cls, *args, **kwargs):
Expand Down
25 changes: 25 additions & 0 deletions numpy/core/tests/test_umath.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,24 @@ def __array__(self):
assert_equal(ncu.maximum(a, B()), 0)
assert_equal(ncu.maximum(a, C()), 0)

def test_ufunc_override_disabled(self):
# 2016-01-29: NUMPY_UFUNC_DISABLED
# This test should be removed when __numpy_ufunc__ is re-enabled.

class MyArray(object):
def __numpy_ufunc__(self, *args, **kwargs):
self._numpy_ufunc_called = True

my_array = MyArray()
real_array = np.ones(10)
assert_raises(TypeError, lambda: real_array + my_array)
assert_raises(TypeError, np.add, real_array, my_array)
assert not hasattr(my_array, "_numpy_ufunc_called")


def test_ufunc_override(self):
# 2016-01-29: NUMPY_UFUNC_DISABLED
return

class A(object):
def __numpy_ufunc__(self, func, method, pos, inputs, **kwargs):
Expand All @@ -1241,6 +1258,8 @@ def __numpy_ufunc__(self, func, method, pos, inputs, **kwargs):
assert_equal(res1[5], {})

def test_ufunc_override_mro(self):
# 2016-01-29: NUMPY_UFUNC_DISABLED
return

# Some multi arg functions for testing.
def tres_mul(a, b, c):
Expand Down Expand Up @@ -1332,6 +1351,8 @@ def __numpy_ufunc__(self, func, method, pos, inputs, **kwargs):
assert_raises(TypeError, four_mul_ufunc, 1, c, c_sub, c)

def test_ufunc_override_methods(self):
# 2016-01-29: NUMPY_UFUNC_DISABLED
return

class A(object):
def __numpy_ufunc__(self, ufunc, method, pos, inputs, **kwargs):
Expand Down Expand Up @@ -1436,6 +1457,8 @@ def __numpy_ufunc__(self, ufunc, method, pos, inputs, **kwargs):
assert_equal(res[4], (a, [4, 2], 'b0'))

def test_ufunc_override_out(self):
# 2016-01-29: NUMPY_UFUNC_DISABLED
return

class A(object):
def __numpy_ufunc__(self, ufunc, method, pos, inputs, **kwargs):
Expand Down Expand Up @@ -1470,6 +1493,8 @@ def __numpy_ufunc__(self, ufunc, method, pos, inputs, **kwargs):
assert_equal(res7['out'][1], 'out1')

def test_ufunc_override_exception(self):
# 2016-01-29: NUMPY_UFUNC_DISABLED
return

class A(object):
def __numpy_ufunc__(self, *a, **kwargs):
Expand Down
0