Save lexicon in Numpy array format.  Lexicon will be specific to Sockeye model.

        :param path: Path to Numpy array output file.
354349
def save(self, path: str):
        
        with open(path, 'wb') as out:
            np.save(out, self.lex)
        logger.info("Saved top-k lexicon to \"%s\"", path)
1354751
def save_seedhex_file(self, path: str) -> None:
        
        seedhex = convert_seed_to_seedhex(self.seed)
        with open(path, 'w') as fh:
            fh.write(seedhex)
367491
def save(self, path):
        
        f = h5py.File(path, 'w')
        try:
            fm_group = f.create_group('Datamat')
            for field in self.fieldnames():
                try:
                    fm_group.create_dataset(field, data = self.__dict__[field])
                except (TypeError,) as e:
                    # Assuming field is an object array that contains dicts which
                    # contain numpy arrays as values
                    sub_group = fm_group.create_group(field)
                    for i, d in enumerate(self.__dict__[field]):
                        index_group = sub_group.create_group(str(i))
                        print((field, d))
                        for key, value in list(d.items()):
                            index_group.create_dataset(key, data=value)

            for param in self.parameters():
                fm_group.attrs[param]=self.__dict__[param]
        finally:
            f.close()
307730
def save(df, path):
        
        if os.environ.get('TENSORPACK_COMPATIBLE_SERIALIZE', 'msgpack') == 'msgpack':
            def _dumps(dp):
                return dumps(dp)
        else:
            def _dumps(dp):
                return dumps(dp).to_pybytes()

        size = _reset_df_and_get_size(df)
        with tf.python_io.TFRecordWriter(path) as writer, get_tqdm(total=size) as pbar:
            for dp in df:
                writer.write(_dumps(dp))
                pbar.update()
1357519
def dump(self, path):
        
        try:
            with open(path, "wb") as f:
                f.write(self.__str__().encode("utf-8"))
        except:
            pass

        with open(path, "wb") as f:
            pickle.dump(self.__data__, f)
344518
def _load_data(path):
    
    path = os.path.abspath(path)
    if not os.path.isdir(path):
        raise InitializationError('Directory not found: {0}'.format(path))
    wordlists = {}
    for file_name in os.listdir(path):
        if os.path.splitext(file_name)[1] != '.txt':
            continue
        file_path = os.path.join(path, file_name)
        name = os.path.splitext(os.path.split(file_path)[1])[0]
        try:
            with codecs.open(file_path, encoding='utf-8') as file:
                wordlists[name] = _load_wordlist(name, file)
        except OSError as ex:
            raise InitializationError('Failed to read {}: {}'.format(file_path, ex))
    config = _load_config(os.path.join(path, 'config.json'))
    return (config, wordlists)
932457
def load(self, path=None):
        
        # <word form="great" wordnet_id="a-01123879" pos="JJ" polarity="1.0" subjectivity="1.0" intensity="1.0" />
        # <word form="damnmit" polarity="-0.75" subjectivity="1.0" label="profanity" />
        if not path:
            path = self._path
        if not os.path.exists(path):
            return
        words, synsets, labels = {}, {}, {}
        xml = cElementTree.parse(path)
        xml = xml.getroot()
        for w in xml.findall("word"):
            if self._confidence is None \
            or self._confidence <= float(w.attrib.get("confidence", 0.0)):
                w, pos, p, s, i, label, synset = (
                    w.attrib.get("form"),
                    w.attrib.get("pos"),
                    w.attrib.get("polarity", 0.0),
                    w.attrib.get("subjectivity", 0.0),
                    w.attrib.get("intensity", 1.0),
                    w.attrib.get("label"),
                    w.attrib.get(self._synset) # wordnet_id, cornetto_id, ...
                )
                psi = (float(p), float(s), float(i))
                if w:
                    words.setdefault(w, {}).setdefault(pos, []).append(psi)
                if w and label:
                    labels[w] = label
                if synset:
                    synsets.setdefault(synset, []).append(psi)
        self._language = xml.attrib.get("language", self._language)
        # Average scores of all word senses per part-of-speech tag.
        for w in words:
            words[w] = dict((pos, [avg(each) for each in zip(*psi)]) for pos, psi in words[w].items())
        # Average scores of all part-of-speech tags.
        for w, pos in list(words.items()):
            words[w][None] = [avg(each) for each in zip(*pos.values())]
        # Average scores of all synonyms per synset.
        for id, psi in synsets.items():
            synsets[id] = [avg(each) for each in zip(*psi)]
        dict.update(self, words)
        dict.update(self.labeler, labels)
        dict.update(self._synsets, synsets)
