code: def test_threshold_data():
      data = np.arange(-3, 4)
  
      # Check that an 'auto' threshold leaves at least one element
      data_t, mask, thresh = html_stat_map._threshold_data(
          data, threshold="auto"
      )
      gtruth_m = np.array([False, True, True, True, True, True, False])
      gtruth_d = np.array([-3, 0, 0, 0, 0, 0, 3])
      assert (mask == gtruth_m).all()
      assert (data_t == gtruth_d).all()
  
      # Check that threshold=None keeps everything
      data_t, mask, thresh = html_stat_map._threshold_data(
          data, threshold=None
      )
      assert np.all(np.logical_not(mask))
      assert np.all(data_t == data)
  
      # Check positive threshold works
      data_t, mask, thresh = html_stat_map._threshold_data(
          data, threshold=1
      )
      gtruth = np.array([False, False, True, True, True, False, False])
      assert (mask == gtruth).all()
  
      # Check 0 threshold works
      data_t, mask, thresh = html_stat_map._threshold_data(
          data, threshold=0
      )
      gtruth = np.array(
          [False, False, False, True, False, False, False]
      )
      assert (mask == gtruth).all()
  
      # Check that overly lenient threshold returns array
      data = np.arange(3, 10)
      data_t, mask, thresh = html_stat_map._threshold_data(
          data, threshold=2
      )
      gtruth = np.full(7, False)
      assert (mask == gtruth).all()
  
imports: import base64
  import warnings
  from io import BytesIO
  import numpy
  import pytest
  from matplotlib import pyplot
  from nibabel import Nifti1Image
  from nilearn import datasets, image
  from nilearn.image import get_data, new_img_like
  from nilearn.plotting import html_stat_map
  from ..js_plotting_utils import colorscale
label_desc: Use image node_id 5 for calling a global function with example usage: test_threshold_data() without return types