예제 #1
0
    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
예제 #2
0
파일: table.py 프로젝트: ekiefl/pooltool
def table_from_pickle(path):
    d = utils.load_pickle(path)
    return table_from_dict(d)
예제 #3
0
 def load(self, path):
     obj = utils.load_pickle(path)
     for system_dict in obj:
         self.append(System(d=system_dict))
예제 #4
0
 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))
예제 #5
0
파일: cue.py 프로젝트: ekiefl/pooltool
def cue_from_pickle(path):
    d = utils.load_pickle(path)
    return cue_from_dict(d)