class_docstr: Array writer that can use slope and intercept to scale array
  
  The writer can subtract an intercept, and divided by a slope, in order to
  be able to convert floating point values into a (u)int range, or to convert
  larger (u)ints to smaller.
  
  It extends the ArrayWriter class with attributes:
  
  * inter
  * slope
  
  and methods:
  
  * reset() - reset inter, slope to default (not adapted to self.array)
  * calc_scale() - calculate inter, slope to best write self.array
class_docstr_tok: ["Array","writer","that","can","use","slope","and","intercept","to","scale","array","The","writer","can","subtract","an","intercept",",","and","divided","by","a","slope",",","in","order","to","be","able","to","convert","floating","point","values","into","a","(","u",")","int","range",",","or","to","convert","larger","(","u",")","ints","to","smaller",".","It","extends","the","ArrayWriter","class","with","attributes",":","*","inter","*","slope","and","methods",":","*","reset","(",")","-","reset","inter",",","slope","to","default","(","not","adapted","to","self.array",")","*","calc_scale","(",")","-","calculate","inter",",","slope","to","best","write","self.array"]
code: def _iu2iu(self):
      # (u)int to (u)int
      mn, mx = (int(v) for v in self.finite_range())
      # range may be greater than the largest integer for this type.
      out_dtype = self._out_dtype
      # Options in this method are scaling using intercept only.  These will
      # have to pass through ``self.scaler_dtype`` (because the intercept is
      # in this type).
      o_min, o_max = (
          int(v) for v in shared_range(self.scaler_dtype, out_dtype)
      )
      type_range = o_max - o_min
      mn2mx = mx - mn
      if mn2mx <= type_range:  # might offset be enough?
          if o_min == 0:  # uint output - take min to 0
              # decrease offset with floor_exact, meaning mn >= t_min after
              # subtraction.  But we may have pushed the data over t_max,
              # which we check below
              inter = floor_exact(mn - o_min, self.scaler_dtype)
          else:  # int output - take midpoint to 0
              # ceil below increases inter, pushing scale up to 0.5 towards
              # -inf, because ints have abs min == abs max + 1
              midpoint = mn + int(np.ceil(mn2mx / 2.0))
              # Floor exact decreases inter, so pulling scaled values more
              # positive. This may make mx - inter > t_max
              inter = floor_exact(midpoint, self.scaler_dtype)
          # Need to check still in range after floor_exact-ing
          int_inter = int(inter)
          assert mn - int_inter >= o_min
          if mx - int_inter <= o_max:
              self.inter = inter
              return
      # Try slope options (sign flip) and then range scaling
      super()._iu2iu()
  
imports: import numpy
  from .casting import best_float, floor_exact, int_abs, shared_range, type_info
  from .volumeutils import array_to_file, finite_range
label_desc: Use image node_id 6 for calling the SlopeInterArrayWriter obj's underlying member method code with example usage: obj._iu2iu() without return types