8000 Temporarily disable __numpy_ufunc__ · numpy/numpy@bac094c · GitHub
[go: up one dir, main page]

Skip to content

Commit bac094c

Browse files
committed
Temporarily disable __numpy_ufunc__
Given that we accidentally released 1.11b2 with `__numpy_ufunc__` still enabled, we should probably just disable it in master for now. When ready to re-enable, grep for NUMPY_UFUNC_DISABLED. Or just revert this commit.
1 parent a9e8c7f commit bac094c

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

numpy/core/src/private/ufunc_override.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ PyUFunc_CheckOverride(PyUFuncObject *ufunc, char *method,
198198
/* Pos of each override in args */
199199
int with_override_pos[NPY_MAXARGS];
200200

201+
/* 2016-01-29: Disable for now in master -- can re-enable once details are
202+
* sorted out. All commented bits are tagged NUMPY_UFUNC_DISABLED. -njs
203+
*/
204+
result = NULL;
205+
return 0;
206+
201207
/*
202208
* Check inputs
203209
*/

numpy/core/tests/test_multiarray.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,6 +2136,9 @@ def test_dot(self):
21362136
assert_equal(c, np.dot(a, b))
21372137

21382138
def test_dot_override(self):
2139+
# 2016-01-29: NUMPY_UFUNC_DISABLED
2140+
return
2141+
21392142
class A(object):
21402143
def __numpy_ufunc__(self, ufunc, method, pos, inputs, **kwargs):
21412144
return "A"
@@ -2543,6 +2546,9 @@ def test_extension_incref_elide_stack(self):
25432546
assert_array_equal(res, l[4] + l[4])
25442547

25452548
def test_ufunc_override_rop_precedence(self):
2549+
# 2016-01-29: NUMPY_UFUNC_DISABLED
2550+
return
2551+
25462552
# Check that __rmul__ and other right-hand operations have
25472553
# precedence over __numpy_ufunc__
25482554

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

26632669
def test_ufunc_override_rop_simple(self):
2670+
# 2016-01-29: NUMPY_UFUNC_DISABLED
2671+
return
2672+
26642673
# Check parts of the binary op overriding behavior in an
26652674
# explicit test case that is easier to understand.
26662675
class SomeClass(object):
@@ -2765,6 +2774,9 @@ def __rsub__(self, other):
27652774
assert_(isinstance(res, SomeClass3))
27662775

27672776
def test_ufunc_override_normalize_signature(self):
2777+
# 2016-01-29: NUMPY_UFUNC_DISABLED
2778+
return
2779+
27682780
# gh-5674
27692781
class SomeClass(object):
27702782
def __numpy_ufunc__(self, ufunc, method, i, inputs, **kw):
@@ -2781,6 +2793,9 @@ def __numpy_ufunc__(self, ufunc, method, i, inputs, **kw):
27812793
assert_equal(kw['signature'], 'ii->i')
27822794

27832795
def test_numpy_ufunc_index(self):
2796+
# 2016-01-29: NUMPY_UFUNC_DISABLED
2797+
return
2798+
27842799
# Check that index is set appropriately, also if only an output
27852800
# is passed on (latter is another regression tests for github bug 4753)
27862801
class CheckIndex(object):
@@ -2818,6 +2833,9 @@ def __numpy_ufunc__(self, ufunc, method, i, inputs, **kw):
28182833
assert_equal(np.add(a, dummy, out=a), 0)
28192834

28202835
def test_out_override(self):
2836+
# 2016-01-29: NUMPY_UFUNC_DISABLED
2837+
return
2838+
28212839
# regression test for github bug 4753
28222840
class OutClass(np.ndarray):
28232841
def __numpy_ufunc__(self, ufunc, method, i, inputs, **kw):
@@ -4875,6 +4893,8 @@ def test_matrix_matrix_values(self):
48754893
assert_equal(res, tgt12_21)
48764894

48774895
def test_numpy_ufunc_override(self):
4896+
# 2016-01-29: NUMPY_UFUNC_DISABLED
4897+
return
48784898

48794899
class A(np.ndarray):
48804900
def __new__(cls, *args, **kwargs):

numpy/core/tests/test_umath.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,24 @@ def __array__(self):
12151215
assert_equal(ncu.maximum(a, B()), 0)
12161216
assert_equal(ncu.maximum(a, C()), 0)
12171217

1218+
def test_ufunc_override_disabled(self):
1219+
# 2016-01-29: NUMPY_UFUNC_DISABLED
1220+
# This test should be removed when __numpy_ufunc__ is re-enabled.
1221+
1222+
class MyArray(object):
1223+
def __numpy_ufunc__(self, *args, **kwargs):
1224+
self._numpy_ufunc_called = True
1225+
1226+
my_array = MyArray()
1227+
real_array = np.ones(10)
1228+
assert_raises(TypeError, lambda: real_array + my_array)
1229+
assert_raises(TypeError, np.add, real_array, my_array)
1230+
assert not hasattr(my_array, "_numpy_ufunc_called")
1231+
1232+
12181233
def test_ufunc_override(self):
1234+
# 2016-01-29: NUMPY_UFUNC_DISABLED
1235+
return
12191236

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

12431260
def test_ufunc_override_mro(self):
1261+
# 2016-01-29: NUMPY_UFUNC_DISABLED
1262+
return
12441263

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

13341353
def test_ufunc_override_methods(self):
1354+
# 2016-01-29: NUMPY_UFUNC_DISABLED
1355+
return
13351356

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

14381459
def test_ufunc_override_out(self):
1460+
# 2016-01-29: NUMPY_UFUNC_DISABLED
1461+
return
14391462

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

14721495
def test_ufunc_override_exception(self):
1496+
# 2016-01-29: NUMPY_UFUNC_DISABLED
1497+
return
14731498

14741499
class A(object):
14751500
def __numpy_ufunc__(self, *a, **kwargs):

0 commit comments

Comments
 (0)
0