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

Method test_float64_pass

numpy/testing/tests/test_utils.py:935–951  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

933class TestArrayAlmostEqualNulp:
934
935 def test_float64_pass(self):
936 # The number of units of least precision
937 # In this case, use a few places above the lowest level (ie nulp=1)
938 nulp = 5
939 x = np.linspace(-20, 20, 50, dtype=np.float64)
940 x = 10**x
941 x = np.r_[-x, x]
942
943 # Addition
944 eps = np.finfo(x.dtype).eps
945 y = x + x*eps*nulp/2.
946 assert_array_almost_equal_nulp(x, y, nulp)
947
948 # Subtraction
949 epsneg = np.finfo(x.dtype).epsneg
950 y = x - x*epsneg*nulp/2.
951 assert_array_almost_equal_nulp(x, y, nulp)
952
953 def test_float64_fail(self):
954 nulp = 5

Callers

nothing calls this directly

Calls 2

linspaceMethod · 0.80

Tested by

no test coverage detected