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

Method test_abs_neg_blocked

numpy/core/tests/test_umath.py:2843–2870  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2841
2842class TestAbsoluteNegative:
2843 def test_abs_neg_blocked(self):
2844 # simd tests on abs, test all alignments for vz + 2 * (vs - 1) + 1
2845 for dt, sz in [(np.float32, 11), (np.float64, 5)]:
2846 for out, inp, msg in _gen_alignment_data(dtype=dt, type='unary',
2847 max_size=sz):
2848 tgt = [ncu.absolute(i) for i in inp]
2849 np.absolute(inp, out=out)
2850 assert_equal(out, tgt, err_msg=msg)
2851 assert_((out >= 0).all())
2852
2853 tgt = [-1*(i) for i in inp]
2854 np.negative(inp, out=out)
2855 assert_equal(out, tgt, err_msg=msg)
2856
2857 for v in [np.nan, -np.inf, np.inf]:
2858 for i in range(inp.size):
2859 d = np.arange(inp.size, dtype=dt)
2860 inp[:] = -d
2861 inp[i] = v
2862 d[i] = -v if v == -np.inf else v
2863 assert_array_equal(np.abs(inp), d, err_msg=msg)
2864 np.abs(inp, out=out)
2865 assert_array_equal(out, d, err_msg=msg)
2866
2867 assert_array_equal(-inp, -1*inp, err_msg=msg)
2868 d = -1 * inp
2869 np.negative(inp, out=out)
2870 assert_array_equal(out, d, err_msg=msg)
2871
2872 def test_lower_align(self):
2873 # 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