(self)
| 120 | _assert_equal_type_and_value(array, ArrayLike(np.array([1]))) |
| 121 | |
| 122 | def test_opt_out(self): |
| 123 | |
| 124 | class OptOut: |
| 125 | """Object that opts out of __array_ufunc__.""" |
| 126 | __array_ufunc__ = None |
| 127 | |
| 128 | def __add__(self, other): |
| 129 | return self |
| 130 | |
| 131 | def __radd__(self, other): |
| 132 | return self |
| 133 | |
| 134 | array_like = ArrayLike(1) |
| 135 | opt_out = OptOut() |
| 136 | |
| 137 | # supported operations |
| 138 | assert_(array_like + opt_out is opt_out) |
| 139 | assert_(opt_out + array_like is opt_out) |
| 140 | |
| 141 | # not supported |
| 142 | with assert_raises(TypeError): |
| 143 | # don't use the Python default, array_like = array_like + opt_out |
| 144 | array_like += opt_out |
| 145 | with assert_raises(TypeError): |
| 146 | array_like - opt_out |
| 147 | with assert_raises(TypeError): |
| 148 | opt_out - array_like |
| 149 | |
| 150 | def test_subclass(self): |
| 151 |
nothing calls this directly
no test coverage detected