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

Method test_roundtrip_half

numpy/core/tests/test_multiarray.py:7914–7931  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

7912 assert_raises(ValueError, self._check_roundtrip, x)
7913
7914 def test_roundtrip_half(self):
7915 half_list = [
7916 1.0,
7917 -2.0,
7918 6.5504 * 10**4, # (max half precision)
7919 2**-14, # ~= 6.10352 * 10**-5 (minimum positive normal)
7920 2**-24, # ~= 5.96046 * 10**-8 (minimum strictly positive subnormal)
7921 0.0,
7922 -0.0,
7923 float('+inf'),
7924 float('-inf'),
7925 0.333251953125, # ~= 1/3
7926 ]
7927
7928 x = np.array(half_list, dtype='>e')
7929 self._check_roundtrip(x)
7930 x = np.array(half_list, dtype='<e')
7931 self._check_roundtrip(x)
7932
7933 def test_roundtrip_single_types(self):
7934 for typ in np.sctypeDict.values():

Callers

nothing calls this directly

Calls 1

_check_roundtripMethod · 0.95

Tested by

no test coverage detected