docstr: Initialize array writer
  
  Parameters
  ----------
  array : array-like
      array-like object
  out_dtype : None or dtype
      dtype with which `array` will be written.  For this class,
      `out_dtype`` needs to be the same as the dtype of the input `array`
      or a swapped version of the same.
  \*\*kwargs : keyword arguments
      This class processes only:
  
      * nan2zero : bool, optional
        Whether to set NaN values to 0 when writing integer output.
        Defaults to True.  If False, NaNs get converted with numpy
        ``astype``, and the behavior is undefined.  Ignored for floating
        point output.
      * check_scaling : bool, optional
        If True, check if scaling needed and raise error if so. Default
        is True
  
  Examples
  --------
  >>> arr = np.array([0, 255], np.uint8)
  >>> aw = ArrayWriter(arr)
  >>> aw = ArrayWriter(arr, np.int8) #doctest: +IGNORE_EXCEPTION_DETAIL
  Traceback (most recent call last):
      ...
  WriterError: Scaling needed but cannot scale
  >>> aw = ArrayWriter(arr, np.int8, check_scaling=False)
docstr_tok: ["Initialize","array","writer","Parameters","--","--","--","--","--","array",":","array-like","array-like","object","out_dtype",":","None","or","dtype","dtype","with","which","`","array","`","will","be","written",".","For","this","class",",","`","out_dtype","``","needs","to","be","the","same","as","the","dtype","of","the","input","`","array","`","or","a","swapped","version","of","the","same",".","\\","*","\\","*","kwargs",":","keyword","arguments","This","class","processes","only",":","*","nan2zero",":","bool",",","optional","Whether","to","set","NaN","values","to","0","when","writing","integer","output",".","Defaults","to","True",".","If","False",",","NaNs","get","converted","with","numpy","``","astype","``",",","and","the","behavior","is","undefined",".","Ignored","for","floating","point","output",".","*","check_scaling",":","bool",",","optional","If","True",",","check","if","scaling","needed","and","raise","error","if","so",".","Default","is","True","Examples","--","--","--","--",">",">",">","arr","=","np.array","(","[","0",",","255","]",",","np.uint8",")",">",">",">","aw","=","ArrayWriter","(","arr",")",">",">",">","aw","=","ArrayWriter","(","arr",",","np.int8",")","#","doctest",":","+IGNORE_EXCEPTION_DETAIL","Traceback","(","most","recent","call","last",")",":","...","WriterError",":","Scaling","needed","but","can","not","scale",">",">",">","aw","=","ArrayWriter","(","arr",",","np.int8",",","check_scaling=False",")"]
code: def __init__(self, array, out_dtype=None, **kwargs):
      r"""Initialize array writer
  
      Parameters
      ----------
      array : array-like
          array-like object
      out_dtype : None or dtype
          dtype with which `array` will be written.  For this class,
          `out_dtype`` needs to be the same as the dtype of the input `array`
          or a swapped version of the same.
      \*\*kwargs : keyword arguments
          This class processes only:
  
          * nan2zero : bool, optional
            Whether to set NaN values to 0 when writing integer output.
            Defaults to True.  If False, NaNs get converted with numpy
            ``astype``, and the behavior is undefined.  Ignored for floating
            point output.
          * check_scaling : bool, optional
            If True, check if scaling needed and raise error if so. Default
            is True
  
      Examples
      --------
      >>> arr = np.array([0, 255], np.uint8)
      >>> aw = ArrayWriter(arr)
      >>> aw = ArrayWriter(arr, np.int8) #doctest: +IGNORE_EXCEPTION_DETAIL
      Traceback (most recent call last):
          ...
      WriterError: Scaling needed but cannot scale
      >>> aw = ArrayWriter(arr, np.int8, check_scaling=False)
      """
      nan2zero = kwargs.pop("nan2zero", True)
      check_scaling = kwargs.pop("check_scaling", True)
      self._array = np.asanyarray(array)
      arr_dtype = self._array.dtype
      if out_dtype is None:
          out_dtype = arr_dtype
      else:
          out_dtype = np.dtype(out_dtype)
      self._out_dtype = out_dtype
      self._finite_range = None
      self._has_nan = None
      self._nan2zero = nan2zero
      if check_scaling and self.scaling_needed():
          raise WriterError("Scaling needed but cannot scale")
  
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 1 to create a new ArrayWriter object  with example: obj = ArrayWriter(array, out_dtype)