def __init__(self, h5json, fname, ext='h5'): """Initialize a PyCode instance. :arg dict h5json: HDF5/JSON content. :arg str fname: Name of the HDF5 file the generated code will create. :arg str ext: Generated HDF5 file's extension. **Without the comma!** """ if len(fname) == 0: raise ValueError('Missing file name.') if 'root' not in h5json: raise KeyError('"root" key not found.') self._h5j = h5json self._dimensions = list() self._dimscales = dict() self._fname = '{}.{}'.format(fname, ext) self._file_var = 'f' self._p = StringStore()
def __init__(self, tinfo, fname, ext='h5'): """Initialize an MCode instance. :arg dict tinfo: Template content information. :arg str fname: Name of the file to use when generating the source code. :arg str ext: HDF5 file extension. **Without the comma!** """ if len(fname) == 0: raise ValueError('Missing file name.') if 'root' not in tinfo: raise KeyError('"root" key not found.') # Helper variables... self._d = tinfo self._root = self._d['root'] self._fname = fname + '.' + ext self._dset_path = dict() # map dataset ID to HDF5 paths self._dimlist = [] # List of dataset IDs that have dimscales attached # Variable for the generated source code... self._m = StringStore()