code: def test_input_ranges():
      # Test we get good precision for a range of input data
      arr = np.arange(-500, 501, 10, dtype=np.float64)
      bio = BytesIO()
      working_type = np.float32
      work_eps = np.finfo(working_type).eps
      for out_type, offset in itertools.product(
          IUINT_TYPES, range(-1000, 1000, 100)
      ):
          aw = SlopeInterArrayWriter(arr, out_type)
          aw.to_fileobj(bio)
          arr2 = array_from_file(arr.shape, out_type, bio)
          arr3 = apply_read_scaling(arr2, aw.slope, aw.inter)
          # Max rounding error for integer type
          # Slope might be negative
          max_miss = (
              np.abs(aw.slope) / working_type(2.0) + work_eps * 10
          )
          abs_err = np.abs(arr - arr3)
          max_err = np.abs(arr) * work_eps + max_miss
          assert np.all(abs_err <= max_err)
          if out_type in UINT_TYPES and 0 in (min(arr), max(arr)):
              # Check that error is minimized for 0 as min or max
              assert min(abs_err) == abs_err[arr == 0]
          bio.truncate(0)
          bio.seek(0)
  
imports: import itertools
  from io import BytesIO
  from platform import machine, python_compiler
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from ..arraywriters import ArrayWriter, ScalingError, SlopeArrayWriter, SlopeInterArrayWriter, WriterError, get_slope_inter, make_array_writer
  from ..casting import int_abs, sctypes, shared_range, type_info
  from ..testing import assert_allclose_safely, suppress_warnings
  from ..volumeutils import _dt_min_max, apply_read_scaling, array_from_file
label_desc: Use image node_id 14 for calling a global function with example usage: test_input_ranges() without return types