Skip to content

Commit

Permalink
Merge pull request #19986 from maurogaravello/issue-19718
Browse files Browse the repository at this point in the history
solveset with piecewise: issue 19718
  • Loading branch information
oscarbenjamin committed Aug 31, 2020
2 parents de4fd86 + dd1cdae commit 0c6b331
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sympy/solvers/solveset.py
Expand Up @@ -969,6 +969,10 @@ def _solveset(f, symbol, domain, _check=False):
given symbol."""
# _check controls whether the answer is checked or not
from sympy.simplify.simplify import signsimp
from sympy.logic.boolalg import BooleanTrue

if isinstance(f, BooleanTrue):
return domain

orig_f = f
if f.is_Mul:
Expand Down Expand Up @@ -1008,7 +1012,6 @@ def _solveset(f, symbol, domain, _check=False):
a = f.args[0]
result = solveset_real(a > 0, symbol)
elif f.is_Piecewise:
result = EmptySet
expr_set_pairs = f.as_expr_set_pairs(domain)
for (expr, in_set) in expr_set_pairs:
if in_set.is_Relational:
Expand Down
8 changes: 8 additions & 0 deletions sympy/solvers/tests/test_solveset.py
Expand Up @@ -694,6 +694,14 @@ def test_piecewise_solveset():

assert solveset(Piecewise((x - 1, Ne(x, I)), (x, True)), x) == FiniteSet(1)

# issue 19718
g = Piecewise((1, x > 10), (0, True))
assert solveset(g > 0, x, S.Reals) == Interval.open(10, oo)

from sympy.logic.boolalg import BooleanTrue
f = BooleanTrue()
assert solveset(f, x, domain=Interval(-3, 10)) == Interval(-3, 10)


def test_solveset_complex_polynomial():
assert solveset_complex(a*x**2 + b*x + c, x) == \
Expand Down

0 comments on commit 0c6b331

Please sign in to comment.