code: def test_array_file_scales(in_type, out_type):
      # Test scaling works for max, min when going from larger to smaller type,
      # and from float to integer.
      bio = BytesIO()
      out_dtype = np.dtype(out_type)
      arr = np.zeros((3,), dtype=in_type)
      info = type_info(in_type)
      arr[0], arr[1] = info["min"], info["max"]
      slope, inter, mn, mx = _calculate_scale(arr, out_dtype, True)
      array_to_file(arr, bio, out_type, 0, inter, slope, mn, mx)
      bio.seek(0)
      arr2 = array_from_file(arr.shape, out_dtype, bio)
      arr3 = apply_read_scaling(arr2, slope, inter)
      # Max rounding error for integer type
      max_miss = slope / 2.0
      assert np.all(np.abs(arr - arr3) <= max_miss)
  
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 5 for calling a global function with example usage: test_array_file_scales(in_type, out_type) without return types