docstr: Take every finite float16, and check the casting functions with
  a manual conversion.
docstr_tok: ["Take","every","finite","float16",",","and","check","the","casting","functions","with","a","manual","conversion","."]
code: def test_half_correctness(self):
      """Take every finite float16, and check the casting functions with
      a manual conversion."""
  
      # Create an array of all finite float16s
      a_bits = self.finite_f16.view(dtype=uint16)
  
      # Convert to 64-bit float manually
      a_sgn = (-1.0) ** ((a_bits & 0x8000) >> 15)
      a_exp = np.array((a_bits & 0x7C00) >> 10, dtype=np.int32) - 15
      a_man = (a_bits & 0x03FF) * 2.0 ** (-10)
      # Implicit bit of normalized floats
      a_man[a_exp != -15] += 1
      # Denormalized exponent is -14
      a_exp[a_exp == -15] = -14
  
      a_manual = a_sgn * a_man * 2.0**a_exp
  
      a32_fail = np.nonzero(self.finite_f32 != a_manual)[0]
      if len(a32_fail) != 0:
          bad_index = a32_fail[0]
          assert_equal(
              self.finite_f32,
              a_manual,
              "First non-equal is half value 0x%x -> %g != %g"
              % (
                  a_bits[bad_index],
                  self.finite_f32[bad_index],
                  a_manual[bad_index],
              ),
          )
  
      a64_fail = np.nonzero(self.finite_f64 != a_manual)[0]
      if len(a64_fail) != 0:
          bad_index = a64_fail[0]
          assert_equal(
              self.finite_f64,
              a_manual,
              "First non-equal is half value 0x%x -> %g != %g"
              % (
                  a_bits[bad_index],
                  self.finite_f64[bad_index],
                  a_manual[bad_index],
              ),
          )
  
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 10 for calling the TestHalf obj's underlying member method code with example usage: obj.test_half_correctness() without return types