numpy.save

Here are the examples of the python api numpy.save taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

173 Examples 7

Example 1

View license
def convert_dataset(path):
    #path = os.path.join(path, 'cifar-10-batches-py')
    train_X, train_y, test_X, test_y = load_dataset(path)

    print 'Saving data to .npy files.'
    numpy.save(os.path.join(path, 'train_X.npy'), train_X)
    numpy.save(os.path.join(path, 'train_y.npy'), train_y)
    numpy.save(os.path.join(path, 'test_X.npy'), test_X)
    numpy.save(os.path.join(path, 'test_y.npy'), test_y)

Example 2

Project: modl
Source File: hcp.py
View license
def _single_mask(masker, img, dest_data_dir, data_dir):
    dest_file = img.replace('HCP', 'HCP_unmasked')
    dest_file = dest_file.replace('.nii.gz', '')
    dest_dir = os.path.abspath(os.path.join(dest_file, os.pardir))
    if not os.path.exists(dest_dir):
        os.makedirs(dest_dir)
    print('Unmasking %s' % img)
    data = masker.transform(img)
    np.save(dest_file, data)
    origin = dict(array=dest_file + '.npy', img=img)
    with open(join(dest_dir, 'origin.json'), 'w+') as f:
        json.dump(origin, f)

Example 3

Project: chainer
Source File: npz.py
View license
def save(file, arr):
    """Saves an array to a binary file in ``.npy`` format.

    Args:
        file (file or str): File or filename to save.
        arr (array_like): Array to save. It should be able to feed to
            :func:`cupy.asnumpy`.

    .. seealso:: :func:`numpy.save`

    """
    numpy.save(file, cupy.asnumpy(arr))

Example 4

Project: chainer
Source File: compute_mean.py
View license
def main():
    parser = argparse.ArgumentParser(description='Compute images mean array')
    parser.add_argument('dataset',
                        help='Path to training image-label list file')
    parser.add_argument('--root', '-R', default='.',
                        help='Root directory path of image files')
    parser.add_argument('--output', '-o', default='mean.npy',
                        help='path to output mean array')
    args = parser.parse_args()

    dataset = chainer.datasets.LabeledImageDataset(args.dataset, args.root)
    mean = compute_mean(dataset)
    np.save(args.output, mean)

Example 5

Project: cupy
Source File: npz.py
View license
def save(file, arr):
    """Saves an array to a binary file in ``.npy`` format.

    Args:
        file (file or str): File or filename to save.
        arr (array_like): Array to save. It should be able to feed to
            :func:`cupy.asnumpy`.

    .. seealso:: :func:`numpy.save`

    """
    numpy.save(file, cupy.asnumpy(arr))

Example 6

Project: pyunicorn
Source File: map_plots.py
View license
    def add_multiple_datasets_npy(self, map_number, title, data):
        """
        Method for very large data sets (RAM issues) and useful for PARALLEL
        code. Data is copied to npy files (titles still in the list) that
        can be loaded afterwards.

        INPUT: title a string describing the data set
               data a Numpy array containing the map to be drawn
        """
        if map_number > len(self.map_mult_data) - 1:
            self.map_mult_data.append([])
        self.map_mult_data[map_number].append(title)

        np.save(str(map_number) + "_" + title, data)

Example 7

Project: tensorpack
Source File: varmanip.py
View license
def dump_session_params(path):
    """ Dump value of all trainable + to_save variables to a dict and save to `path` as
    npy format, loadable by ParamRestore
    """
    var = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES)
    var.extend(tf.get_collection(EXTRA_SAVE_VARS_KEY))
    result = {}
    for v in var:
        name = get_savename_from_varname(v.name)
        if name in result:
            logger.info("Variable {} would be stored instead of another with \
the same name".format(v.name))
        result[name] = v.eval()
    logger.info("Variables to save to {}:".format(path))
    logger.info(str(result.keys()))
    np.save(path, result)

Example 8

Project: heamy
Source File: cache.py
View license
    def store(self, key, data):
        """Takes an array and stores it in the cache."""
        if not os.path.exists(self._hash_dir):
            os.makedirs(self._hash_dir)

        if isinstance(data, pd.DataFrame):
            columns = data.columns.tolist()
            np.save(os.path.join(self._hash_dir, key), data.values)
            json.dump(columns, open(os.path.join(self._hash_dir, '%s.json' % key), 'w'))
        else:
            np.save(os.path.join(self._hash_dir, key), data)

