def __getattr__(self, k): if k == SimulationManager.ALL: return [ p for p in itertools.chain.from_iterable(s for s in self.stashes.values()) ] elif k == 'mp_' + SimulationManager.ALL: return mulpyplexer.MP([ p for p in itertools.chain.from_iterable(s for s in self.stashes.values()) ]) elif k.startswith('mp_'): return mulpyplexer.MP(self.stashes[k[3:]]) elif k.startswith('one_') and k[4:] in self.stashes: return self.stashes[k[4:]][0] elif k in self.stashes: return self.stashes[k] else: raise AttributeError(k)
def _fetch_states(self, stash): if stash in self._stashes: return self._stashes[stash] elif stash == SimulationManager.ALL: return list(itertools.chain.from_iterable(self._stashes.values())) elif stash == 'mp_' + SimulationManager.ALL: return mulpyplexer.MP(self._fetch_states(stash=SimulationManager.ALL)) elif stash.startswith('mp_'): return mulpyplexer.MP(self._stashes.get(stash[3:], [])) elif stash.startswith('one_'): return self._stashes.get(stash[4:], [None])[0] else: raise AttributeError("No such stash: %s" % stash)
def mulpyplex(self, *stashes): """ Mulpyplex across several stashes. :param stashes: the stashes to mulpyplex :return: a mulpyplexed list of states from the stashes in question, in the specified order """ return mulpyplexer.MP(list(itertools.chain.from_iterable(self.stashes[s] for s in stashes)))
def mp_successors(self): return mulpyplexer.MP(self.successors)
def __getattr__(self, k): if k.startswith('mp_'): return mulpyplexer.MP(self.stashes[k[3:]]) else: return self.stashes[k]