class_docstr: ArrayWriter that can use scalefactor for writing arrays
  
  The scalefactor allows the array writer to write floats to int output
  types, and rescale larger ints to smaller.  It can therefore lose
  precision.
  
  It extends the ArrayWriter class with attribute:
  
  * slope
  
  and methods:
  
  * reset() - reset slope to default (not adapted to self.array)
  * calc_scale() - calculate slope to best write self.array
class_docstr_tok: ["ArrayWriter","that","can","use","scalefactor","for","writing","arrays","The","scalefactor","allows","the","array","writer","to","write","floats","to","int","output","types",",","and","rescale","larger","ints","to","smaller",".","It","can","therefore","lose","precision",".","It","extends","the","ArrayWriter","class","with","attribute",":","*","slope","and","methods",":","*","reset","(",")","-","reset","slope","to","default","(","not","adapted","to","self.array",")","*","calc_scale","(",")","-","calculate","slope","to","best","write","self.array"]
code: def _do_scaling(self):
      arr = self._array
      out_dtype = self._out_dtype
      assert out_dtype.kind in "iu"
      mn, mx = self.finite_range()
      if arr.dtype.kind == "f":
          # Float to (u)int scaling
          # Need to take nan2zero value into account for scaling
          if self._nan2zero and self.has_nan:
              mn = min(mn, 0)
              mx = max(mx, 0)
          self._range_scale(mn, mx)
          return
      # (u)int to (u)int
      info = np.iinfo(out_dtype)
      out_max, out_min = info.max, info.min
      # If left as int64, uint64, comparisons will default to floats, and
      # these are inexact for > 2**53 - so convert to int
      if int(mx) <= int(out_max) and int(mn) >= int(out_min):
          # already in range
          return
      # (u)int to (u)int scaling
      self._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 9 for calling the SlopeArrayWriter obj's underlying member method code with example usage: obj._do_scaling() without return types