code: def check_arr(test_id, V_in, in_type, out_type, scaling_type):
      arr, arr_dash, slope, inter = check_params(
          V_in, in_type, out_type
      )
      if arr_dash is None:
          # Scaling causes a header or writer error
          return
      nzs = arr != 0  # avoid divide by zero error
      if not np.any(nzs):
          if DEBUG:
              raise ValueError("Array all zero")
          return
      arr = arr[nzs]
      arr_dash_L = arr_dash.astype(BIG_FLOAT)[nzs]
      top = arr - arr_dash_L
      if not np.any(top != 0):
          return
      rel_err = np.abs(top / arr)
      abs_err = np.abs(top)
      if slope == 1:  # integers output, offset only scaling
          if {in_type, out_type} == {np.int64, np.uint64}:
              # Scaling to or from 64 bit ints can go outside range of continuous
              # integers for float64 and thus lose precision; take this into
              # account
              A = arr.astype(float)
              Ai = A - inter
              ulps = [big_bad_ulp(A), big_bad_ulp(Ai)]
              exp_abs_err = np.max(ulps, axis=0)
          else:  # floats can give full precision - no error!
              exp_abs_err = np.zeros_like(abs_err)
          rel_thresh = 0
      else:
          # Error from integer rounding
          inting_err = np.abs(scaling_type(slope) / 2)
          inting_err = inting_err + ulp(inting_err)
          # Error from calculation of inter
          inter_err = ulp(scaling_type(inter))
          # Max abs error from floating point
          with np.errstate(over="ignore"):
              Ai = arr - scaling_type(inter)
          Ais = Ai / scaling_type(slope)
          exp_abs_err = (
              inting_err
              + inter_err
              + (big_bad_ulp(Ai) + big_bad_ulp(Ais))
          )
          # Relative scaling error from calculation of slope
          # This threshold needs to be 2 x larger on windows 32 bit and PPC for
          # some reason
          rel_thresh = ulp(scaling_type(1))
      test_vals = (abs_err <= exp_abs_err) | (rel_err <= rel_thresh)
      this_test = np.all(test_vals)
      if DEBUG:
          abs_fails = abs_err > exp_abs_err
          rel_fails = rel_err > rel_thresh
          all_fails = abs_fails & rel_fails
          if np.any(rel_fails):
              abs_mx_e = abs_err[rel_fails].max()
              exp_abs_mx_e = exp_abs_err[rel_fails].max()
          else:
              abs_mx_e = None
              exp_abs_mx_e = None
          if np.any(abs_fails):
              rel_mx_e = rel_err[abs_fails].max()
          else:
              rel_mx_e = None
          print(
              (
                  test_id,
                  np.dtype(in_type).str,
                  np.dtype(out_type).str,
                  exp_abs_mx_e,
                  abs_mx_e,
                  rel_thresh,
                  rel_mx_e,
                  slope,
                  inter,
              )
          )
          # To help debugging failures with --pdb-failure
          np.nonzero(all_fails)
      assert this_test
  
file_path: nibabel/nibabel/tests/test_round_trip.py
imports: from io import BytesIO
  import numpy
  from numpy.testing import assert_array_equal
  from ..None import Nifti1Header, Nifti1Image
  from ..arraywriters import ScalingError
  from ..casting import best_float, sctypes, type_info, ulp
  from ..spatialimages import HeaderDataError, supported_np_types
label_desc: Use image node_id 6 for calling a global function with example usage: check_arr(test_id, V_in, in_type, out_type, scaling_type) without return types