Skip to content

Remove compilation dependency of rings/convert/mpfi on cypari2 #40231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions src/sage/doctest/rif_tol.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
# ****************************************************************************

from sage.doctest.marked_output import MarkedOutput
from sage.rings.real_mpfi import RealIntervalField, RealIntervalFieldElement

_RIFtol: 'RealIntervalField | None' = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never seen this Python syntax - what does it do?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a type annotation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a type annotation!


_RIFtol = None


def RIFtol(*args):
def RIFtol(*args) -> RealIntervalFieldElement:
"""
Create an element of the real interval field used for doctest tolerances.

Expand All @@ -57,18 +57,7 @@ def RIFtol(*args):
"""
global _RIFtol
if _RIFtol is None:
try:
# We need to import from sage.all to avoid circular imports.
from sage.rings.real_mpfi import RealIntervalField
except ImportError:
from warnings import warn
warn("RealIntervalField not available, ignoring all tolerance specifications in doctests")

def fake_RIFtol(*args):
return 0
_RIFtol = fake_RIFtol
else:
_RIFtol = RealIntervalField(1044)
_RIFtol = RealIntervalField(1044)
return _RIFtol(*args)


Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/convert/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ foreach name, pyx : extension_data
subdir: 'sage/rings/convert',
install: true,
include_directories: [inc_cpython, inc_rings],
dependencies: [py_dep, cypari2, gmp, gsl, mpfi, mpfr, pari],
dependencies: [py_dep, gmp, gsl, mpfi, mpfr],
)
endforeach

3 changes: 1 addition & 2 deletions src/sage/rings/convert/mpfi.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ from sage.rings.complex_mpfr cimport ComplexNumber
from sage.rings.complex_interval cimport ComplexIntervalFieldElement
from sage.rings.complex_double cimport ComplexDoubleElement

from cypari2.gen cimport Gen


cdef inline int return_real(mpfi_ptr im) noexcept:
"""
Expand Down Expand Up @@ -440,6 +438,7 @@ cdef int mpfi_set_sage(mpfi_ptr re, mpfi_ptr im, x, field, int base) except -1:
return return_real(im)

# Complex
from cypari2.gen import Gen
if isinstance(x, Gen):
imag = x.imag()
if im is NULL:
Expand Down
Loading