Skip to content

Commit

Permalink
Sanitize assumptions on symbols.
Browse files Browse the repository at this point in the history
Convert assumptions to bool (this needs to happen before caching).

Fixes issue 3567: Sanitize FactKB
http://code.google.com/p/sympy/issues/detail?id=3567
  • Loading branch information
jrioux committed Nov 8, 2013
1 parent 716ba18 commit a66bcc6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sympy/core/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def __new__(cls, name, **assumptions):
raise ValueError(
'''Symbol commutativity must be True or False.''')
assumptions['commutative'] = is_commutative
for key in assumptions.keys():
assumptions[key] = bool(assumptions[key])
return Symbol.__xnew_cached_(cls, name, **assumptions)

def __new_stage2__(cls, name, **assumptions):
Expand Down
7 changes: 7 additions & 0 deletions sympy/core/tests/test_assumptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,13 @@ def test_issue_3176():
assert (b*0).is_zero is None


def test_sanitize_assumptions():
# issue 3567
x = Symbol('x', real=1, positive=0)
assert x.is_real is True
assert x.is_positive is False


def test_special_assumptions():
x = Symbol('x')
z2 = z = Symbol('z', zero=True)
Expand Down

0 comments on commit a66bcc6

Please sign in to comment.