MCPcopy Index your code
hub / github.com/numpy/numpy / test_abs_neg_blocked

Method test_abs_neg_blocked

numpy/_core/tests/test_umath.py:3136–3163  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3134
3135class TestAbsoluteNegative:
3136 def test_abs_neg_blocked(self):
3137 # simd tests on abs, test all alignments for vz + 2 * (vs - 1) + 1
3138 for dt, sz in [(np.float32, 11), (np.float64, 5)]:
3139 for out, inp, msg in _gen_alignment_data(dtype=dt, type='unary',
3140 max_size=sz):
3141 tgt = [ncu.absolute(i) for i in inp]
3142 np.absolute(inp, out=out)
3143 assert_equal(out, tgt, err_msg=msg)
3144 assert_((out >= 0).all())
3145
3146 tgt = [-1 * (i) for i in inp]
3147 np.negative(inp, out=out)
3148 assert_equal(out, tgt, err_msg=msg)
3149
3150 for v in [np.nan, -np.inf, np.inf]:
3151 for i in range(inp.size):
3152 d = np.arange(inp.size, dtype=dt)
3153 inp[:] = -d
3154 inp[i] = v
3155 d[i] = -v if v == -np.inf else v
3156 assert_array_equal(np.abs(inp), d, err_msg=msg)
3157 np.abs(inp, out=out)
3158 assert_array_equal(out, d, err_msg=msg)
3159
3160 assert_array_equal(-inp, -1 * inp, err_msg=msg)
3161 d = -1 * inp
3162 np.negative(inp, out=out)
3163 assert_array_equal(out, d, err_msg=msg)
3164
3165 def test_lower_align(self):
3166 # check data that is not aligned to element size

Callers

nothing calls this directly

Calls 5

_gen_alignment_dataFunction · 0.90
assert_equalFunction · 0.90
assert_Function · 0.90
assert_array_equalFunction · 0.90
allMethod · 0.45

Tested by

no test coverage detected