Skip to content

Commit

Permalink
gh-38278: Deprecate is_Infinite
Browse files Browse the repository at this point in the history
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes #12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes #12345". -->

Part of:
- #32414

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - #12345: short description why this is a dependency -->
<!-- - #34567: ... -->
    
URL: #38278
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
  • Loading branch information
Release Manager committed Jul 20, 2024
2 parents 89c7d56 + 23f0d07 commit 8ec83bc
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/sage/geometry/fan_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
from sage.modules.free_module_morphism import FreeModuleMorphism
from sage.rings.infinity import Infinity
from sage.rings.integer_ring import ZZ
from sage.rings.infinity import is_Infinite
from sage.rings.infinity import InfinityElement
from functools import reduce


Expand Down Expand Up @@ -1458,7 +1458,7 @@ def is_surjective(self):
sage: phi.is_surjective()
False
"""
if is_Infinite(self.index()):
if isinstance(self.index(), InfinityElement):
return False # Not surjective between vector spaces.
for dcones in self.codomain_fan().cones():
for sigma_p in dcones:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/modular/arithgroup/arithgroup_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ cdef class ArithmeticSubgroupElement(MultiplicativeGroupElement):
sage: G([1, 4, 0, 1]).acton(infinity)
+Infinity
"""
from sage.rings.infinity import is_Infinite, infinity
if is_Infinite(z):
from sage.rings.infinity import InfinityElement, infinity
if isinstance(z, InfinityElement):
if self.c() != 0:
return self.a() / self.c()
else:
Expand Down
7 changes: 7 additions & 0 deletions src/sage/rings/infinity.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,10 @@ def is_Infinite(x) -> bool:
EXAMPLES::
sage: sage.rings.infinity.is_Infinite(oo)
doctest:warning...
DeprecationWarning: The function is_Infinite is deprecated;
use 'isinstance(..., InfinityElement)' instead.
See https://github.com/sagemath/sage/issues/38022 for details.
True
sage: sage.rings.infinity.is_Infinite(-oo)
True
Expand All @@ -988,6 +992,9 @@ def is_Infinite(x) -> bool:
sage: sage.rings.infinity.is_Infinite(ZZ)
False
"""
from sage.misc.superseded import deprecation
deprecation(38022, "The function is_Infinite is deprecated; use 'isinstance(..., InfinityElement)' instead.")

return isinstance(x, InfinityElement)


Expand Down
6 changes: 3 additions & 3 deletions src/sage/rings/multi_power_series_ring_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
from sage.structure.richcmp import richcmp

from sage.rings.finite_rings.integer_mod_ring import Zmod
from sage.rings.infinity import infinity, is_Infinite
from sage.rings.infinity import infinity, InfinityElement
from sage.rings.integer import Integer
from sage.rings.polynomial.polynomial_ring import is_PolynomialRing
from sage.rings.power_series_ring import is_PowerSeriesRing
Expand Down Expand Up @@ -1956,7 +1956,7 @@ def exp(self, prec=infinity):
assert (val >= 1)

prec = min(prec, self.prec())
if is_Infinite(prec):
if isinstance(prec, InfinityElement):
prec = R.default_prec()
n_inv_factorial = R.base_ring().one()
x_pow_n = Rbg.one()
Expand Down Expand Up @@ -2053,7 +2053,7 @@ def log(self, prec=infinity):
assert (val >= 1)

prec = min(prec, self.prec())
if is_Infinite(prec):
if isinstance(prec, InfinityElement):
prec = R.default_prec()
x_pow_n = Rbg.one()
log_x = Rbg.zero().add_bigoh(prec)
Expand Down
10 changes: 5 additions & 5 deletions src/sage/rings/power_series_ring_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ With power series the behavior is the same.
# ****************************************************************************

from cpython.object cimport Py_EQ, Py_NE
from sage.rings.infinity import infinity, is_Infinite
from sage.rings.infinity import infinity, InfinityElement

from sage.rings.rational_field import QQ

Expand Down Expand Up @@ -1900,7 +1900,7 @@ cdef class PowerSeries(AlgebraElement):
assert(val >= 1)

prec = min(prec, self.prec())
if is_Infinite(prec):
if isinstance(prec, InfinityElement):
prec = R.default_prec()
n_inv_factorial = R.base_ring().one()
x_pow_n = R.one()
Expand Down Expand Up @@ -1986,7 +1986,7 @@ cdef class PowerSeries(AlgebraElement):
x = self

prec = min(prec, self.prec())
if is_Infinite(prec):
if isinstance(prec, InfinityElement):
prec = R.default_prec()
n_inv_factorial = R.base_ring().one()
x_pow_n = x
Expand Down Expand Up @@ -2139,7 +2139,7 @@ cdef class PowerSeries(AlgebraElement):
x = self

prec = min(prec, self.prec())
if is_Infinite(prec):
if isinstance(prec, InfinityElement):
prec = R.default_prec()
n_inv_factorial = R.base_ring().one()
x_pow_n = x
Expand Down Expand Up @@ -2227,7 +2227,7 @@ cdef class PowerSeries(AlgebraElement):
assert(val >= 1)

prec = min(prec, self.prec())
if is_Infinite(prec):
if isinstance(prec, InfinityElement):
prec = R.default_prec()
n_inv_factorial = R.base_ring().one()
x_pow_n = R.one()
Expand Down

0 comments on commit 8ec83bc

Please sign in to comment.