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

Method _test_abs_func

numpy/core/tests/test_scalarmath.py:751–771  ·  view source on GitHub ↗
(self, absfunc, test_dtype)

Source from the content-addressed store, hash-verified

749
750class TestAbs:
751 def _test_abs_func(self, absfunc, test_dtype):
752 x = test_dtype(-1.5)
753 assert_equal(absfunc(x), 1.5)
754 x = test_dtype(0.0)
755 res = absfunc(x)
756 # assert_equal() checks zero signedness
757 assert_equal(res, 0.0)
758 x = test_dtype(-0.0)
759 res = absfunc(x)
760 assert_equal(res, 0.0)
761
762 x = test_dtype(np.finfo(test_dtype).max)
763 assert_equal(absfunc(x), x.real)
764
765 with suppress_warnings() as sup:
766 sup.filter(UserWarning)
767 x = test_dtype(np.finfo(test_dtype).tiny)
768 assert_equal(absfunc(x), x.real)
769
770 x = test_dtype(np.finfo(test_dtype).min)
771 assert_equal(absfunc(x), -x.real)
772
773 @pytest.mark.parametrize("dtype", floating_types + complex_floating_types)
774 def test_builtin_abs(self, dtype):

Callers 2

test_builtin_absMethod · 0.95
test_numpy_absMethod · 0.95

Calls 3

assert_equalFunction · 0.90
suppress_warningsClass · 0.90
filterMethod · 0.80

Tested by

no test coverage detected