def write_tvb_to_h5(self, datatype, path=None, recursive=True, force_overwrite=True): if path is None: path = self.config.out.FOLDER_RES if path.endswith("h5"): # It is a file path: dirpath = os.path.dirname(path) if os.path.isdir(dirpath): path = change_filename_or_overwrite(path, force_overwrite) else: os.mkdir(dirpath) h5.store(datatype, path, recursive) else: if not os.path.isdir(path): os.mkdir(path) from tvb_scripts.datatypes.head import Head if isinstance(datatype, Head): path = os.path.join(path, datatype.title) if not os.path.isdir(path): os.mkdir(path) path = os.path.join(path, "Head.h5") else: path = os.path.join(path, datatype.title + ".h5") path = change_filename_or_overwrite(path, self.force_overwrite) h5.store(datatype, path, recursive) return path
def test_store_load(tmpdir, connectivity_factory): path = os.path.join(str(tmpdir), 'interface.conn.h5') connectivity = connectivity_factory(2) store(connectivity, path) con2 = load(path) numpy.testing.assert_equal(connectivity.weights, con2.weights)