#NEWLINE# @ slow_test #NEWLINE# @ testing . requires_testing_data #NEWLINE# @ requires_version ( 'scipy' , '0.11' ) #NEWLINE# def test_add_source_space_distances( ) : #NEWLINE# #INDENT# 'Test adding distances to source space' #NEWLINE# tempdir = _TempDir ( ) #NEWLINE# src = read_source_spaces ( fname ) #NEWLINE# src_new = read_source_spaces ( fname ) #NEWLINE# del src_new [ 0 ] [ 'dist' ] #NEWLINE# del src_new [ 1 ] [ 'dist' ] #NEWLINE# n_do = 19 #NEWLINE# src_new [ 0 ] [ 'vertno' ] = src_new [ 0 ] [ 'vertno' ] [ : n_do ] . copy ( ) #NEWLINE# src_new [ 1 ] [ 'vertno' ] = src_new [ 1 ] [ 'vertno' ] [ : n_do ] . copy ( ) #NEWLINE# out_name = op . join ( tempdir , 'temp-src.fif' ) #NEWLINE# n_jobs = 2 #NEWLINE# assert_true ( ( ( n_do % n_jobs ) != 0 ) ) #NEWLINE# add_source_space_distances ( src_new , n_jobs = n_jobs ) #NEWLINE# write_source_spaces ( out_name , src_new ) #NEWLINE# src_new = read_source_spaces ( out_name ) #NEWLINE# for ( so , sn ) in zip ( src , src_new ) : #NEWLINE# #INDENT# v = so [ 'vertno' ] [ : n_do ] #NEWLINE# assert_array_equal ( so [ 'dist_limit' ] , np . array ( [ ( - 0.007 ) ] , np . float32 ) ) #NEWLINE# assert_array_equal ( sn [ 'dist_limit' ] , np . array ( [ np . inf ] , np . float32 ) ) #NEWLINE# do = so [ 'dist' ] #NEWLINE# dn = sn [ 'dist' ] #NEWLINE# ds = list ( ) #NEWLINE# for d in [ do , dn ] : #NEWLINE# #INDENT# d . data [ ( d . data > 0.007 ) ] = 0 #NEWLINE# d = d [ v ] [ : , v ] #NEWLINE# d . eliminate_zeros ( ) #NEWLINE# ds . append ( d ) #NEWLINE# #UNINDENT# assert_true ( ( np . sum ( ( ds [ 0 ] . data < 0.007 ) ) > 10 ) ) #NEWLINE# d = ( ds [ 0 ] - ds [ 1 ] ) #NEWLINE# assert_allclose ( np . zeros_like ( d . data ) , n_jobs . data , rtol = 0 , atol = 1e-09 )