Commits

Pierre Carbonnelle committed 7b2cbd6

various fixes in examples

Comments (0)

Files changed (3)

pyDatalog/examples/Mongo.py

 from pyDatalog import pyDatalog
 
 print("\n *** combined SQLite and Mongo query :\n")
-X, N, Diploma = pyDatalog.variables(3)
+pyDatalog.create_atoms('X, N, Diploma')
 
 # Who has a salary of 6800 and a MSc. diploma
 (Employee.salary[X]==6800) & (Employee.diploma[X]=="MSc.")

pyDatalog/examples/test.py

     p(Y)
     assert (Y._value() == ['a',])
     p(Decimal(2.0))
-    assert p(Y) > Y == Decimal(2.0)
+    assert p(Y) >= Y == Decimal(2.0)
     
     X = pyDatalog.Variable()
     pyDatalog.create_atoms('X')

pyDatalog/examples/test_of_performance.py

         
     @pyDatalog.program()
     def _(): # the function name is ignored
-        assert ask(successor(1801,1800)) == set([(1801, 1800)])
+        assert ask(successor(1801,1800)) == set([()])
 
         + even(0)
         even(N) <= (N > 0) & successor(N,N1) & odd(N1)
         odd(N) <= (N > 0) & successor(N,N2) & even(N2)
         
-        assert ask(odd(299)) == set([(299,)]) 
-        assert ask(odd(9999)) == set([(9999,)])
+        assert ask(odd(299)) == set([()]) 
+        assert ask(odd(9999)) == set([()])
         
         # TODO why is this much much slower ??
         # odd(N) <= even(N1) & successor(N, N1)
 
         + even(0)
         even(N) <= (N > 0) & odd(N-1)
-        assert ask(even(0)) == set([(0,)])
+        assert ask(even(0)) == set([()])
         odd(N) <= (N > 0) & even(N-1)
 
-        assert ask(odd(9999)) == set([(9999,)])
+        assert ask(odd(9999)) == set([()])
 
 if __name__ == "__main__":
     start_time = time.time()