<s> __author__ = '<STR_LIT>' <EOL> import numpy as np <EOL> import itertools as itools <EOL> import hashlib <EOL> import pypet . compat as compat <EOL> from collections import deque <EOL> class Universe ( object ) : <EOL> """<STR_LIT>""" <EOL> def __contains__ ( self , item ) : <EOL> return True <EOL> class IteratorChain ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , * iterables ) : <EOL> self . _chain = deque ( ) <EOL> self . _current = iter ( [ ] ) <EOL> self . add ( * iterables ) <EOL> def add ( self , * iterables ) : <EOL> """<STR_LIT>""" <EOL> self . _chain . extend ( iterables ) <EOL> def next ( self ) : <EOL> """<STR_LIT>""" <EOL> while True : <EOL> try : <EOL> return next ( self . _current ) <EOL> except StopIteration : <EOL> try : <EOL> self . _current = iter ( self . _chain . popleft ( ) ) <EOL> except IndexError : <EOL> raise StopIteration ( '<STR_LIT>' ) <EOL> def __next__ ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . next ( ) <EOL> def __iter__ ( self ) : <EOL> while True : <EOL> yield self . next ( ) <EOL> class ChainMap ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , * maps ) : <EOL> self . _maps = maps <EOL> def __getitem__ ( self , key ) : <EOL> for mapping in self . _maps : <EOL> try : <EOL> return mapping [ key ] <EOL> except KeyError : <EOL> pass <EOL> raise KeyError ( key ) <EOL> def __len__ ( self ) : <EOL> length = <NUM_LIT:0> <EOL> for mapping in self . _maps : <EOL> length += len ( mapping ) <EOL> return length <EOL> def __iter__ ( self ) : <EOL> iter_list = [ compat . iterkeys ( mapping ) for mapping in self . _maps ] <EOL> return itools . chain ( * iter_list ) <EOL> class HashArray ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , ndarray ) : <EOL> """<STR_LIT>""" <EOL> self . _ndarray = ndarray <EOL> def __eq__ ( self , other ) : <EOL> try : <EOL> return np . all ( self . _ndarray == other . _ndarray ) <EOL> except AttributeError : <EOL> return False <EOL> def __hash__ ( self ) : <EOL> return int ( hashlib . sha1 ( self . _ndarray . view ( np . uint8 ) ) . hexdigest ( ) , <NUM_LIT:16> ) <EOL> class TrajectoryMock ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , traj ) : <EOL> self . v_environment_name = traj . v_environment_name <EOL> self . v_name = traj . v_name <EOL> self . v_crun_ = traj . v_crun_ <EOL> self . v_crun = traj . v_crun <EOL> self . v_idx = traj . v_idx </s>
