code: def test__ftype4scaled_finite_warningfilters():
      # This test checks our ability to properly manage the thread-unsafe
      # warnings filter list.
  
      # _ftype4scaled_finite always operates on one-or-two element arrays
      # Ensure that an overflow will happen for < float64
      finfo = np.finfo(np.float32)
      tst_arr = np.array((finfo.min, finfo.max), dtype=np.float32)
  
      go = threading.Event()
      stop = threading.Event()
      err = []
  
      class MakeTotalDestroy(threading.Thread):
          def run(self):
              # Restore the warnings filters when we're done testing
              with warnings.catch_warnings():
                  go.set()
                  while not stop.is_set():
                      warnings.filters[:] = []
                      time.sleep(0)
  
      class CheckScaling(threading.Thread):
          def run(self):
              go.wait()
              # Give ourselves a few bites at the apple
              # 200 loops through the function takes ~10ms
              # The highest number of iterations I've seen before hitting interference
              # is 131, with 99% under 30, so this should be reasonably reliable.
              for i in range(200):
                  try:
                      # Use float16 to ensure two failures and increase time in function
                      _ftype4scaled_finite(
                          tst_arr, 2.0, 1.0, default=np.float16
                      )
                  except Exception as e:
                      err.append(e)
                      break
              stop.set()
  
      thread_a = CheckScaling()
      thread_b = MakeTotalDestroy()
      thread_a.start()
      thread_b.start()
      thread_a.join()
      thread_b.join()
  
      if err:
          raise err[0]
  
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 42 for calling a global function with example usage: test__ftype4scaled_finite_warningfilters() without return types