code: def test_type_info():
      # Test routine to get min, max, nmant, nexp
      for dtt in sctypes["int"] + sctypes["uint"]:
          info = np.iinfo(dtt)
          infod = type_info(dtt)
          assert infod == dict(
              min=info.min,
              max=info.max,
              nexp=None,
              nmant=None,
              minexp=None,
              maxexp=None,
              width=np.dtype(dtt).itemsize,
          )
          assert infod["min"].dtype.type == dtt
          assert infod["max"].dtype.type == dtt
      for dtt in IEEE_floats + [np.complex64, np.complex64]:
          infod = type_info(dtt)
          assert dtt2dict(dtt) == infod
          assert infod["min"].dtype.type == dtt
          assert infod["max"].dtype.type == dtt
      # What is longdouble?
      ld_dict = dtt2dict(np.longdouble)
      dbl_dict = dtt2dict(np.float64)
      infod = type_info(np.longdouble)
      vals = tuple(ld_dict[k] for k in ("nmant", "nexp", "width"))
      # Information for PPC head / tail doubles from:
      # https://developer.apple.com/library/mac/#documentation/Darwin/Reference/Manpages/man3/float.3.html
      if vals in (
          (52, 11, 8),  # longdouble is same as double
          (63, 15, 12),  # intel 80 bit
          (63, 15, 16),  # intel 80 bit
          (112, 15, 16),  # real float128
          (106, 11, 16),  # PPC head, tail doubles, expected values
      ):
          pass
      elif vals == (
          105,
          11,
          16,
      ):  # bust info for PPC head / tail longdoubles
          # min and max broken, copy from infod
          ld_dict.update({k: infod[k] for k in ("min", "max")})
      elif vals == (
          1,
          1,
          16,
      ):  # another bust info for PPC head / tail longdoubles
          ld_dict = dbl_dict.copy()
          ld_dict.update(dict(nmant=106, width=16))
      elif vals == (52, 15, 12):
          width = ld_dict["width"]
          ld_dict = dbl_dict.copy()
          ld_dict["width"] = width
      else:
          raise ValueError(
              f"Unexpected float type {np.longdouble} to test"
          )
      assert ld_dict == infod
  
file_path: nibabel/nibabel/tests/test_floating.py
imports: import sys
  from contextlib import nullcontext
  import numpy
  import pytest
  from packaging.version import Version
  from ..casting import FloatingError, _check_maxexp, _check_nmant, ceil_exact, floor_exact, floor_log2, have_binary128, longdouble_precision_improved, ok_floats, on_powerpc, sctypes, type_info
  from ..testing import suppress_warnings
label_desc: Use image node_id 2 for calling a global function with example usage: test_type_info() without return types