Skip to content

Conversation

orlitzky
Copy link
Contributor

@orlitzky orlitzky commented Oct 8, 2025

A third attempt at supporting mpmath 1.4.x. Previous PRs:

mpmath 1.4.x is still in alpha, so we can't require it yet, but we can try to support it. This isn't too difficult given that mpmath.__version__ is available to python, but there are some major cython changes that are better hidden behind a conditional compile.

The new PR makes things compatible where possible, copy/pastes an entire function in one case, and even uses a separate file utils13.pyx in another. A new feature is added to hide the 1.3.x doctests on 1.4.

Tweak some expected output to work with both versions of mpmath.
Certain types that used to be implemented in sage are now a part
of mpmath itself, so the class names have changed. Fortunately
it looks like we can match both with enough "..."
This file needs an update to support mpmath-1.4.x, and the changes
can't easily be conditionalized (cimports are involved). Instead
we make a copy, with the intention of using meson to conditionally
compile one or the other based on the value of mpmath.__version__
at build-time.
To support both versions of mpmath, we create an internal copy of the
existing py_scalar_parent() function, and update the original to
support mpmath-1.4.x. If mpmath.__version__ indicates that v1.3 is in
use, we punt to the old copy of the function.

The copy/paste is ugly, but considering that it's only temporary,
emphasis is placed on how easy it will be to undo eventually.
mpmath v1.3 and v1.4 build very differently. Rather than try to
support both simultaneously with the same set of files, we
conditionalize the build to check mpmath.__version__ via python,
and respond accordingly.
@orlitzky orlitzky marked this pull request as draft October 8, 2025 16:29
To support mpmath v1.3 and v1.4 simultaneously, we have some sage
library files that are only used mpmath-1.3.x is installed. The
tests in these files will fail with mpmath-1.4, however, so we
add a new feature to detect mpmath-1.3.x.
Most of these files are only used (and can only be tested) under
mpmath-1.3.x. We now have a "feature" for that version, and just
need to add the appropriate file-level tags.
Now that we have a feature for "mpmath13", the doctests for the
mpmath-1.3.x copy of py_scalar_parent() are put back in place.
It isn't smart enough to handle an if/else statement that doesn't
apply.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant