Save the object to a .npz file.

    Parameters
    ----------
    filepath : str
        The path to save the file.
    obj: `pypianoroll.Multitrack` objects
        The object to be saved.
344985
def save(filepath, obj, compressed=True):
    
    if not isinstance(obj, Multitrack):
        raise TypeError("Support only `pypianoroll.Multitrack` class objects")
    obj.save(filepath, compressed)
792782
def save(df, path):
        
        buffer = []
        size = _reset_df_and_get_size(df)
        with get_tqdm(total=size) as pbar:
            for dp in df:
                buffer.append(dp)
                pbar.update()
        np.savez_compressed(path, buffer=np.asarray(buffer, dtype=np.object))
628055
def save(self, path):
        
        (folder, filename) = os.path.split(path)
        (name, extension) = os.path.splitext(filename)

        if not name:
            raise ValueError, "name is required"

        if extension:
            format = Image.image_format(extension)
        else:
            format = self.format
            filename = name + self.extension
            path = os.path.join(folder, filename)

        image = self.convert(format)
        if image._contents:
            f = open(path, "wb")
            f.write(image._contents)
            f.close()
        else:
            image.pil_image.save(path, format)

        return path
767594
def save(self, path, **extra):
        
        with File(path, 'w') as f:
            for key, val in vars(self).items():
                assert val is not None, key  # sanity check
                try:
                    f[key] = maybe_encode(val)
                except ValueError as err:
                    if 'Object header message is too large' in str(err):
                        logging.error(str(err))
            for k, v in extra.items():
                f.attrs[k] = maybe_encode(v)
1121808
def save_features(paths: List[str], datas: List[np.ndarray],
                  compressed: bool = False) -> List:
    
    fnames = []  # type: List[str]
    for path, data in zip(paths, datas):
        fnames.append(save_feature(path, data, compressed))
    return fnames
346474
def dump_to_path(self, cnf, filepath, **kwargs):
        
        with self.wopen(filepath) as out:
            out.write(self.dump_to_string(cnf, **kwargs))
598458
def saveto(self, path, sortkey = True):
        
        with open(path, 'w') as f:
            self.savetofile(f, sortkey)
1312843
def to_file(self, path):
        
        with open(os.path.expanduser(path), "w") as ofile:
            ofile.write(self.__repr__())
549670
def save(self, path):
        
        writer = csv.writer(open(path, 'w', newline=''), delimiter=' ')
        rows = list(self.items())
        rows.sort(key=lambda x: x[0])
        writer.writerows(rows)
657209
def save(self, path):
        ''' 
        '''
        self.clip.write_audiofile(path, fps=self.sampling_rate)
193857
def save(self, vpk_output_path):
        
        with fopen(vpk_output_path, 'wb') as f:
            # write VPK1 header
            f.write(struct.pack("3I", self.signature,
                                      self.version,
                                      self.tree_length))

            self.header_length = f.tell()

            data_offset = self.header_length + self.tree_length

            # write file tree
            for ext in self.tree:
                f.write("{0}\x00".format(ext).encode('latin-1'))

                for relpath in self.tree[ext]:
                    f.write("{0}\x00".format(relpath).encode('latin-1'))

                    for filename in self.tree[ext][relpath]:
                        f.write("{0}\x00".format(filename).encode('latin-1'))

                        # append file data
                        metadata_offset = f.tell()
                        file_offset = data_offset
                        real_filename = filename if not ext else "{0}.{1}".format(filename, ext)
                        checksum = 0
                        f.seek(data_offset)

                        with fopen(os.path.join(self.path,
                                                '' if relpath == ' ' else relpath,
                                                real_filename
                                                ),
                                   'rb') as pakfile:
                            for chunk in iter(lambda: pakfile.read(1024), b''):
                                checksum = crc32(chunk, checksum)
                                f.write(chunk)

                        data_offset = f.tell()
                        file_length = f.tell() - file_offset
                        f.seek(metadata_offset)

                        # metadata

                        # crc32
                        # preload_length
                        # archive_index
                        # archive_offset
                        # file_length
                        # suffix
                        f.write(struct.pack("IHHIIH", checksum & 0xFFffFFff,
                                                      0,
                                                      0x7fff,
                                                      file_offset - self.tree_length - self.header_length,
                                                      file_length,
                                                      0xffff
                                                      ))


                    # next relpath
                    f.write(b"\x00")
                # next ext
                f.write(b"\x00")
            # end of file tree
            f.write(b"\x00")
368032
def save(obj, path):
    
    with open(path, 'wb') as f:
        try:
            pickle.dump(obj, f, protocol=pickle.HIGHEST_PROTOCOL)
        except Exception as e:
            print('Pickling failed for object {0}, path {1}'.format(obj, path))
            print('Error message: {0}'.format(e))
298997
def _save_to(self, im, path, format=None):
        
        format = format or im.format
        if not format:
            _, format = splitext(path)
            format = format[1:]
        im.format = format.lower()
        im.save(filename=path)
625512
def save(self, path="speech"):
        
        if self._data is None:
            raise Exception("There's nothing to save")

        extension = "." + self.__params["format"]
        if os.path.splitext(path)[1] != extension:
            path += extension

        with open(path, "wb") as f:
            for d in self._data:
                f.write(d)

        return path
1074455
def to_hdf5(self, filepath: str):
        
        try:
            self.start("Saving data to Hdf5...")
            dd.io.save(filepath, self.df)
            self.end("Finished saving Hdf5 data")
        except Exception as e:
            self.err(e, "Can not convert data to Hdf5")
320632
def save(self, path):
    
    json.dump(dict(loss=self.__class__.__name__,
                   params=self.hparams),
              open(os.path.join(path, 'loss.json'), 'wb'))
1345967
def save(self, file_path):
        

        # TODO need a file format that is flexible and efficient to allow the following:
        #   1) being able to read just meta info without having to load the ENTIRE dataset
        #       i.e. use case: compatibility check with #subjects, ids and their classes
        #   2) random access layout: being able to read features for a single subject!

        try:
            file_path = os.path.abspath(file_path)
            with open(file_path, 'wb') as df:
                # pickle.dump(self, df)
                pickle.dump((self.__data, self.__classes, self.__labels,
                             self.__dtype, self.__description, self.__num_features,
                             self.__feature_names),
                            df)
            return
        except IOError as ioe:
            raise IOError('Unable to save the dataset to file: {}', format(ioe))
        except:
            raise