Skip to content

Commit

Permalink
Merge pull request #28 from pysmt/eager_model_contains
Browse files Browse the repository at this point in the history
Bugfix: Implemented EagerModel.__contains__
  • Loading branch information
mikand committed Mar 3, 2015
2 parents 1f50d94 + 238c96f commit e3d7d16
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pysmt/solvers/eager.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ def __iter__(self):
include more variables.
"""
return iter(self.assignment.items())

def __contains__(self, x):
"""Returns whether the model contains a value for 'x'."""
return x in self.assignment
7 changes: 7 additions & 0 deletions pysmt/test/test_eager_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ def test_complete_model(self):
self.assertTrue(model.get_value(p).is_constant(INT))
self.assertTrue(model.get_value(r).is_constant(REAL))

def test_contains(self):
x, y, z = [FreshSymbol() for _ in xrange(3)]
d = {x: TRUE(), y: FALSE()}
model = EagerModel(assignment=d,
environment=get_env())
self.assertTrue(x in model)
self.assertFalse(z in model)

if __name__ == '__main__':
import unittest
Expand Down

0 comments on commit e3d7d16

Please sign in to comment.