MCPcopy Create free account
hub / github.com/numpy/numpy / test_blocked

Method test_blocked

numpy/core/tests/test_scalarmath.py:156–186  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

_gen_alignment_dataFunction · 0.90
assert_almost_equalFunction · 0.90
divideMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected