def copy(self, set_to_initial=True): """Make a fresh copy of this system state Parameters ========== set_to_initial : bool, True Prior to copying, this method sets the ball states the initial states in the history. However, this can be prevented by setting this to False, causing the ball states to be copied as is. """ with tempfile.NamedTemporaryFile(delete=True) as temp: self.save(temp.name, set_to_initial=set_to_initial) balls, table, cue, events, meta = self.from_dict( utils.load_pickle(temp.name)) system = self.__class__(balls=balls, table=table, cue=cue) system.events = events system.meta = meta return system
def table_from_pickle(path): d = utils.load_pickle(path) return table_from_dict(d)
def load(self, path): obj = utils.load_pickle(path) for system_dict in obj: self.append(System(d=system_dict))
def load(self, path): """Load a pickle-stored system state""" self.balls, self.table, self.cue, self.events, self.meta = self.from_dict( utils.load_pickle(path))
def cue_from_pickle(path): d = utils.load_pickle(path) return cue_from_dict(d)