Python _pickle.loads() Examples
The following are 6
code examples of _pickle.loads().
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
_pickle
, or try the search function
.
Example #1
Source File: history.py From alpha_zero_othello with MIT License | 6 votes |
def start(): config = DataConfig() histories = sorted(glob.glob(config.history_location+"*.pickle")) data = {} for hist in histories: file = open(hist, 'rb') h = pickle.loads(pickle.load(file)) for k, v in h.items(): if k not in data.keys(): data[k] = [] for item in v: data[k].append(item) legend = [] plt.subplot(2, 1, 1) for kv in data.items(): legend.append(kv[0]) plt.plot(kv[1]) plt.legend(legend) for i, kv in enumerate(data.items()): plt.subplot(2, 3, i+4) plt.title(kv[0]) plt.plot(kv[1]) plt.tight_layout() plt.show()
Example #2
Source File: utils.py From distributed_rl with MIT License | 5 votes |
def loads(packed): if _USE_COMPRESS: return cPickle.loads(lz4.frame.decompress(packed)) else: return cPickle.loads(packed)
Example #3
Source File: pickle_import_export.py From douglas-quaid with GNU General Public License v3.0 | 5 votes |
def get_object_from_pickle(pickle_obj): # Return an object from the pickle version of it # The protocol version used is detected automatically, so we do not # have to specify it. return cPickle.loads(pickle_obj) # non static, to be sure we patched it before use, only once
Example #4
Source File: udp_client.py From OpenBCI_Python with MIT License | 5 votes |
def start_listening(self, callback=None): while True: data, addr = self.client.recvfrom(1024) print("data") if self.json: sample = json.loads(data) # In JSON mode we only recieve channel data. print(data) else: sample = pickle.loads(data) # Note that sample is an OpenBCISample object. print(sample.id) print(sample.channel_data)
Example #5
Source File: entity_list.py From demoparser with Apache License 2.0 | 5 votes |
def new_entity(self, index, class_id, serial): """Create new entity. :returns: Created entity. """ if self._entities[index]: self._entities[index] = None baseline = self.parser.instance_baselines[class_id] cls = BaseEntity # Find an entity class based on which tables are in its baseline. # Class IDs don't seem to be consistent across demo files so all # you can do is assume if an entity baseline has 'DT_Team' it must # be a Team. for table in baseline: if table in self.class_map: cls = self.class_map[table] break new_baseline = pickle.loads(pickle.dumps(baseline)) assert baseline == new_baseline entity = cls(self.parser, index, class_id, serial, new_baseline) self._entities[index] = entity return entity
Example #6
Source File: replaybuffer.py From alpha_zero_othello with MIT License | 5 votes |
def load(self, filename): try: file = open(filename, 'rb') if len(self.buffer) == 0: self.buffer = pickle.loads(pickle.load(file)) else: buf = pickle.loads(pickle.load(file)) self.merge(buf) file.close() return True except Exception as e: return False