Skip to content

Commit

Permalink
Merge pull request #18324 from sachin-4099/17882_typerr
Browse files Browse the repository at this point in the history
solvers: Fixed NoneType Error
  • Loading branch information
jksuom committed Feb 5, 2020
2 parents a8a3a3b + c56e359 commit 530df75
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion sympy/solvers/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3460,7 +3460,10 @@ def _take(d, take_int_pow):
# check for trivial case
# - already a polynomial in integer powers
if all(_Q(g) == 1 for g in gens):
return
if (len(gens) == len(poly.gens) and d!=1):
return eq, []
else:
return
# - an exponent has a symbol of interest (don't handle)
if any(g.as_base_exp()[1].has(*syms) for g in gens):
return
Expand Down
3 changes: 2 additions & 1 deletion sympy/solvers/solveset.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,8 @@ def _has_rational_power(expr, symbol):

def _solve_radical(f, symbol, solveset_solver):
""" Helper function to solve equations with radicals """
eq, cov = unrad(f)
res = unrad(f)
eq, cov = res if res else (f, [])
if not cov:
result = solveset_solver(eq, symbol) - \
Union(*[solveset_solver(g, symbol) for g in denoms(f, symbol)])
Expand Down
5 changes: 5 additions & 0 deletions sympy/solvers/tests/test_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,11 @@ def test_issue_17650():
assert solve(abs((abs(x**2 - 1) - x)) - x) == [1, -1 + sqrt(2), 1 + sqrt(2)]


def test_issue_17882():
eq = -8*x**2/(9*(x**2 - 1)**(S(4)/3)) + 4/(3*(x**2 - 1)**(S(1)/3))
assert unrad(eq) == (4*x**2 - 12, [])


def test_issue_17949():
assert solve(exp(+x+x**2), x) == []
assert solve(exp(-x+x**2), x) == []
Expand Down
5 changes: 5 additions & 0 deletions sympy/solvers/tests/test_solveset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1916,6 +1916,11 @@ def test_issue_14454():
assert invert_real(x**2, number, x, S.Reals) # no error


def test_issue_17882():
assert solveset(-8*x**2/(9*(x**2 - 1)**(S(4)/3)) + 4/(3*(x**2 - 1)**(S(1)/3)), x, S.Complexes) == \
FiniteSet(sqrt(3), -sqrt(3))


def test_term_factors():
assert list(_term_factors(3**x - 2)) == [-2, 3**x]
expr = 4**(x + 1) + 4**(x + 2) + 4**(x - 1) - 3**(x + 2) - 3**(x + 3)
Expand Down

0 comments on commit 530df75

Please sign in to comment.