docstr: Checks that all 16-bit values survive conversion
  to/from 32-bit and 64-bit float
docstr_tok: ["Checks","that","all","16-bit","values","survive","conversion","to\/from","32-bit","and","64-bit","float"]
code: def test_half_conversions(self):
      """Checks that all 16-bit values survive conversion
      to/from 32-bit and 64-bit float"""
      # Because the underlying routines preserve the NaN bits, every
      # value is preserved when converting to/from other floats.
  
      # Convert from float32 back to float16
      with np.errstate(invalid="ignore"):
          b = np.array(self.all_f32, dtype=float16)
      # avoid testing NaNs due to differ bits wither Q/SNaNs
      b_nn = b == b
      assert_equal(
          self.all_f16[b_nn].view(dtype=uint16),
          b[b_nn].view(dtype=uint16),
      )
  
      # Convert from float64 back to float16
      with np.errstate(invalid="ignore"):
          b = np.array(self.all_f64, dtype=float16)
      b_nn = b == b
      assert_equal(
          self.all_f16[b_nn].view(dtype=uint16),
          b[b_nn].view(dtype=uint16),
      )
  
      # Convert float16 to longdouble and back
      # This doesn't necessarily preserve the extra NaN bits,
      # so exclude NaNs.
      a_ld = np.array(self.nonan_f16, dtype=np.longdouble)
      b = np.array(a_ld, dtype=float16)
      assert_equal(
          self.nonan_f16.view(dtype=uint16), b.view(dtype=uint16)
      )
  
      # Check the range for which all integers can be represented
      i_int = np.arange(-2048, 2049)
      i_f16 = np.array(i_int, dtype=float16)
      j = np.array(i_f16, dtype=int)
      assert_equal(i_int, j)
  
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 2 for calling the TestHalf obj's underlying member method code with example usage: obj.test_half_conversions() without return types