Merge branch 'master' into release-v1.4

This commit is contained in:
Sergey B Kirpichev
2026-02-22 13:56:05 +03:00
7 changed files with 85 additions and 12 deletions
+16
View File
@@ -0,0 +1,16 @@
// .backportrc.json -- for https://github.com/sorenlouv/backport
{
// Required
"repoOwner": "mpmath",
"repoName": "mpmath",
// the branches available to backport to
"targetBranchChoices": ["mpmath-1.4.x"],
// Automatically detect which branches a pull request should be
// backported to based on the pull request labels.
"branchLabelMapping": {
"^backport-to-(.+)$": "mpmath-$1"
},
"targetPRLabels": ["backport"],
"sourcePRLabels": ["backport-pr-created"],
"commitConflicts": true
}
+37
View File
@@ -0,0 +1,37 @@
name: Automatic backport action
on:
pull_request_target:
types: ["labeled", "closed"]
permissions:
contents: write # so it can comment
pull-requests: write # so it can create pull requests
jobs:
backport:
name: Backport PR
if: github.event.pull_request.merged == true && !(contains(github.event.pull_request.labels.*.name, 'backport')) && !(contains(github.event.pull_request.labels.*.name, 'backport-pr-created'))
runs-on: ubuntu-24.04
steps:
# Workaround not to fail the workflow if the PR does not need a backport
# https://github.com/sorenlouv/backport-github-action/issues/127#issuecomment-2277248320
- name: Check for backport labels
id: check_labels
run: |-
labels='${{ toJSON(github.event.pull_request.labels.*.name) }}'
matched=$(echo "${labels}" | jq '. | map(select(startswith("backport-to-"))) | length')
echo "matched=$matched"
echo "matched=$matched" >> $GITHUB_OUTPUT
- name: Backport Action
if: fromJSON(steps.check_labels.outputs.matched) > 0
uses: sorenlouv/backport-github-action@v10.2.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
auto_backport_label_prefix: backport-to-
- name: Info log
if: ${{ success() && fromJSON(steps.check_labels.outputs.matched) > 0 }}
run: cat ~/.backport/backport.info.log
- name: Debug log
if: ${{ failure() && fromJSON(steps.check_labels.outputs.matched) > 0 }}
run: cat ~/.backport/backport.debug.log
+3
View File
@@ -166,6 +166,8 @@ Bug fixes:
* Properly handle nan's elliprj(), see #1038 (Sergey B Kirpichev)
* Raise ValueError for logm(0), see #1017 (Ayush Baranwal)
* Fix erf(z) with re(z) of large magnitude, see #1039 (Sergey B Kirpichev)
* Return nan's for polylog(s, nan) or polylog(s, nan+nanj),
see #1041 (Sergey B Kirpichev)
Maintenance:
@@ -201,6 +203,7 @@ Maintenance:
* Build and publish wheel, see #913 (David Hotham)
* Use the intended setuptools_scm integration pattern, see #940 (Ronny
Pfannschmidt)
* Add backport action, see #1042 (Sergey B Kirpichev)
See the release milestone (1.4) for a complete list of issues and pull requests
involved in this release.
+6
View File
@@ -40,6 +40,9 @@ parser.add_argument('--prec', type=int,
help='Set default mpmath precision')
parser.add_argument('--no-pretty', help='Disable pretty-printing',
action='store_true')
parser.add_argument('--int-limits',
help="Enable string conversion length limitation for int's",
action='store_true')
def main():
@@ -49,6 +52,9 @@ def main():
print(__version__)
sys.exit(0)
if not args.int_limits:
sys.set_int_max_str_digits(0)
lines = ['from mpmath import *',
'from fractions import Fraction']
+4
View File
@@ -493,6 +493,10 @@ def polylog(ctx, s, z):
return polylog_series(ctx, s, z)
if abs(z) >= 1.4 and ctx.isint(s):
return (-1)**(s+1)*polylog_series(ctx, s, 1/z) + polylog_continuation(ctx, int(ctx.re(s)), z)
if ctx.isnan(z):
if ctx._is_real_type(z) and ctx.isnpint(s):
return ctx.nan
return ctx.mpc(ctx.nan, ctx.nan)
if ctx.isint(s):
return polylog_unitcircle(ctx, int(ctx.re(s)), z)
return polylog_general(ctx, s, z)
+2 -1
View File
@@ -15,7 +15,8 @@ if platform.python_implementation() == 'PyPy':
def test_bare_console_no_bare_division():
c = Console(f'{sys.executable} -m mpmath --no-ipython --no-wrap-floats')
c = Console(f'{sys.executable} -m mpmath --no-ipython '
'--no-wrap-floats --int-limits') # for coverage
assert c.expect_exact('>>> ') == 0
assert c.send('1 + 2\r\n') == 7
+17 -11
View File
@@ -2,17 +2,17 @@ import pytest
from mpmath import (agm, airyai, airybi, appellf1, bei, ber, besseli, besselj,
besseljzero, besselk, bessely, besselyzero, betainc,
chebyt, chebyu, chi, ci, convert, coulombg, e, e1, ei,
ellipe, ellipk, eps, erf, erfc, erfi, erfinv, exp, expint,
fadd, fmul, foxh, fp, fraction, fresnelc, fresnels, fsub, fsum,
gamma, gammainc, gegenbauer, hankel1, hankel2, hermite,
hyp0f1, hyp1f1, hyp1f2, hyp2f0, hyp2f1, hyp2f2, hyp2f3,
hyper, hypercomb, hyperu, inf, isnan, j, j0, j1, jacobi,
kei, ker, laguerre, lambertw, ldexp, legendre, legenp,
legenq, lerchphi, li, log, lower_gamma, meijerg, mp, mpc,
mpf, nan, ncdf, npdf, nthroot, pi, qp, quadts, shi, si,
spherharm, spherical_jn, spherical_yn, sqrt, struveh,
struvel, upper_gamma, whitm, whitw, zeta)
chebyt, chebyu, chi, ci, clsin, convert, coulombg, e, e1,
ei, ellipe, ellipk, eps, erf, erfc, erfi, erfinv, exp,
expint, fadd, fmul, foxh, fp, fraction, fresnelc, fresnels,
fsub, fsum, gamma, gammainc, gegenbauer, hankel1, hankel2,
hermite, hyp0f1, hyp1f1, hyp1f2, hyp2f0, hyp2f1, hyp2f2,
hyp2f3, hyper, hypercomb, hyperu, inf, isnan, j, j0, j1,
jacobi, kei, ker, laguerre, lambertw, ldexp, legendre,
legenp, legenq, lerchphi, li, log, lower_gamma, meijerg,
mp, mpc, mpf, nan, ncdf, npdf, nthroot, pi, polylog, qp,
quadts, shi, si, spherharm, spherical_jn, spherical_yn,
sqrt, struveh, struvel, upper_gamma, whitm, whitw, zeta)
from mpmath.libmp import BACKEND, NoConvergence
@@ -2474,3 +2474,9 @@ def test_issue_545():
rel_eps=mpf('1e-4346'))
assert erf(-x).ae(mpc(-1, '1.5120569745187501e-4345'),
rel_eps=mpf('1e-4346'))
def test_issue_459():
assert isnan(clsin(1, mp.inf))
assert isnan(clsin(2, mp.inf))
assert isnan(clsin(2, mp.nan))
assert isnan(polylog(-2, mp.nan))