Skip to content

Commit

Permalink
polys: correct conversion of expressions to field elements
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Feb 3, 2022
1 parent 457d969 commit f6eacef
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions diofant/polys/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ def from_expr(self, expr):
def _rebuild(expr):
if (generator := mapping.get(expr)) is not None:
return generator
elif 1/expr in mapping:
return 1/mapping[1/expr]
elif expr.is_Add:
return functools.reduce(operator.add, list(map(_rebuild, expr.args)))
elif expr.is_Mul:
Expand Down
4 changes: 4 additions & 0 deletions diofant/tests/domains/test_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,10 @@ def test_Domain__contains__():

assert F(1) in ZZ

# issue sympy/sympy#14433
F = QQ.inject(1/x).field
assert all(_ in F for _ in [x, 1/x])


def test_Domain_ring():
assert ZZ.has_assoc_Ring is True
Expand Down
1 change: 1 addition & 0 deletions docs/release/notes-0.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ These Sympy issues also were addressed:
* :sympyissue:`22878`: RecursionError in trigsimp
* :sympyissue:`22982`: limit((log(E + 1/x) - 1)**(1 - sqrt(E + 1/x)), x, oo) returns 0 instead of oo
* :sympyissue:`22986`: limit(acosh(1 + 1/x)*sqrt(x), x, oo) is evaluated incorrectly.
* :sympyissue:`14433`: x not in QQ.frac_field(1/x)

0 comments on commit f6eacef

Please sign in to comment.