Python cPickle.html() Examples
The following are 7
code examples of cPickle.html().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cPickle
, or try the search function
.
Example #1
Source File: learner.py From stanza-old with Apache License 2.0 | 5 votes |
def dump(self, outfile): ''' Serialize the model for this learner and write it to a file. Serialized models can be loaded back in with `load`. By default, pickle the entire object. This may not be very efficient or reliable for long-term storage; consider overriding this (and `load`) to serialize only the necessary parameters. Alternatively, you can define __getstate__ and __setstate__ for subclasses to influence how the model is pickled (see https://docs.python.org/2/library/pickle.html). :param file outfile: A file-like object where the serialized model will be written. ''' pickle.dump(self, outfile)
Example #2
Source File: gpickle.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def write_gpickle(G, path, protocol=pickle.HIGHEST_PROTOCOL): """Write graph in Python pickle format. Pickles are a serialized byte stream of a Python object [1]_. This format will preserve Python objects used as nodes or edges. Parameters ---------- G : graph A NetworkX graph path : file or string File or filename to write. Filenames ending in .gz or .bz2 will be compressed. protocol : integer Pickling protocol to use. Default value: ``pickle.HIGHEST_PROTOCOL``. Examples -------- >>> G = nx.path_graph(4) >>> nx.write_gpickle(G, "test.gpickle") References ---------- .. [1] http://docs.python.org/library/pickle.html """ pickle.dump(G, path, protocol)
Example #3
Source File: gpickle.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def read_gpickle(path): """Read graph object in Python pickle format. Pickles are a serialized byte stream of a Python object [1]_. This format will preserve Python objects used as nodes or edges. Parameters ---------- path : file or string File or filename to write. Filenames ending in .gz or .bz2 will be uncompressed. Returns ------- G : graph A NetworkX graph Examples -------- >>> G = nx.path_graph(4) >>> nx.write_gpickle(G, "test.gpickle") >>> G = nx.read_gpickle("test.gpickle") References ---------- .. [1] http://docs.python.org/library/pickle.html """ return pickle.load(path) # fixture for nose tests
Example #4
Source File: gpickle.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def write_gpickle(G, path, protocol=pickle.HIGHEST_PROTOCOL): """Write graph in Python pickle format. Pickles are a serialized byte stream of a Python object [1]_. This format will preserve Python objects used as nodes or edges. Parameters ---------- G : graph A NetworkX graph path : file or string File or filename to write. Filenames ending in .gz or .bz2 will be compressed. protocol : integer Pickling protocol to use. Default value: ``pickle.HIGHEST_PROTOCOL``. Examples -------- >>> G = nx.path_graph(4) >>> nx.write_gpickle(G, "test.gpickle") References ---------- .. [1] https://docs.python.org/2/library/pickle.html """ pickle.dump(G, path, protocol)
Example #5
Source File: gpickle.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def read_gpickle(path): """Read graph object in Python pickle format. Pickles are a serialized byte stream of a Python object [1]_. This format will preserve Python objects used as nodes or edges. Parameters ---------- path : file or string File or filename to write. Filenames ending in .gz or .bz2 will be uncompressed. Returns ------- G : graph A NetworkX graph Examples -------- >>> G = nx.path_graph(4) >>> nx.write_gpickle(G, "test.gpickle") >>> G = nx.read_gpickle("test.gpickle") References ---------- .. [1] https://docs.python.org/2/library/pickle.html """ return pickle.load(path) # fixture for nose tests
Example #6
Source File: gpickle.py From aws-kube-codesuite with Apache License 2.0 | 5 votes |
def write_gpickle(G, path, protocol=pickle.HIGHEST_PROTOCOL): """Write graph in Python pickle format. Pickles are a serialized byte stream of a Python object [1]_. This format will preserve Python objects used as nodes or edges. Parameters ---------- G : graph A NetworkX graph path : file or string File or filename to write. Filenames ending in .gz or .bz2 will be compressed. protocol : integer Pickling protocol to use. Default value: ``pickle.HIGHEST_PROTOCOL``. Examples -------- >>> G = nx.path_graph(4) >>> nx.write_gpickle(G, "test.gpickle") References ---------- .. [1] https://docs.python.org/2/library/pickle.html """ pickle.dump(G, path, protocol)
Example #7
Source File: gpickle.py From aws-kube-codesuite with Apache License 2.0 | 5 votes |
def read_gpickle(path): """Read graph object in Python pickle format. Pickles are a serialized byte stream of a Python object [1]_. This format will preserve Python objects used as nodes or edges. Parameters ---------- path : file or string File or filename to write. Filenames ending in .gz or .bz2 will be uncompressed. Returns ------- G : graph A NetworkX graph Examples -------- >>> G = nx.path_graph(4) >>> nx.write_gpickle(G, "test.gpickle") >>> G = nx.read_gpickle("test.gpickle") References ---------- .. [1] https://docs.python.org/2/library/pickle.html """ return pickle.load(path) # fixture for nose tests