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

Method _test_abs_func

numpy/_core/tests/test_scalarmath.py:750–770  ·  view source on GitHub ↗
(self, absfunc, test_dtype)

Source from the content-addressed store, hash-verified

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

Callers 2

test_builtin_absMethod · 0.95
test_numpy_absMethod · 0.95

Calls 1

assert_equalFunction · 0.90

Tested by

no test coverage detected