def get_arrays_from_file(params_file, params=None):
        """Reads the values of one or more parameters from an hdf file and
        returns as a dictionary.

        Parameters
        ----------
        params_file : str
            The hdf file that contains the values of the parameters.
        params : {None, list}
            If provided, will just retrieve the given parameter names.

        Returns
        -------
        dict
            A dictionary of the parameters mapping `param_name -> array`.
        """
        try:
            f = h5py.File(params_file, 'r')
        except:
            raise ValueError('File not found.')
        if params is not None:
            if not isinstance(params, list):
                params = [params]
            for p in params:
                if p not in f.keys():
                    raise ValueError('Parameter {} is not in {}'
                                     .format(p, params_file))
        else:
            params = [str(k) for k in f.keys()]
        params_values = {p:f[p][:] for p in params}
        try:
            bandwidth = f.attrs["bandwidth"]
        except KeyError:
            bandwidth = "scott"

        f.close()
        return params_values, bandwidth
def get_arrays_from_file ( params_file , params = None ) : try : f = h5py . File ( params_file , 'r' ) except : raise ValueError ( 'File not found.' ) if params is not None : if not isinstance ( params , list ) : params = [ params ] for p in params : if p not in f . keys ( ) : raise ValueError ( 'Parameter {} is not in {}' . format ( p , params_file ) ) else : params = [ str ( k ) for k in f . keys ( ) ] params_values = { p : f [ p ] [ : ] for p in params } try : bandwidth = f . attrs [ "bandwidth" ] except KeyError : bandwidth = "scott" f . close ( ) return params_values , bandwidth
Reads the values of one or more parameters from an hdf file and
        returns as a dictionary.

        Parameters
        ----------
        params_file : str
            The hdf file that contains the values of the parameters.
        params : {None, list}
            If provided, will just retrieve the given parameter names.

        Returns
        -------
        dict
            A dictionary of the parameters mapping `param_name -> array`.