code: def test_a2f_nan2zero_scaling():
      # Check that nan gets translated to the nearest equivalent to zero
      #
      # nan can be represented as zero of we can store (0 - intercept) / divslope
      # in the output data - because reading back the data as `stored_array  * divslope +
      # intercept` will reconstruct zeros for the nans in the original input.
      #
      # Check with array containing nan, matching array containing zero and
      # Array containing zero
      # Array values otherwise not including zero without scaling
      # Same with negative sign
      # Array values including zero before scaling but not after
      bio = BytesIO()
      for in_dt, out_dt, zero_in, inter in itertools.product(
          FLOAT_TYPES, IUINT_TYPES, (True, False), (0, -100)
      ):
          in_info = np.finfo(in_dt)
          out_info = np.iinfo(out_dt)
          mx = min(in_info.max, out_info.max * 2.0, 2**32) + inter
          mn = 0 if zero_in or inter else 100
          vals = [np.nan] + [mn, mx]
          nan_arr = np.array(vals, dtype=in_dt)
          zero_arr = np.nan_to_num(nan_arr)
          with np.errstate(invalid="ignore"):
              back_nan = write_return(
                  nan_arr, bio, np.int64, intercept=inter
              )
              back_zero = write_return(
                  zero_arr, bio, np.int64, intercept=inter
              )
          assert_array_equal(back_nan, back_zero)
  
imports: import bz2
  import functools
  import gzip
  import itertools
  import os
  import tempfile
  import threading
  import time
  import warnings
  from io import BytesIO
  from os.path import exists
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from packaging.version import Version
  from nibabel.testing import assert_allclose_safely, assert_dt_equal, error_warnings, suppress_warnings
  from ..casting import OK_FLOATS, floor_log2, sctypes, shared_range, type_info
  from ..openers import BZ2File, ImageOpener, Opener
  from ..optpkg import optional_package
  from ..tmpdirs import InTemporaryDirectory
  from ..volumeutils import _dt_min_max, _ftype4scaled_finite, _is_compressed_fobj, _write_data, apply_read_scaling, array_from_file, array_to_file, best_write_scale_ftype, better_float_of, fname_ext_ul_case, int_scinter_ftype, make_dt_codes, native_code, rec2dict, seek_tell, shape_zoom_affine, working_type, write_zeros
label_desc: Use image node_id 14 for calling a global function with example usage: test_a2f_nan2zero_scaling() without return types