@requires_h5py
def test_io_stc_h5():
 tempdir = _TempDir()
 stc = _fake_stc()
 assert_raises(ValueError, stc.save, op.join(tempdir, 'tmp'), ftype='foo')
 out_name = op.join(tempdir, 'tmp')
 stc.save(out_name, ftype='h5')
 stc.save(out_name, ftype='h5')
 stc3 = read_source_estimate(out_name)
 stc4 = read_source_estimate((out_name + '-stc.h5'))
 assert_raises(RuntimeError, read_source_estimate, out_name, subject='bar')
 for stc_new in (stc3, stc4):
  assert_equal(stc_new.subject, stc.subject)
  assert_array_equal(stc_new.data, stc.data)
  assert_array_equal(stc_new.tmin, stc.tmin)
  assert_array_equal(stc_new.tstep, stc.tstep)
  assert_equal(len(stc_new.vertices), len(stc.vertices))
  for (v1, v2) in zip(stc_new.vertices, stc.vertices):
   assert_array_equal(v1, v2)

@ requires_h5py def test_io_stc_h5 ( ) : tempdir = _TempDir ( ) stc = _fake_stc ( ) assert_raises ( ValueError , stc . save , op . join ( tempdir , 'tmp' ) , ftype = 'foo' ) out_name = op . join ( tempdir , 'tmp' ) stc . save ( out_name , ftype = 'h5' ) stc . save ( out_name , ftype = 'h5' ) stc3 = read_source_estimate ( out_name ) stc4 = read_source_estimate ( ( out_name + '-stc.h5' ) ) assert_raises ( RuntimeError , read_source_estimate , out_name , subject = 'bar' ) for stc_new in ( stc3 , stc4 ) : assert_equal ( stc_new . subject , stc . subject ) assert_array_equal ( stc_new . data , stc . data ) assert_array_equal ( stc_new . tmin , stc . tmin ) assert_array_equal ( stc_new . tstep , stc . tstep ) assert_equal ( len ( stc_new . vertices ) , len ( stc . vertices ) ) for ( v1 , v2 ) in zip ( stc_new . vertices , stc . vertices ) : assert_array_equal ( v1 , v2 )
test io for stc files using hdf5 .