Example #1
0
 def __repr__(self):
     '''
     Get a string representation of the node range.
     
     Example output:
     <garlicsim.data_structures.NodeRange, from node with clock 2 to block
     that ends at clock 102, containing 101 nodes total, at 0x291c550>
     '''
     return '<%s, from %s %s to %s %s, containing %s nodes total, at %s>' \
            % (
                
                misc_tools.shorten_class_address(
                    self.__class__.__module__,
                    self.__class__.__name__
                    ),
                
                'block that starts at clock' if isinstance(self.start, Block) \
                else 'node with clock',
                
                self.start[0].state.clock if isinstance(self.start, Block) \
                else self.start.state.clock,
                
                'block that ends at clock' if \
                isinstance(self.end, Block) else 'node with clock',
                
                self.end[-1].state.clock if isinstance(self.end, Block) \
                else self.end.state.clock,
                
             cute_iter_tools.get_length(self),
             
             hex(id(self))
            )
Example #2
0
    def __repr__(self):
        '''
        Get a string representation of the project.
        
        Example output:
        
        <garlicsim.Project containing 101 nodes and employing 4 crunchers at
        0x1f668d0>
        '''
        # Todo: better have the simpack mentioned here, not doing it cause it's
        # currently in a module wrapper.
        
        nodes_count = len(self.tree.nodes)
        crunchers_count = len(self.crunching_manager.crunchers)
                                   
        return '''<%s containing %s nodes and employing %s crunchers at \
%s>''' % \
               (
                   misc_tools.shorten_class_address(
                       self.__class__.__module__,
                       self.__class__.__name__
                   ),
                   nodes_count,
                   crunchers_count,
                   hex(id(self))
               )
        
        
        
        
        
        
Example #3
0
 def __repr__(self):
     '''
     Get a string representation of the path.
     
     Example output:
     <garlicsim.data_structures.Path of length 43 at 0x1c822d0>
     '''
     return '<%s of length %s at %s>' % \
            (
                misc_tools.shorten_class_address(
                    self.__class__.__module__,
                    self.__class__.__name__
                ),
                len(self),
                hex(id(self))
            )
Example #4
0
 def __repr__(self):
     '''
     Get a string representation of the emitter.
     
     Example output:        
     <garlicsim_wx.general_misc.emitters.emitter.Emitter 'tree_modified' at
     0x1c013d0>
     '''
     return '<%s %sat %s>' % (
         misc_tools.shorten_class_address(
                    self.__class__.__module__,
                    self.__class__.__name__
                    ),
         ''.join(("'", self.name, "' ")) if self.name else '',
         hex(id(self))
     )
Example #5
0
 def __repr__(self):
     '''
     Get a string representation of the state.
     
     Example output:
     <garlicsim.data_structures.State with clock 32.3 at 0x1c822d0>
     ''' 
     return '<%s %sat %s>' % \
            (
                misc_tools.shorten_class_address(
                    self.__class__.__module__,
                    self.__class__.__name__
                    ),
                'with clock %s ' % self.clock if hasattr(self, 'clock') \
                                   else '',
                hex(id(self))
            )
Example #6
0
 def __repr__(self):
     '''
     Get a string representation of the end.
     
     Example output:        
     <garlicsim.data_structures.End from state with clock 6.5, crunched with
     StepProfile(t=0.1), at 0x1ffde70>
     '''
     
     return '<%s from state with clock %s, crunched with %s, at %s>' % \
         (
             misc_tools.shorten_class_address(
                 self.__class__.__module__,
                 self.__class__.__name__
                 ),
             self.parent.state.clock,
             self.step_profile,
             hex(id(self))
         )
Example #7
0
 def __repr__(self):
     '''
     Get a string representation of the block.
     
     Example output:
     <garlicsim.data_structures.Block of length 40 crunched with
     StepProfile(t=0.1) at 0x1c84d70>
     '''
     assert self.alive # todo: say "Dead block"
     return '<%s of length %s, crunched with %s at %s>' % \
            (
                misc_tools.shorten_class_address(
                    self.__class__.__module__,
                    self.__class__.__name__
                ),
                len(self),
                self.get_step_profile(),
                hex(id(self))
            )
Example #8
0
 def __repr__(self):
     '''
     Get a string representation of the crunching manager.
     
     Example output:
     <garlicsim.asynchronous_crunching.CrunchingManager
     currently employing 2 crunchers to handle 2 jobs at 0x1f699b0>
     '''
     
     crunchers_count = len(self.crunchers)
     job_count = len(self.jobs)
                                
     return '<%s currently employing %s crunchers to handle %s jobs at %s>' % \
            (
                misc_tools.shorten_class_address(
                    self.__class__.__module__,
                    self.__class__.__name__
                ),
                crunchers_count,
                job_count,
                hex(id(self))
            )
Example #9
0
 def __repr__(self):
     '''
     Get a string representation of the node.
     
     Example output:        
     <garlicsim.data_structures.Node with clock 6.5, untouched, belongs to a
     block, crunched with StepProfile(t=0.1), at 0x1ffde70>
     '''
     return '<%s%s, %s%s%s, %s, %sat %s>' % \
         (
             misc_tools.shorten_class_address(
                 self.__class__.__module__,
                 self.__class__.__name__
                 ),
             ' with clock %s' % self.state.clock if hasattr(self.state, 'clock') else '',
             'root, ' if (self.parent is None) else '',
             'leaf, ' if (len(self.children) == 0) else '',
             'touched' if self.touched else 'untouched',
             'belongs to a block' if self.block else 'blockless',
             'crunched with %s, ' % self.step_profile if self.step_profile else '',
             hex(id(self))
         )
Example #10
0
def _get_from_state_class(state_class):
    '''
    Find the simpack that a state class belong to.
    
    Internal use.
    '''
    assert state_class.__name__ == 'State' # remove this limitation
    original_module_name = state_class.__module__
    short_address = misc_tools.shorten_class_address(original_module_name,
                                                     state_class.__name__)
    simpack_name = '.'.join(short_address.split('.')[:-1])
    simpack = __import__(simpack_name, fromlist=[''])
    try:
        garlicsim.misc.simpack_grokker.SimpackGrokker(simpack)
        # Not saving the reference: But it'll get cached because SimpackGrokker
        # is a CachedType.
    except garlicsim.misc.InvalidSimpack:
        raise garlicsim.misc.GarlicSimException('''Could not guess simpack \
correctly from state object.''')
    return simpack