Example 9

Project: panns
Source File: index.py
View license
    def save(self, fname='panns.idx', mmap=True):
        """
        The function saves the index in a file using cPickle.

        Parameters:
        fname: the index file name.
        mmap:  enable mmap or not. Enable it if mem is small.
        """
        f = open(fname, 'wb')
        pickle.dump(self.get_basic_info(), f, -1)
        logger.info('dump binary trees to %s ...' % fname)
        for tree in self.btr:
            pickle.dump(tree, f, -1)
        logger.info('dump raw dataset to %s ...' % (fname+'.npy'))
        if mmap:
            make_mmap(self.mtx, (len(self.mtx),self.dim), self.typ, fname+'.npy')
        else:
            numpy.save(open(fname+'.npy', 'wb'), self.mtx)
        pass

Example 10

Project: glove-theano
Source File: glove.py
View license
    def save_params(self):
        '''
        Saves the word embedding lookup matrix to file.
        '''
        W = self.W.get_value() + self.W1.get_value()
        np.save('lookup', W)

Example 11

Project: tensorlayer-chinese
Source File: files.py
View license
def save_any_to_npy(save_dict={}, name='any.npy'):
    """Save variables to .npy file.

    Examples
    ---------
    >>> tl.files.save_any_to_npy(save_dict={'data': ['a','b']}, name='test.npy')
    >>> data = tl.files.load_npy_to_any(name='test.npy')
    >>> print(data)
    ... {'data': ['a','b']}
    """
    np.save(name, save_dict)

Example 12

Project: stanza
Source File: embeddings.py
View license
    def to_files(self, array_file, vocab_file):
        """Write the embedding matrix and the vocab to files.

        :param (file) array_file: file to write array to
        :param (file) vocab_file: file to write vocab to
        """
        logging.info('Writing array...')
        np.save(array_file, self.array)
        logging.info('Writing vocab...')
        self.vocab.to_file(vocab_file)

Example 13

Project: pyscf
Source File: 24-callback.py
View license
def save_mo_coeff(envs):
    imacro = envs['imacro']
    imicro = envs['imicro']
    if imacro % 3 == 2:
        fname = 'mcscf-mo-%d-%d.npy' % (imacro+1, imicro+1)
        print('Save MO of step %d-%d in file %s' % (imacro+1, imicro+1, fname))
        numpy.save(fname, envs['mo_coeff'])

Example 14

Project: kaggle-galaxies
Source File: load_data.py
View license
def save_gz(path, arr): # save a .npy.gz file
    tmp_path = os.path.join("/tmp", os.path.basename(path) + ".tmp.npy")
    # tmp_path = path + ".tmp.npy" # temp file needs to end in .npy, else np.load adds it!
    np.save(tmp_path, arr)
    os.system("gzip -c %s > %s" % (tmp_path, path))
    os.remove(tmp_path)

Example 15

Project: pymt
Source File: utils.py
View license
def serialize_numpy(obj):
    import numpy
    from StringIO import StringIO
    from base64 import b64encode
    io = StringIO()
    numpy.save(io, obj)
    io.seek(0)
    return b64encode(io.read())

Example 16

Project: D-GEX
Source File: gct2npy.py
View license
def main():
    infile = sys.argv[1]
    outfile = sys.argv[2]
    
    gctobj = gct.GCT(infile)
    gctobj.read()
    
    data = gctobj.matrix[:, :].astype('float64')
    
    np.save(outfile, data)

Example 17

Project: Theano-MPI
Source File: Async_Worker.py
View license
    def save_model(self): 
        
        assert self.uepoch != None
        layers = self.model.layers
        path = self.config['weights_dir']
        vels = self.model.vels  
        
        from base.helper_funcs import save_weights, save_momentums
        save_weights(layers, path, self.uepoch)
        np.save(path + 'lr_' + str(self.uepoch) + \
                        '.npy', self.model.shared_lr.get_value())
        #save_momentums(vels,self.config['weights_dir'], self.uepoch)
        if self.verbose:
            print '\nweights and momentums saved at epoch %d' % self.uepoch

Example 18