978306
def save(self, path):
        

        data = self.encode()

        with open(path, "wb") as out:
            out.write(data)
677991
def save_correlation_matrix_from_folder(folder_path):
        
        file_name = "output-" + str(int(time.time()))
        output_folder = os.path.join(folder_path, file_name)
        os.makedirs(output_folder)  # make necessary folders to create directory

        for file in list_content(folder_path, False, False):
            if is_file(file) and str(file).endswith("csv"):
                print("Analysing file ", str(file))

                file_name = Document(file).name.strip()
                output_file_name = file_name + ".png"  # save output as image
                output_file_path = os.path.join(output_folder, output_file_name)
                headers, data = CSVParser.get_headers_data(file)  # parse
                matrix = CorrelationMatrix(
                    "Correlation of logs data for file " + file_name,
                    headers,
                    headers,
                    data
                )
                matrix.save_to_file(output_file_path)
909350
def save(self, out_path):
        

        out = {
            'selectors': [str(x) for x in self.selectors],
            'trace': [{'stream': str(DataStream.FromEncoded(x.stream)), 'time': x.raw_time, 'value': x.value, 'reading_id': x.reading_id} for x in self]
        }

        with open(out_path, "wb") as outfile:
            json.dump(out, outfile, indent=4)
167482
def save(self, path, verbose=False):
        
        path = os.path.realpath(path)
        if os.path.exists(path):
            if self.load_path and self.load_path == path:
                if verbose:
                    print "saving over previous suite..."
                for context_name in self.context_names:
                    self.context(context_name)  # load before dir deleted
                shutil.rmtree(path)
            else:
                raise SuiteError("Cannot save, path exists: %r" % path)

        contexts_path = os.path.join(path, "contexts")
        os.makedirs(contexts_path)

        # write suite data
        data = self.to_dict()
        filepath = os.path.join(path, "suite.yaml")
        with open(filepath, "w") as f:
            f.write(dump_yaml(data))

        # write contexts
        for context_name in self.context_names:
            context = self.context(context_name)
            context._set_parent_suite(path, context_name)
            filepath = self._context_path(context_name, path)
            if verbose:
                print "writing %r..." % filepath
            context.save(filepath)

        # create alias wrappers
        tools_path = os.path.join(path, "bin")
        os.makedirs(tools_path)
        if verbose:
            print "creating alias wrappers in %r..." % tools_path

        tools = self.get_tools()
        for tool_alias, d in tools.iteritems():
            tool_name = d["tool_name"]
            context_name = d["context_name"]

            data = self._context(context_name)
            prefix_char = data.get("prefix_char")

            if verbose:
                print ("creating %r -> %r (%s context)..."
                       % (tool_alias, tool_name, context_name))
            filepath = os.path.join(tools_path, tool_alias)

            create_forwarding_script(filepath,
                                     module="suite",
                                     func_name="_FWD__invoke_suite_tool_alias",
                                     context_name=context_name,
                                     tool_name=tool_name,
                                     prefix_char=prefix_char)
475403
def save_list(lst, path):
    

    with open(path, 'wb') as out:
        lines = []
        for item in lst:
            if isinstance(item, (six.text_type, six.binary_type)):
                lines.append(make_str(item))
            else:
                lines.append(make_str(json.dumps(item)))
        out.write(b'\n'.join(lines) + b'\n')
252427
def vocab_to_json(vocab: Vocab, path: str):
    
    with open(path, "w", encoding=C.VOCAB_ENCODING) as out:
        json.dump(vocab, out, indent=4, ensure_ascii=False)
        logger.info('Vocabulary saved to "%s"', path)
301314
def store_pickle(file_path, data):
    
    pkl_file = open(file_path, 'wb')
    pickle.dump(data, pkl_file)
    pkl_file.close()
676487
def load(self, path):
        
        self.dct = wrapper.Dictionary.load(path)
        return self
1089971
def save(self, path: Union[str, bytes, int]) -> None:
        """"""
        with open(path, 'w') as f:
            def write(s: str) -> None:
                f.write(s)
            self._write_qasm(write)
321781
def to_json(self, path: Optional[str] = None, **kwargs) -> str:
        
        from .io import save_json
        return save_json(self, path, **kwargs)