code: def test_half_fpe(self):
      with np.errstate(all="raise"):
          sx16 = np.array((1e-4,), dtype=float16)
          bx16 = np.array((1e4,), dtype=float16)
          sy16 = float16(1e-4)
          by16 = float16(1e4)
  
          # Underflow errors
          assert_raises_fpe("underflow", lambda a, b: a * b, sx16, sx16)
          assert_raises_fpe("underflow", lambda a, b: a * b, sx16, sy16)
          assert_raises_fpe("underflow", lambda a, b: a * b, sy16, sx16)
          assert_raises_fpe("underflow", lambda a, b: a * b, sy16, sy16)
          assert_raises_fpe("underflow", lambda a, b: a / b, sx16, bx16)
          assert_raises_fpe("underflow", lambda a, b: a / b, sx16, by16)
          assert_raises_fpe("underflow", lambda a, b: a / b, sy16, bx16)
          assert_raises_fpe("underflow", lambda a, b: a / b, sy16, by16)
          assert_raises_fpe(
              "underflow",
              lambda a, b: a / b,
              float16(2.0**-14),
              float16(2**11),
          )
          assert_raises_fpe(
              "underflow",
              lambda a, b: a / b,
              float16(-(2.0**-14)),
              float16(2**11),
          )
          assert_raises_fpe(
              "underflow",
              lambda a, b: a / b,
              float16(2.0**-14 + 2**-24),
              float16(2),
          )
          assert_raises_fpe(
              "underflow",
              lambda a, b: a / b,
              float16(-(2.0**-14) - 2**-24),
              float16(2),
          )
          assert_raises_fpe(
              "underflow",
              lambda a, b: a / b,
              float16(2.0**-14 + 2**-23),
              float16(4),
          )
  
          # Overflow errors
          assert_raises_fpe("overflow", lambda a, b: a * b, bx16, bx16)
          assert_raises_fpe("overflow", lambda a, b: a * b, bx16, by16)
          assert_raises_fpe("overflow", lambda a, b: a * b, by16, bx16)
          assert_raises_fpe("overflow", lambda a, b: a * b, by16, by16)
          assert_raises_fpe("overflow", lambda a, b: a / b, bx16, sx16)
          assert_raises_fpe("overflow", lambda a, b: a / b, bx16, sy16)
          assert_raises_fpe("overflow", lambda a, b: a / b, by16, sx16)
          assert_raises_fpe("overflow", lambda a, b: a / b, by16, sy16)
          assert_raises_fpe(
              "overflow",
              lambda a, b: a + b,
              float16(65504),
              float16(17),
          )
          assert_raises_fpe(
              "overflow",
              lambda a, b: a - b,
              float16(-65504),
              float16(17),
          )
          assert_raises_fpe(
              "overflow", np.nextafter, float16(65504), float16(np.inf)
          )
          assert_raises_fpe(
              "overflow",
              np.nextafter,
              float16(-65504),
              float16(-np.inf),
          )
          assert_raises_fpe("overflow", np.spacing, float16(65504))
  
          # Invalid value errors
          assert_raises_fpe(
              "invalid", np.divide, float16(np.inf), float16(np.inf)
          )
          assert_raises_fpe("invalid", np.spacing, float16(np.inf))
          assert_raises_fpe("invalid", np.spacing, float16(np.nan))
  
          # These should not raise
          float16(65472) + float16(32)
          float16(2**-13) / float16(2)
          float16(2**-14) / float16(2**10)
          np.spacing(float16(-65504))
          np.nextafter(float16(65504), float16(-np.inf))
          np.nextafter(float16(-65504), float16(np.inf))
          np.nextafter(float16(np.inf), float16(0))
          np.nextafter(float16(-np.inf), float16(0))
          np.nextafter(float16(0), float16(np.nan))
          np.nextafter(float16(np.nan), float16(0))
          float16(2**-14) / float16(2**10)
          float16(-(2**-14)) / float16(2**10)
          float16(2**-14 + 2**-23) / float16(2)
          float16(-(2**-14) - 2**-23) / float16(2)
  
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 16 for calling the TestHalf obj's underlying member method code with example usage: obj.test_half_fpe() without return types