Project: Theano-MPI
Source File: helper_funcs.py
View license
def save_momentums(vels, weights_dir, epoch):
    
    if not os.path.exists(weights_dir):
            os.makedirs(weights_dir)
            print 'Creating folder: %s' % weights_dir
            
    for ind in range(len(vels)):
        np.save(os.path.join(weights_dir, 'mom_' + str(ind) + '_' + str(epoch)),
                vels[ind].get_value())

Example 19

Project: Theano-MPI
Source File: BSP_Worker.py
View license
    def save_model(self): 
      
        layers = self.model.layers
        path = self.config['weights_dir']
        vels = self.model.vels  
        
        from base.helper_funcs import save_weights, save_momentums
        save_weights(layers, path, self.epoch)
        np.save(path + 'lr_' + str(self.epoch) + \
                        '.npy', self.model.shared_lr.get_value())
        #save_momentums(vels, self.config['weights_dir'], self.epoch)
        
        if self.verbose:
            print '\nweights and momentums saved at epoch %d' % self.epoch
        
        with open(path+"val_info.txt", "a") as f:
            f.write("\nepoch: {} val_info {}:".format(self.epoch, \
                                                    self.model.current_info))

Example 20

Project: theano_alexnet
Source File: make_labels.py
View license
def save_val_labels(misc_dir, val_label_name):
    ### VALIDATION LABELS ###
    with open(os.path.join(misc_dir, 'val.txt'), 'r') as text_labels:
        lines = text_labels.readlines()
    labels = []
    for line in lines:
        labels.append(int(line.split()[1]))
    np.save(val_label_name, labels)

Example 21

Project: histwords
Source File: seq_procrustes.py
View license
def align_years(years, rep_type, in_dir, out_dir, count_dir, min_count, **rep_args):
    first_iter = True
    base_embed = None
    for year in years:
        print "Loading year:", year
        year_embed =  create_representation(rep_type, in_dir + str(year), **rep_args)
        year_words = words_above_count(count_dir, year, min_count)
        year_embed.get_subembed(year_words)
        print "Aligning year:", year
        if first_iter:
            aligned_embed = year_embed
            first_iter = False
        else:
            aligned_embed = alignment.smart_procrustes_align(base_embed, year_embed)
        base_embed = aligned_embed
        print "Writing year:", year
        foutname = out_dir + str(year)
        np.save(foutname + "-w.npy",aligned_embed.m)
        write_pickle(aligned_embed.iw, foutname + "-vocab.pkl")

Example 22

Project: socialsent
Source File: makelowdim.py
View license
def run(in_file, out_path, dim=300, keep_words=None): 
        base_embed = Explicit.load(in_file, normalize=False)
        if keep_words != None:
            base_embed = base_embed.get_subembed(keep_words)
        u, s, v = randomized_svd(base_embed.m, n_components=dim, n_iter=5)
        np.save(out_path + "-u.npy", u)
        np.save(out_path + "-v.npy", v)
        np.save(out_path + "-s.npy", s)
        util.write_pickle(base_embed.iw, out_path  + "-vocab.pkl")

Example 23

Project: tensorlayer
Source File: files.py
View license
def save_any_to_npy(save_dict={}, name='any.npy'):
    """Save variables to .npy file.

    Examples
    ---------
    >>> tl.files.save_any_to_npy(save_dict={'data': ['a','b']}, name='test.npy')
    >>> data = tl.files.load_npy_to_any(name='test.npy')
    >>> print(data)
    ... {'data': ['a','b']}
    """
    np.save(name, save_dict)

Example 24

Project: Deep-Learning-TensorFlow
Source File: run_dbn.py
View license
    def save_layers_output(which_set):
        if which_set == 'train':
            trout = srbm.get_layers_output(trX)
            for i, o in enumerate(trout):
                np.save(FLAGS.save_layers_output_train + '-layer-' + str(i + 1) + '-train', o)

        elif which_set == 'test':
            teout = srbm.get_layers_output(teX)
            for i, o in enumerate(teout):
                np.save(FLAGS.save_layers_output_test + '-layer-' + str(i + 1) + '-test', o)

Example 25

