Compare commits

...

12 Commits

Author SHA1 Message Date
Sergey B Kirpichev d91462ab6e Fix typo and function names for sin/cospi()
test / linter (push) Failing after 0s
test / docs (push) Failing after 0s
test / coverage (push) Failing after 0s
Publish on PyPI / Build distributions (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
test / frozen-version (push) Has been cancelled
test / tests (false, false, 3.10) (push) Has been cancelled
test / tests (false, false, 3.14t) (push) Has been cancelled
test / tests (false, false, 3.9) (push) Has been cancelled
test / tests (false, false, 3.11) (push) Has been cancelled
test / tests (false, false, 3.12) (push) Has been cancelled
test / tests (false, false, 3.13) (push) Has been cancelled
test / tests (false, false, 3.13t) (push) Has been cancelled
test / tests (false, false, 3.14) (push) Has been cancelled
test / tests (true, pypy3.11) (push) Has been cancelled
test / tests (true, 3.x) (push) Has been cancelled
(cherry picked from commit 35a1e33f02)
2026-05-28 07:27:47 +03:00
Sergey B Kirpichev 10719fc826 Amend README.rst with 1.4.1 release
(cherry picked from commit db21709e9a)
2026-05-26 08:19:33 +03:00
Sergey B Kirpichev f55f6394fa Amend 1108318e (restrict fix to CPython < 3.14)
Closes #1046

(cherry picked from commit 527d9d228c)
2026-03-31 05:36:04 +03:00
Sergey B Kirpichev c1131e2d64 Merge pull request #1053 from skirpichev/release-1.4.1
test / linter (push) Failing after 0s
test / coverage (push) Failing after 0s
test / docs (push) Failing after 0s
Publish on PyPI / Build distributions (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
test / tests (false, false, 3.10) (push) Has been cancelled
test / tests (false, false, 3.11) (push) Has been cancelled
test / tests (false, false, 3.12) (push) Has been cancelled
test / tests (false, false, 3.13) (push) Has been cancelled
test / tests (false, false, 3.13t) (push) Has been cancelled
test / tests (false, false, 3.14) (push) Has been cancelled
test / tests (false, false, 3.14t) (push) Has been cancelled
test / tests (false, false, 3.9) (push) Has been cancelled
test / tests (true, pypy3.11) (push) Has been cancelled
test / frozen-version (push) Has been cancelled
test / tests (true, 3.x) (push) Has been cancelled
v1.4.1
2026-03-15 04:02:54 +03:00
Sergey B Kirpichev d3d3eb9767 Update CHANGES 2026-03-11 15:25:01 +03:00
Sergey B Kirpichev 629daff497 Add a workaround for test on s390x
Closes #1046

(cherry picked from commit 1108318e0f)
2026-03-11 15:16:06 +03:00
Sergey B Kirpichev 96272f303a Revert "Add backport action"
This reverts commit 319703eafd.

(cherry picked from commit 5d48d2abd9)
2026-03-10 05:34:12 +03:00
flurin4 e12948020f Test frozen package version (#1055)
Add bash script to test package version in a frozen application version and a separate CI job to run it.  Closes #1044.

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
(cherry picked from commit 45f5adbb37)
2026-03-10 05:34:02 +03:00
Sergey B Kirpichev 1ef88b4fa4 Amend docstring for round_digits()
(cherry picked from commit 9677a2a939)
2026-03-04 07:24:15 +03:00
Sergey B Kirpichev 650520b3c2 Use version_file option of setuptools-scm to keep version info
Closes #1044

(cherry picked from commit ed57d4034d)
2026-03-04 05:09:38 +03:00
Sergey B Kirpichev 501af4a7c7 Keep forever deprecated aliases for mpc/mpf_log() 2026-03-04 05:09:37 +03:00
Doug Torrance 6887127ae9 Set argtypes for sprintf from ctypes
Needed on some architectures (see the "Calling variadic functions" in
the ctypes documentation).

closes #1047

(cherry picked from commit d74dff7e48)
2026-03-01 08:33:57 +03:00
16 changed files with 100 additions and 81 deletions
-16
View File
@@ -1,16 +0,0 @@
// .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
@@ -1,37 +0,0 @@
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
+12
View File
@@ -12,10 +12,22 @@ jobs:
uses: ./.github/workflows/coverage.yml
docs:
uses: ./.github/workflows/docs.yml
frozen-version:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: "3.x"
- name: Run frozen version test
run: bash mpmath/tests/test_version_frozen.sh
tests:
needs:
- linter
- coverage
- frozen-version
runs-on: ubuntu-24.04
strategy:
fail-fast: false
+3
View File
@@ -33,6 +33,9 @@ my/
dist/
build/
# Generated by setuptools_scm
mpmath/_version.py
# Tox files
.tox/
+11
View File
@@ -1,3 +1,14 @@
--1.4.1--
Released March 15, 2026
Bug fixes:
* Fix test_hexadecimal_with_libc_bulk(), see #1049 (Doug Torrance)
* Keep available deprecated aliases for mpc/mpf_log() (Sergey B Kirpichev)
* Use version_file option of setuptools-scm to keep version info, see #1048
(Sergey B Kirpichev)
* Add workaround for test on s390x, see #1061 (Sergey B Kirpichev)
--1.4.0--
Released February 23, 2026
+1
View File
@@ -85,6 +85,7 @@ Credit also goes to:
Release history:
* Version 1.4.1 released on March 15, 2026
* Version 1.4.0 released on February 23, 2026
* Version 1.3.0 released on March 7, 2023
* Version 1.2.1 released on February 9, 2021
+1 -4
View File
@@ -1,7 +1,4 @@
from importlib.metadata import version
__version__ = version(__name__)
del version
from ._version import __version__
import functools
import sys
+4 -2
View File
@@ -67,8 +67,10 @@ class MPContext(BaseMPContext, StandardBaseContext):
ctx.atan2.__func__.__doc__ = function_docs.atan2
ctx.digamma.__doc__ = function_docs.digamma
ctx.cospi.__doc_ = function_docs.cospi
ctx.sinpi.__doc_ = function_docs.sinpi
ctx.cospi.__doc__ = function_docs.cospi
ctx.sinpi.__doc__ = function_docs.sinpi
ctx.sinpi.__name__ = 'sinpi'
ctx.cospi.__name__ = 'cospi'
def init_builtins(ctx):
# Exact constants
+1 -4
View File
@@ -737,10 +737,7 @@ def mpf_ln(x, prec, rnd=round_fast):
m -= n*ln2_fixed(wp)
return from_man_exp(m, -wp, prec, rnd)
def mpf_log(x, prec, rnd=round_fast):
warnings.warn("mpf_log is deprecated, use mpf_ln",
DeprecationWarning)
return mpf_ln(x, prec, rnd)
mpf_log = mpf_ln # deprecated alias
def mpf_log1p(x, prec, rnd=round_fast):
"""
+1 -5
View File
@@ -3,7 +3,6 @@ Low-level functions for complex arithmetic.
"""
import sys
import warnings
from .backend import MPZ
from .libelefun import (mpf_acos, mpf_acosh, mpf_asin, mpf_atan, mpf_atan2,
@@ -436,10 +435,7 @@ def mpc_ln(z, prec, rnd=round_fast):
im = mpc_arg(z, prec, rnd)
return re, im
def mpc_log(x, prec, rnd=round_fast):
warnings.warn("mpc_log is deprecated, use mpc_ln",
DeprecationWarning)
return mpc_ln(x, prec, rnd)
mpc_log = mpc_ln # deprecated alias
def mpc_cos(z, prec, rnd=round_fast):
"""Complex cosine. The formula used is cos(a+bi) = cos(a)*cosh(b) -
+2 -4
View File
@@ -1102,12 +1102,10 @@ def to_digits_exp(s, dps, base=10):
return sign, digits, exponent
def round_digits(sign, digits, dps, base, rnd=round_nearest, fixed=False):
'''
"""
Returns the rounded digits, and the number of places the decimal point was
shifted.
Supports three kinds of rounding: up, down, or nearest.
'''
"""
assert len(digits) > dps
assert rnd in (round_nearest, round_up, round_down, round_ceiling,
-7
View File
@@ -707,13 +707,6 @@ def test_issue_985():
assert mpc(-1) in {1, -1}
def test_mpfmpc_log_deprecation():
with pytest.deprecated_call():
mpmath.libmp.mpf_log(mpf(123)._mpf_, 53)
with pytest.deprecated_call():
mpmath.libmp.mpc_log(mpc(123)._mpc_, 53)
def test_issue_975():
def worker():
mp = mpmath.MPContext()
+1
View File
@@ -864,6 +864,7 @@ except OSError:
def float_print(d, i):
fmt = "%." + str(i) + "a\n"
a = ctypes.create_string_buffer(256)
libc.sprintf.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
libc.sprintf(a, bytes(fmt, 'utf-8'), ctypes.c_double(d))
return a.raw.decode('utf-8').split("\n")[0]
+10 -1
View File
@@ -1,3 +1,6 @@
import platform
import sys
import pytest
from mpmath import (agm, airyai, airybi, appellf1, bei, ber, besseli, besselj,
@@ -1470,7 +1473,13 @@ def test_issue_239():
x = ldexp(2476979795053773,-52)
assert betainc(206, 385, 0, 0.55, 1).ae('0.99999999999999999999996570910644857895771110649954')
mp.dps = 15
pytest.raises(ValueError, lambda: hyp2f1(-5,5,0.5,0.5))
expected_exc = ValueError
if platform.machine() == 's390x' and sys.version_info < (3, 14):
# This case has recursion depth beyond platform capabilities, that
# could be controlled with sys.setrecursionlimit(). See issue #1046
# for details.
expected_exc = RecursionError
pytest.raises(expected_exc, lambda: hyp2f1(-5,5,0.5,0.5))
# Extra stress testing for Bessel functions
# Reference zeros generated with the aid of scipy.special
+51
View File
@@ -0,0 +1,51 @@
#!/bin/bash
#
# Test that the version number is provided correctly in a frozen (bundled)
# executable (see #1044).
set -e
# Get the directory of the current repository
MPMATH_DIR="$(realpath "$(dirname "$0")/../../")"
echo "Repo mpmath directory: $MPMATH_DIR"
echo "Install requirements..."
python3 -m pip install build pyinstaller
echo "Building the source distribution from the local repo..."
python3 -m build --sdist
# Find and install the generated tarball
TARBALL=$(ls -t dist/*.tar.gz | head -1)
echo "Generated tarball: $TARBALL"
echo "Installing mpmath from tarball..."
pip install dist/"$(basename $TARBALL)"
TEMP_DIR=$(mktemp -d)
echo "Created temporary directory: $TEMP_DIR"
cd "$TEMP_DIR"
# Create version_script.py that prints the package version
cat << EOF > version_script.py
import mpmath
print(mpmath.__version__)
EOF
# Save local version for later comparison
DIRECT_VERSION="$(python3 -m mpmath --version)"
echo "Building version_script with PyInstaller..."
pyinstaller --onefile --clean version_script.py
echo "Run frozen executable and extract the version from the output..."
FROZEN_VERSION="$(./dist/version_script 2>&1)"
if [ "$DIRECT_VERSION" == "$FROZEN_VERSION" ]; then
echo "Test passed: Version matches in frozen (bundled) executable."
else
echo "Test failed: Version mismatch."
echo "Direct version: $DIRECT_VERSION"
echo "Frozen version: $FROZEN_VERSION"
exit 1
fi
+2 -1
View File
@@ -54,6 +54,7 @@ exclude = ['.eggs', '.git']
max_line_length = 200
[tool.setuptools_scm]
version_file = "mpmath/_version.py"
[tool.pytest.ini_options]
testpaths = ['mpmath', 'docs']
@@ -66,7 +67,7 @@ timeout = 600
[tool.coverage.run]
branch = true
omit = ['mpmath/tests/*']
omit = ['mpmath/tests/*', 'mpmath/_version.py']
patch = ["subprocess"]
[tool.coverage.html]