<s> """<STR_LIT>""" <EOL> import numpy as np <EOL> from nose . tools import assert_true , assert_equal <EOL> from nilearn . _utils . testing import assert_raises_regex , assert_warns <EOL> from nilearn . _utils . extmath import fast_abs_percentile <EOL> from nilearn . _utils . param_validation import check_threshold <EOL> def test_check_threshold ( ) : <EOL> matrix = np . array ( [ [ <NUM_LIT:1.> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT:1.> ] ] ) <EOL> name = '<STR_LIT>' <EOL> wrong_thresholds = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> for wrong_threshold in wrong_thresholds : <EOL> assert_raises_regex ( ValueError , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' . format ( name ) , <EOL> check_threshold , <EOL> wrong_threshold , matrix , <EOL> '<STR_LIT>' , name ) <EOL> threshold = object ( ) <EOL> assert_raises_regex ( TypeError , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' . format ( name ) , <EOL> check_threshold , threshold , matrix , <EOL> '<STR_LIT>' , name ) <EOL> assert_equal ( check_threshold ( <NUM_LIT:2> , matrix , percentile_func = fast_abs_percentile ) , <NUM_LIT:2> ) <EOL> assert_warns ( UserWarning , check_threshold , <NUM_LIT> , matrix , <EOL> percentile_func = fast_abs_percentile ) <EOL> threshold = <NUM_LIT> <EOL> threshold_numpy_scalar = np . float64 ( threshold ) <EOL> assert_equal ( <EOL> check_threshold ( threshold , matrix , percentile_func = fast_abs_percentile ) , <EOL> check_threshold ( threshold_numpy_scalar , matrix , percentile_func = fast_abs_percentile ) ) <EOL> assert_true ( <NUM_LIT:1.> < check_threshold ( "<STR_LIT>" , matrix , <EOL> percentile_func = fast_abs_percentile , <EOL> name = name ) <= <NUM_LIT> ) </s>