View license
    def save_layers_output(which_set):
        if which_set == 'train':
            trout = srbm.get_layers_output(trX)
            for i, o in enumerate(trout):
                np.save(FLAGS.save_layers_output_train + '-layer-' + str(i + 1) + '-train', o)

        elif which_set == 'test':
            teout = srbm.get_layers_output(teX)
            for i, o in enumerate(teout):
                np.save(FLAGS.save_layers_output_test + '-layer-' + str(i + 1) + '-test', o)

Example 26

View license
    def save_layers_output(which_set):
        if which_set == 'train':
            trout = sdae.get_layers_output(trX)
            for i, o in enumerate(trout):
                np.save(FLAGS.save_layers_output_train + '-layer-' + str(i + 1) + '-train', o)

        elif which_set == 'test':
            teout = sdae.get_layers_output(teX)
            for i, o in enumerate(teout):
                np.save(FLAGS.save_layers_output_test + '-layer-' + str(i + 1) + '-test', o)

Example 27

View license
    def save_layers_output(which_set):
        if which_set == 'train':
            trout = sdae.get_layers_output(trX)
            for i, o in enumerate(trout):
                np.save(FLAGS.save_layers_output_train + '-layer-' + str(i + 1) + '-train', o)

        elif which_set == 'test':
            teout = sdae.get_layers_output(teX)
            for i, o in enumerate(teout):
                np.save(FLAGS.save_layers_output_test + '-layer-' + str(i + 1) + '-test', o)

Example 28

Project: LatentStrainAnalysis
Source File: eigenhashes.py
View license
	def calculate_global_weights(self,M,NZ):
		GWnz = self.global_entropy_weights(M)
		np.save(self.output_path+'global_nonzero_weights.npy',GWnz)
		GW = np.zeros(2**self.hash_size,dtype=np.float32)
		for i in xrange(len(NZ)):
			GW[NZ[i]] = GWnz[i]
		NZ = None
		np.save(self.output_path+'global_weights.npy',GW)
		GW = None
		return GWnz

Example 29

Project: LatentStrainAnalysis
Source File: eigenhashes.py
View license
	def eigenkmers(self,M,num_dims=10):
		L,V,R = svds(M,num_dims)
		np.save(self.output_path+'eigenleft.npy',L)
		np.save(self.output_path+'eigenvalues.npy',V)
		np.save(self.output_path+'eigenright.npy',R)
		return np.transpose(np.transpose(R)*V)

Example 30

Project: 3D-R2N2
Source File: net.py
View license
    def save(self, filename):
        # params_cpu = {}
        params_cpu = []
        for param in self.params:
            # params_cpu[param.name] = np.array(param.val.get_value())
            params_cpu.append(param.val.get_value())
        np.save(filename, params_cpu)
        print('saving network parameters to ' + filename)

Example 31

Project: ptsa
Source File: lmer.py
View license
def _memmap_array(x, memmap_dir=None):
    if memmap_dir is None:
        memmap_dir = tempfile.gettempdir()
    filename = os.path.join(memmap_dir,str(id(x))+'.npy')
    np.save(filename,x)
    return np.load(filename,'r')

Example 32

Project: cvu
Source File: options_struct.py
View license
    def _proc_export_to_scalar(self):
        from traitsui.file_dialog import save_file
        filename = save_file()
        if filename.endswith('.mat'):
            from scipy import io
            io.savemat(filename, mdict={self.current_stat.name:
                self.current_stat.stat})
        elif filename.endswith('.npy'):
            np.save(filename, self.current_stat.stat)
        else:
            np.savetxt(filename, self.current_stat.stat)

Example 33

Project: layered
Source File: trainer.py
View license
    def _evaluate(self, index):
        if not self._every(self.problem.evaluate_every,
                           self.problem.batch_size, index):
            return
        if self.save:
            np.save(self.save, self.weights)
        error = compute_error(
            self.network, self.weights, self.problem.dataset.testing)
        print('Batch {} test error {:.2f}%'.format(index, 100 * error))
        if self.visual:
            self.plot_testing([error])

Example 34

Project: distarray
Source File: test_distributed_io.py
View license
    @classmethod
    def setUpClass(cls):
        super(TestNpyFileLoad, cls).setUpClass()
        cls.expected = np.arange(20).reshape(2, 10)

        def save_test_file(data):
            import numpy
            from distarray.testing import temp_filepath
            output_path = temp_filepath('.npy')
            numpy.save(output_path, data)
            return output_path

        cls.output_path = cls.context.apply(save_test_file, (cls.expected,),
                                            targets=[cls.context.targets[0]])[0]  # noqa

