Esempio n. 1
0
def get_states( mode, text, steps, missing=None):
    """
    Helper function to generate the states
    """
    eng  = boolean.Model( mode=mode, text=text )
    eng.initialize( missing=missing )
    eng.iterate( steps=steps )
    return eng.states
Esempio n. 2
0
    def test_plde_engine( self ):
        "Testing PLDE (no ranks)"
        
        EQ = self.assertEqual

        text = """
        A = B = True
        C = False
        A* = A
        B* = A and B
        C* = not C
        """
        eng  = boolean.Model( mode='plde', text=text )
        eng.initialize()
        eng.iterate( fullt=1, steps=10 )
        EQ( len(eng.data), 3)
        EQ( len(eng.data['A']), 10)
Esempio n. 3
0
    def test_initializer( self ):
        "Testing initializer (no ranks)"
        
        EQ = self.assertEqual

        text = """
        A = False
        A* = A
        B* = A and B
        C* = not C
        """
        eng  = boolean.Model( mode='sync', text=text )
        eng.initialize( missing= boolean.util.allfalse, defaults=dict(A=True, B=True) )
        eng.iterate( steps=10 )
        EQ( eng.start.A, True )
        EQ( eng.start.B, True )
        EQ( eng.start.C, False )
        EQ( len(eng.states), 11)
Esempio n. 4
0
    def test_model( self ):
        "Basic operation"
        
        EQ = self.assertEqual

        text = """
        A = B = True
        C = False
        A* = A
        B* = A and B
        C* = not C
        """
        eng  = boolean.Model( mode='sync', text=text )
        eng.initialize()
        eng.iterate( steps=5 )
        
        EQ( eng.start.A, True )
        EQ( eng.start.B, True )
        EQ( eng.start.C, False )

        EQ( eng.last.A, True )
        EQ( eng.last.B, True )
        EQ( eng.last.C, True )