code: def test_finite_range(in_arr, res):
      # Finite range utility function
      assert finite_range(in_arr) == res
      assert finite_range(in_arr, False) == res
      assert finite_range(in_arr, check_nan=False) == res
      has_nan = np.any(np.isnan(in_arr))
      assert finite_range(in_arr, True) == res + (has_nan,)
      assert finite_range(in_arr, check_nan=True) == res + (has_nan,)
      in_arr = np.array(in_arr)
      flat_arr = in_arr.ravel()
      assert finite_range(flat_arr) == res
      assert finite_range(flat_arr, True) == res + (has_nan,)
      # Check float types work as complex
      if in_arr.dtype.kind == "f":
          c_arr = in_arr.astype(np.complex128)
          assert finite_range(c_arr) == res
          assert finite_range(c_arr, True) == res + (has_nan,)
  
file_path: nibabel/nibabel/tests/test_scaling.py
imports: import warnings
  from io import BytesIO
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from ..casting import sctypes, type_info
  from ..testing import suppress_warnings
  from ..volumeutils import apply_read_scaling, array_from_file, array_to_file, finite_range
  from .test_volumeutils import _calculate_scale
label_desc: Use image node_id 1 for calling a global function with example usage: test_finite_range(in_arr, res) without return types