Example 35

Project: caffe-tensorflow
Source File: convert.py
View license
def convert(def_path, caffemodel_path, data_output_path, code_output_path, phase):
    try:
        transformer = TensorFlowTransformer(def_path, caffemodel_path, phase=phase)
        print_stderr('Converting data...')
        if caffemodel_path is not None:
            data = transformer.transform_data()
            print_stderr('Saving data...')
            with open(data_output_path, 'wb') as data_out:
                np.save(data_out, data)
        if code_output_path:
            print_stderr('Saving source...')
            with open(code_output_path, 'wb') as src_out:
                src_out.write(transformer.transform_source())
        print_stderr('Done.')
    except KaffeError as err:
        fatal_error('Error encountered: {}'.format(err))

Example 36

Project: pycortex
Source File: mayavi_aligner.py
View license
    def _xfm_default(self):
        xfm = mlab.pipeline.transform_data(self.surf_src, figure=self.scene_3d.mayavi_scene)
        def savexfm(info, evt):
            self._undolist.append(xfm.transform.matrix.to_array())
            np.save("/tmp/last_xfm.npy", self.get_xfm())

        xfm.widget.add_observer("EndInteractionEvent", savexfm)
        xfm.widget.add_observer("EndInteractionEvent", self.update_slabs)
        xfm.transform.set_matrix(self.startxfm.ravel())
        xfm.widget.set_transform(xfm.transform)
        return xfm

Example 37

Project: ROLO
Source File: MOLO_utils.py
View license
def save_rolo_output(out_fold, rolo_output, step, num_steps, batch_size):
        assert(len(rolo_output)== batch_size)
        st= step * batch_size * num_steps - 2
        for i in range(batch_size):
            id = st + (i + 1)* num_steps + 1
            pred = rolo_output[i]
            path = os.path.join(out_fold, str(id))
            np.save(path, pred)

Example 38

Project: ROLO
Source File: MOLO_utils.py
View license
def save_rolo_output_test( out_fold, rolo_output, step, num_steps, batch_size):
        assert(len(rolo_output)== batch_size)
        st= step - 2 #* batch_size * num_steps
        for i in range(batch_size):
            id = st + (i + 1)* num_steps + 1
            pred = rolo_output[i]
            path = os.path.join(out_fold, str(id))
            np.save(path, pred)

Example 39

Project: ROLO
Source File: ROLO_utils.py
View license
def save_rolo_output(out_fold, rolo_output, step, num_steps, batch_size):
        assert(len(rolo_output)== batch_size)
        st= step * batch_size * num_steps - 2
        for i in range(batch_size):
            id = st + (i + 1)* num_steps + 1
            pred = rolo_output[i]
            path = os.path.join(out_fold, str(id))
            np.save(path, pred)

Example 40

Project: ROLO
Source File: ROLO_utils.py
View license
def save_rolo_output_test( out_fold, rolo_output, step, num_steps, batch_size):
        assert(len(rolo_output)== batch_size)
        st= step - 2 #* batch_size * num_steps
        for i in range(batch_size):
            id = st + (i + 1)* num_steps + 1
            pred = rolo_output[i]
            path = os.path.join(out_fold, str(id))
            np.save(path, pred)

Example 41

Project: ROLO
Source File: ROLO_utils.py
View license
def save_rolo_output_heatmap( out_fold, rolo_heat, step, num_steps, batch_size):
        assert(len(rolo_heat)== batch_size)
        st= step - 2 #* batch_size * num_steps
        for i in range(batch_size):
            id = st + (i + 1)* num_steps + 1
            pred = rolo_heat[i]
            path = os.path.join(out_fold, str(id))
            np.save(path, pred)

Example 42

Project: robothon
Source File: test_io.py
View license
    def do(self, a):
        c = StringIO.StringIO()
        np.save(c, a)
        c.seek(0)
        a_reloaded = np.load(c)
        assert_equal(a, a_reloaded)

Example 43

Project: pyNCS
Source File: BaseComAPI.py
View license
    def __save_rec_file(self, ev_array, filename):
        '''
        Save data using np.save, and adds filename in self._record_fns
        '''
        self._rec_fns.append(filename+'.npy')
        numpy.save(filename, ev_array)

        self._run_id += 1

