docstr: Test np.spacing and np.nextafter
docstr_tok: ["Test","np.spacing","and","np.nextafter"]
code: def test_spacing_nextafter(self):
      """Test np.spacing and np.nextafter"""
      # All non-negative finite #'s
      a = np.arange(0x7C00, dtype=uint16)
      hinf = np.array((np.inf,), dtype=float16)
      hnan = np.array((np.nan,), dtype=float16)
      a_f16 = a.view(dtype=float16)
  
      assert_equal(np.spacing(a_f16[:-1]), a_f16[1:] - a_f16[:-1])
  
      assert_equal(np.nextafter(a_f16[:-1], hinf), a_f16[1:])
      assert_equal(np.nextafter(a_f16[0], -hinf), -a_f16[1])
      assert_equal(np.nextafter(a_f16[1:], -hinf), a_f16[:-1])
  
      assert_equal(np.nextafter(hinf, a_f16), a_f16[-1])
      assert_equal(np.nextafter(-hinf, a_f16), -a_f16[-1])
  
      assert_equal(np.nextafter(hinf, hinf), hinf)
      assert_equal(np.nextafter(hinf, -hinf), a_f16[-1])
      assert_equal(np.nextafter(-hinf, hinf), -a_f16[-1])
      assert_equal(np.nextafter(-hinf, -hinf), -hinf)
  
      assert_equal(np.nextafter(a_f16, hnan), hnan[0])
      assert_equal(np.nextafter(hnan, a_f16), hnan[0])
  
      assert_equal(np.nextafter(hnan, hnan), hnan)
      assert_equal(np.nextafter(hinf, hnan), hnan)
      assert_equal(np.nextafter(hnan, hinf), hnan)
  
      # switch to negatives
      a |= 0x8000
  
      assert_equal(np.spacing(a_f16[0]), np.spacing(a_f16[1]))
      assert_equal(np.spacing(a_f16[1:]), a_f16[:-1] - a_f16[1:])
  
      assert_equal(np.nextafter(a_f16[0], hinf), -a_f16[1])
      assert_equal(np.nextafter(a_f16[1:], hinf), a_f16[:-1])
      assert_equal(np.nextafter(a_f16[:-1], -hinf), a_f16[1:])
  
      assert_equal(np.nextafter(hinf, a_f16), -a_f16[-1])
      assert_equal(np.nextafter(-hinf, a_f16), a_f16[-1])
  
      assert_equal(np.nextafter(a_f16, hnan), hnan[0])
      assert_equal(np.nextafter(hnan, a_f16), hnan[0])
  
imports: import platform
  import pytest
  import numpy
  from numpy import uint16, float16, float32, float64
  from numpy.testing import assert_, assert_equal, _OLD_PROMOTION, IS_WASM
label_desc: Use image node_id 13 for calling the TestHalf obj's underlying member method code with example usage: obj.test_spacing_nextafter() without return types