code: def _check_write_scaling(
      self, slope, inter, effective_slope, effective_inter
  ):
      # Test that explicit set of slope / inter forces write of data using
      # this slope, inter.  We use this helper function for children of the
      # Analyze header
      img_class = self.image_class
      arr = np.arange(24, dtype=np.float32).reshape((2, 3, 4))
      # We're going to test rounding later
      arr[0, 0, 0] = 0.4
      arr[1, 0, 0] = 0.6
      aff = np.eye(4)
      # Implicit header gives scale-me scaling
      img = img_class(arr, aff)
      self.assert_scale_me_scaling(img.header)
      # Input header scaling reset when creating image
      hdr = img.header
      self._set_raw_scaling(hdr, slope, inter)
      img = img_class(arr, aff)
      self.assert_scale_me_scaling(img.header)
      # Array from image unchanged by scaling
      assert_array_equal(img.get_fdata(), arr)
      # As does round trip
      img_rt = bytesio_round_trip(img)
      self.assert_scale_me_scaling(img_rt.header)
      # Round trip array is not scaled
      assert_array_equal(img_rt.get_fdata(), arr)
      # Explicit scaling causes scaling after round trip
      self._set_raw_scaling(img.header, slope, inter)
      self.assert_scaling_equal(img.header, slope, inter)
      # Array from image unchanged by scaling
      assert_array_equal(img.get_fdata(), arr)
      # But the array scaled after round trip
      img_rt = bytesio_round_trip(img)
      assert_array_equal(
          img_rt.get_fdata(),
          apply_read_scaling(arr, effective_slope, effective_inter),
      )
      # The scaling set into the array proxy
      do_slope, do_inter = img.header.get_slope_inter()
      assert_array_equal(
          img_rt.dataobj.slope, 1 if do_slope is None else do_slope
      )
      assert_array_equal(
          img_rt.dataobj.inter, 0 if do_inter is None else do_inter
      )
      # The new header scaling has been reset
      self.assert_scale_me_scaling(img_rt.header)
      # But the original is the same as it was when we set it
      self.assert_scaling_equal(img.header, slope, inter)
      # The data gets rounded nicely if we need to do conversion
      img.header.set_data_dtype(np.uint8)
      with np.errstate(invalid="ignore"):
          img_rt = bytesio_round_trip(img)
      assert_array_equal(
          img_rt.get_fdata(),
          apply_read_scaling(
              np.round(arr), effective_slope, effective_inter
          ),
      )
      # But we have to clip too
      arr[-1, -1, -1] = 256
      arr[-2, -1, -1] = -1
      with np.errstate(invalid="ignore"):
          img_rt = bytesio_round_trip(img)
      exp_unscaled_arr = np.clip(np.round(arr), 0, 255)
      assert_array_equal(
          img_rt.get_fdata(),
          apply_read_scaling(
              exp_unscaled_arr, effective_slope, effective_inter
          ),
      )
  
imports: import itertools
  import unittest
  from io import BytesIO
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from ..optpkg import optional_package
  from ..casting import sctypes_aliases, shared_range, type_info
  from ..spatialimages import HeaderDataError
  from ..spm99analyze import HeaderTypeError, Spm99AnalyzeHeader, Spm99AnalyzeImage
  from ..testing import assert_allclose_safely, bytesio_filemap, bytesio_round_trip, suppress_warnings
  from ..volumeutils import _dt_min_max, apply_read_scaling
  from .None import test_analyze
label_desc: Use image node_id 7 for calling the ImageScalingMixin obj's underlying member method code with example usage: obj._check_write_scaling(slope, inter, effective_slope, effective_inter) without return types