Beispiel #1
0
    def load_dict(self, filename):
        """
        Utility function to load a dictionary `data` from a HDF5 file
        `filename`.
        """
        data = io.read_dict_hdf5(filename)

        return data
    def load_dict(self, filename):
        """
        Utility function to load a dictionary `data` from a HDF5 file
        `filename`.
        """
        data = io.read_dict_hdf5(filename)

        return data
Beispiel #3
0
    def from_file_hdf5(filename):
        obj = Coefficients()
        obj.__dict__ = read_dict_hdf5(filename)
        for key, val in six.iteritems(obj.__dict__):
            if type(val) == list:
                for ii, vv in enumerate(val):
                    val[ii] = nm.array(vv, dtype=nm.float64)

        return obj
Beispiel #4
0
    def from_file_hdf5( filename ):
        obj = Coefficients()
        obj.__dict__ = read_dict_hdf5( filename )
        for key, val in six.iteritems(obj.__dict__):
            if type( val ) == list:
                for ii, vv in enumerate( val ):
                    val[ii] = nm.array( vv, dtype = nm.float64 )

        return obj
Beispiel #5
0
    def test_recursive_dict_hdf5(self):
        from sfepy.base.ioutils import write_dict_hdf5, read_dict_hdf5
        from sfepy.base.ioutils import pt
        if pt is None:
            self.report('skipped (no pytables)')
            return True
        filename = op.join(self.options.out_dir, 'dict.h5')

        test = {'A': 0, 'B': {'C': [0, 1], 'D': {'E': {'F': {'G': 2.0}}}}}

        self.report('%s' % test)
        self.report('saving into %s...' % filename)
        write_dict_hdf5(filename, test)
        self.report('reading...')
        test2 = read_dict_hdf5(filename)
        self.report('%s' % test2)

        assert_(test == test2)

        return True
Beispiel #6
0
    def test_recursive_dict_hdf5( self ):
        from sfepy.base.ioutils import write_dict_hdf5, read_dict_hdf5
        from sfepy.base.ioutils import pt
        if pt is None:
            self.report( 'skipped (no pytables)' )
            return True
        filename = op.join( self.options.out_dir, 'dict.h5' )

        test = {'A' : 0, 'B' : {'C' : [0, 1],
                                'D' : {'E' : {'F' : {'G' : 2.0}}}}}

        self.report( '%s' % test )
        self.report( 'saving into %s...' % filename )
        write_dict_hdf5( filename, test )
        self.report( 'reading...' )
        test2 = read_dict_hdf5( filename )
        self.report( '%s' % test2 )

        assert_( test == test2 )

        return True