@requires_version('scipy', '0.11')
def test_add_patch_info():
 src = read_source_spaces(fname_small)
 src_new = read_source_spaces(fname_small)
 for s in src_new:
  s['nearest'] = None
  s['nearest_dist'] = None
  s['pinfo'] = None
 try:
  add_source_space_distances(src_new, dist_limit=1e-05)
 except RuntimeError:
  pass
 else:
  assert_true(all(((s['nearest'] is None) for s in src_new)))
  assert_true(all(((s['nearest_dist'] is None) for s in src_new)))
  assert_true(all(((s['pinfo'] is None) for s in src_new)))
 add_source_space_distances(src_new)
 for (s1, s2) in zip(src, src_new):
  assert_array_equal(s1['nearest'], s2['nearest'])
  assert_allclose(s1['nearest_dist'], s2['nearest_dist'], atol=1e-07)
  assert_equal(len(s1['pinfo']), len(s2['pinfo']))
  for (p1, p2) in zip(s1['pinfo'], s2['pinfo']):
   assert_array_equal(p1, p2)

@ requires_version ( 'scipy' , '0.11' ) def test_add_patch_info ( ) : src = read_source_spaces ( fname_small ) src_new = read_source_spaces ( fname_small ) for s in src_new : s [ 'nearest' ] = None s [ 'nearest_dist' ] = None s [ 'pinfo' ] = None try : add_source_space_distances ( src_new , dist_limit = 1e-05 ) except RuntimeError : pass else : assert_true ( all ( ( ( s [ 'nearest' ] is None ) for s in src_new ) ) ) assert_true ( all ( ( ( s [ 'nearest_dist' ] is None ) for s in src_new ) ) ) assert_true ( all ( ( ( s [ 'pinfo' ] is None ) for s in src_new ) ) ) add_source_space_distances ( src_new ) for ( s1 , s2 ) in zip ( src , src_new ) : assert_array_equal ( s1 [ 'nearest' ] , s2 [ 'nearest' ] ) assert_allclose ( s1 [ 'nearest_dist' ] , s2 [ 'nearest_dist' ] , atol = 1e-07 ) assert_equal ( len ( s1 [ 'pinfo' ] ) , len ( s2 [ 'pinfo' ] ) ) for ( p1 , p2 ) in zip ( s1 [ 'pinfo' ] , s2 [ 'pinfo' ] ) : assert_array_equal ( p1 , p2 )
test adding patch info to source space .