Exemplo n.º 1
0
 def iterate( self, steps, shuffler=None, **kwds ):
     """
     Iterates over the lines 'steps' times. 
     """
     shuffler = shuffler or self.shuffler
     for index in range(steps):
         self.parser.RULE_START_ITERATION( index, self )
         BoolModel.state_update(self)
         lines = shuffler( )
         list(map( self.local_parse, lines )) 
Exemplo n.º 2
0
 def initialize(self, missing=None, defaults={} ):
     "Initializes the TimeModel"
     self.mode = ruleparser.TIME
     BoolModel.initialize( self, missing=missing, defaults=defaults )
     
     if not self.label_tokens:
         util.error( 'this mode of operation requires time labels for rules' )
     
     self.gcd   = util.list_gcd( self.ranks )
     self.step  = 0
     self.times = [ 0 ]
Exemplo n.º 3
0
    def initialize(self, missing=None, defaults={}):
        "Custom initializer"

        BoolModel.initialize(self, missing=missing, defaults=defaults)
        super(PldeModel, self).initialize(missing=missing, defaults=defaults)
        # will also maintain the order of insertion
        self.mapper = odict.odict()
        self.indexer = {}
        # this will maintain the order of nodes
        self.nodes = list(self.nodes)
        self.nodes.sort()
        for index, node in enumerate(self.nodes):
            triplet = self.first[node]
            self.mapper[node] = (index, node, triplet)
            self.indexer[node] = index

        # a sanity check
        assert self.nodes == self.mapper.keys()
Exemplo n.º 4
0
 def initialize(self, missing=None, defaults={} ):
     "Custom initializer"
     BoolModel.initialize( self, missing=missing, defaults=defaults )
     
     # will also maintain the order of insertion
     self.mapper  = odict.odict() 
     self.indexer = {}
     
     # this will maintain the order of nodes
     self.nodes = list(self.nodes)
     self.nodes.sort()
     for index, node in enumerate(self.nodes):
         triplet = self.first[node]
         self.mapper [node] = ( index, node, triplet )
         self.indexer[node] = index
     
     # a sanity check
     assert self.nodes == self.mapper.keys()
Exemplo n.º 5
0
    def __init__(self, text, mode='plde'):

        # run the regular boolen engine for one step to detect syntax errors
        model = BoolModel(text=text, mode='sync')
        model.initialize(missing=util.randbool)
        model.iterate(steps=1)

        # onto the main initialization
        self.INIT_LINE = helper.init_line
        self.OVERRIDE = default_override
        self.DEFAULT_EQUATION = default_equation
        self.EXTRA_INIT = ''

        # setting up this engine
        BoolModel.__init__(self, text=text, mode=mode)
        self.dynamic_code = '*** not yet generated ***'
        self.lazy_data = {}
Exemplo n.º 6
0
    def __init__(self, text, mode='plde'):
        
        # run the regular boolen engine for one step to detect syntax errors
        model = BoolModel(text=text, mode='sync')
        model.initialize( missing=util.randbool )
        model.iterate( steps=1 )

        # onto the main initialization
        self.INIT_LINE  = helper.init_line
        self.OVERRIDE   = default_override
        self.DEFAULT_EQUATION = default_equation
        self.EXTRA_INIT = ''

        # setting up this engine
        BoolModel.__init__(self, text=text, mode=mode)
        self.dynamic_code = '*** not yet generated ***'
        self.lazy_data = {}