Example 44

Project: automl-phase-2
Source File: agent.py
View license
    def np_pickler(array):
        """Function for pickle to use when pickling numpy arrays"""
        with tempfile.NamedTemporaryFile(mode='wb', suffix='_pickle.npy', dir=constants.SAVE_DIR, delete=False) as fp:
            np.save(fp, array)
            tempfl = fp.name
        return np_unpickler, (tempfl,)

Example 45

Project: genreXpose
Source File: ceps.py
View license
def write_ceps(ceps, fn):
    """
    Write the MFCC to separate files to speed up processing.
    """
    base_fn, ext = os.path.splitext(fn)
    data_fn = base_fn + ".ceps"
    np.save(data_fn, ceps)
    print "Written ", data_fn

Example 46

Project: Rewrite
Source File: preprocess.py
View license
def process_font(chars, font_path, save_dir, x_offset=0, y_offset=0, mode='target'):
    char_size = 64
    canvas = 80
    if mode == 'source':
        char_size *= 2
        canvas *= 2
    font_bitmaps = generate_font_bitmaps(chars, font_path, char_size,
                                         canvas, x_offset, y_offset)
    _, ext = os.path.splitext(font_path)
    if not ext.lower() in [".otf", ".ttf"]:
        raise RuntimeError("unknown font type found %s. only TrueType or OpenType is supported" % ext)
    _, tail = os.path.split(font_path)
    font_name = ".".join(tail.split(".")[:-1])
    bitmap_path = os.path.join(save_dir, "%s.npy" % font_name)
    np.save(bitmap_path, font_bitmaps)
    sample_image_path = os.path.join(save_dir, "%s_sample.png" % font_name)
    render_fonts_image(font_bitmaps[:100], sample_image_path, 10, False)
    print("%s font %s saved at %s" % (mode, font_name, bitmap_path))

Example 47

Project: Rewrite
Source File: preprocess.py
View license
def process_font(chars, font_path, save_dir, x_offset=0, y_offset=0, mode='target'):
    char_size = 64
    canvas = 80
    if mode == 'source':
        char_size *= 2
        canvas *= 2
    font_bitmaps = generate_font_bitmaps(chars, font_path, char_size,
                                         canvas, x_offset, y_offset)
    _, ext = os.path.splitext(font_path)
    if not ext.lower() in [".otf", ".ttf"]:
        raise RuntimeError("unknown font type found %s. only TrueType or OpenType is supported" % ext)
    _, tail = os.path.split(font_path)
    font_name = ".".join(tail.split(".")[:-1])
    bitmap_path = os.path.join(save_dir, "%s.npy" % font_name)
    np.save(bitmap_path, font_bitmaps)
    sample_image_path = os.path.join(save_dir, "%s_sample.png" % font_name)
    render_fonts_image(font_bitmaps[:100], sample_image_path, 10, False)
    print("%s font %s saved at %s" % (mode, font_name, bitmap_path))

Example 48

Project: phy
Source File: array.py
View license
def write_array(path, arr):
    """Write an array to a .npy file."""
    file_ext = op.splitext(path)[1]
    if file_ext == '.npy':
        return np.save(path, arr)
    raise NotImplementedError("The file extension `{}` ".format(file_ext) +
                              "is not currently supported.")

Example 49

Project: phy
Source File: array.py
View license
def write_array(path, arr):
    """Write an array to a .npy file."""
    file_ext = op.splitext(path)[1]
    if file_ext == '.npy':
        return np.save(path, arr)
    raise NotImplementedError("The file extension `{}` ".format(file_ext) +
                              "is not currently supported.")

Example 50

Project: sima
Source File: sequence.py
View license
    def _todict(self, savedir=None):
        if self._path is None:
            self._path = 'seq_' + uuid.uuid4().hex + '.npy'
            if savedir is not None:
                self._path = join(savedir, self._path)
            with open(self._path, 'wb') as f:
                np.save(f, self._array)
        d = {'__class__': self.__class__, 'array': None}
        if savedir is None:
            d.update({'path': abspath(self._path)})
        else:
            d.update({'_abspath': abspath(self._path),
                      '_relpath': relpath(self._path, savedir)})
        return d