(self)
| 159 | class TestBaseMath: |
| 160 | @pytest.mark.xfail(check_support_sve(), reason="gh-22982") |
| 161 | def test_blocked(self): |
| 162 | # test alignments offsets for simd instructions |
| 163 | # alignments for vz + 2 * (vs - 1) + 1 |
| 164 | for dt, sz in [(np.float32, 11), (np.float64, 7), (np.int32, 11)]: |
| 165 | for out, inp1, inp2, msg in _gen_alignment_data(dtype=dt, |
| 166 | type='binary', |
| 167 | max_size=sz): |
| 168 | exp1 = np.ones_like(inp1) |
| 169 | inp1[...] = np.ones_like(inp1) |
| 170 | inp2[...] = np.zeros_like(inp2) |
| 171 | assert_almost_equal(np.add(inp1, inp2), exp1, err_msg=msg) |
| 172 | assert_almost_equal(np.add(inp1, 2), exp1 + 2, err_msg=msg) |
| 173 | assert_almost_equal(np.add(1, inp2), exp1, err_msg=msg) |
| 174 | |
| 175 | np.add(inp1, inp2, out=out) |
| 176 | assert_almost_equal(out, exp1, err_msg=msg) |
| 177 | |
| 178 | inp2[...] += np.arange(inp2.size, dtype=dt) + 1 |
| 179 | assert_almost_equal(np.square(inp2), |
| 180 | np.multiply(inp2, inp2), err_msg=msg) |
| 181 | # skip true divide for ints |
| 182 | if dt != np.int32: |
| 183 | assert_almost_equal(np.reciprocal(inp2), |
| 184 | np.divide(1, inp2), err_msg=msg) |
| 185 | |
| 186 | inp1[...] = np.ones_like(inp1) |
| 187 | np.add(inp1, 2, out=out) |
| 188 | assert_almost_equal(out, exp1 + 2, err_msg=msg) |
| 189 | inp2[...] = np.ones_like(inp2) |
| 190 | np.add(2, inp2, out=out) |
| 191 | assert_almost_equal(out, exp1 + 2, err_msg=msg) |
| 192 | |
| 193 | def test_lower_align(self): |
| 194 | # check data that is not aligned to element size |
nothing calls this directly
no test coverage detected