Exemple #1
0
    def do_writing(self, filename, group='root'):
        """
        Parameters
        ----------
        filename: str
        """
        h5file = h5py.File(filename, 'w')
        h5file_group = h5file.create_group(group)
        h5file_group.attrs.update(remove_nones(self.metadata))

        for dataname, dataset in self.datasets.items():
            h5file_group.create_dataset(dataname,
                                        data=dataset,
                                        dtype=dataset.dtype,
                                        compression="gzip")
Exemple #2
0
def dict_serialize(dict_instance: Dict[str, Any]) -> 'IOData':
    """
    Create an IOData instance from dictionary data.
    """
    import scqubits.io_utils.fileio as io
    dict_instance = utils.remove_nones(dict_instance)
    attributes: Dict[str, Any] = {}
    ndarrays: Dict[str, ndarray] = {}
    objects: Dict[str, object] = {}
    typename = 'dict'

    for name, content in dict_instance.items():
        update_func = type_dispatch(content)
        attributes, ndarrays, objects = update_func(name, content, attributes,
                                                    ndarrays, objects)
    return io.IOData(typename, attributes, ndarrays, objects)
Exemple #3
0
def dict_serialize(dict_instance):
    """
    Create an IOData instance from dictionary data.

    Parameters
    ----------
    dict_instance: dict

    Returns
    -------
    IOData
    """
    import scqubits.utils.file_io as io
    dict_instance = utils.remove_nones(dict_instance)
    attributes = {}
    ndarrays = {}
    objects = {}
    typename = 'dict'

    for name, content in dict_instance.items():
        update_func = type_dispatch(content)
        attributes, ndarrays, objects = update_func(name, content, attributes, ndarrays, objects)
    return io.IOData(typename, attributes, ndarrays, objects)