code: def test_check_threshold():
      matrix = np.array([[1.0, 2.0], [2.0, 1.0]])
  
      name = "threshold"
      # few not correctly formatted strings for 'threshold'
      wrong_thresholds = ["0.1", "10", "10.2.3%", "asdf%"]
      for wrong_threshold in wrong_thresholds:
          with pytest.raises(
              ValueError,
              match=f"{name}.+should be a number followed by the percent sign",
          ):
              check_threshold(
                  wrong_threshold, matrix, fast_abs_percentile, name
              )
  
      threshold = object()
      with pytest.raises(
          TypeError,
          match=f"{name}.+should be either a number or a string",
      ):
          check_threshold(threshold, matrix, fast_abs_percentile, name)
  
      # Test threshold as int, threshold=2 should return as it is
      # since it is not string
      assert check_threshold(2, matrix, fast_abs_percentile) == 2
  
      # check whether raises a warning if given threshold is higher than expected
      with pytest.warns(UserWarning):
          check_threshold(3.0, matrix, fast_abs_percentile)
  
      # test with numpy scalar as argument
      threshold = 2.0
      threshold_numpy_scalar = np.float64(threshold)
      assert check_threshold(
          threshold, matrix, fast_abs_percentile
      ) == check_threshold(
          threshold_numpy_scalar, matrix, fast_abs_percentile
      )
  
      # Test for threshold provided as a percentile of the data
      # (str ending with a %)
      assert (
          1.0
          < check_threshold(
              "50%", matrix, fast_abs_percentile, name=name
          )
          <= 2.0
      )
  
file_path: nilearn/nilearn/_utils/tests/test_param_validation.py
imports: import os
  import warnings
  import nibabel
  import numpy
  import pytest
  from sklearn.base import BaseEstimator
  from nilearn._utils.extmath import fast_abs_percentile
  from nilearn._utils.param_validation import MNI152_BRAIN_VOLUME, check_feature_screening, check_threshold, get_mask_volume
label_desc: Use image node_id 1 for calling a global function with example usage: test_check_threshold() without return types