mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-09-24 04:59:14 -07:00
dev-python/mpmath: Backport upstream fix for gmpy2 test failures
Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
50
dev-python/mpmath/files/mpmath-1.4.0_alpha5-valueerror.patch
Normal file
50
dev-python/mpmath/files/mpmath-1.4.0_alpha5-valueerror.patch
Normal file
@@ -0,0 +1,50 @@
|
||||
From 9ad6a13925922711ca004686194daf8f110feaea Mon Sep 17 00:00:00 2001
|
||||
From: Sergey B Kirpichev <skirpichev@gmail.com>
|
||||
Date: Mon, 9 Jun 2025 05:07:00 +0300
|
||||
Subject: [PATCH] Fix from_man_exp to correctly reject non-integral mantissa
|
||||
|
||||
This partially reverts 25506567
|
||||
---
|
||||
mpmath/ctx_mp_python.py | 2 +-
|
||||
mpmath/libmp/libmpf.py | 7 +++++--
|
||||
mpmath/tests/test_basic_ops.py | 5 +++++
|
||||
3 files changed, 11 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/mpmath/ctx_mp_python.py b/mpmath/ctx_mp_python.py
|
||||
index d9e9f64f..72b81278 100644
|
||||
--- a/mpmath/ctx_mp_python.py
|
||||
+++ b/mpmath/ctx_mp_python.py
|
||||
@@ -64,7 +64,7 @@ def __new__(cls, val=fzero, **kwargs):
|
||||
if len(val) == 4:
|
||||
val = val[0], MPZ(val[1]), *val[2:]
|
||||
elif len(val) == 2:
|
||||
- v._mpf_ = from_man_exp(MPZ(val[0]), val[1], prec, rounding)
|
||||
+ v._mpf_ = from_man_exp(val[0], val[1], prec, rounding)
|
||||
return v
|
||||
else:
|
||||
raise ValueError
|
||||
diff --git a/mpmath/libmp/libmpf.py b/mpmath/libmp/libmpf.py
|
||||
index af61879e..266ee394 100644
|
||||
--- a/mpmath/libmp/libmpf.py
|
||||
+++ b/mpmath/libmp/libmpf.py
|
||||
@@ -8,7 +8,7 @@
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
-from .backend import BACKEND, MPZ, MPZ_FIVE, MPZ_ONE, MPZ_ZERO, gmpy
|
||||
+from .backend import BACKEND, MPZ, MPZ_FIVE, MPZ_ONE, MPZ_ZERO, gmpy, int_types
|
||||
from .libintmath import (bctable, bin_to_radix, isqrt, numeral, sqrtrem,
|
||||
stddigits, trailtable)
|
||||
|
||||
@@ -204,7 +204,10 @@ def normalize(sign, man, exp, bc, prec, rnd):
|
||||
def from_man_exp(man, exp, prec=0, rnd=round_fast):
|
||||
"""Create raw mpf from (man, exp) pair. The mantissa may be signed.
|
||||
If no precision is specified, the mantissa is stored exactly."""
|
||||
- man = MPZ(man)
|
||||
+ if isinstance(man, int_types):
|
||||
+ man = MPZ(man)
|
||||
+ else:
|
||||
+ raise TypeError("man expected to be an integer")
|
||||
sign = 0
|
||||
if man < 0:
|
||||
sign = 1
|
||||
64
dev-python/mpmath/mpmath-1.4.0_alpha5-r1.ebuild
Normal file
64
dev-python/mpmath/mpmath-1.4.0_alpha5-r1.ebuild
Normal file
@@ -0,0 +1,64 @@
|
||||
# Copyright 1999-2025 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=8
|
||||
|
||||
DISTUTILS_USE_PEP517=setuptools
|
||||
PYTHON_COMPAT=( pypy3 pypy3_11 python3_{10..13} )
|
||||
|
||||
inherit distutils-r1 optfeature pypi
|
||||
|
||||
DESCRIPTION="Python library for arbitrary-precision floating-point arithmetic"
|
||||
HOMEPAGE="
|
||||
https://mpmath.org/
|
||||
https://github.com/mpmath/mpmath/
|
||||
https://pypi.org/project/mpmath/
|
||||
"
|
||||
|
||||
LICENSE="BSD"
|
||||
SLOT="0"
|
||||
KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos"
|
||||
IUSE="test-full"
|
||||
|
||||
BDEPEND="
|
||||
dev-python/setuptools-scm[${PYTHON_USEDEP}]
|
||||
test? (
|
||||
dev-python/hypothesis[${PYTHON_USEDEP}]
|
||||
dev-python/numpy[${PYTHON_USEDEP}]
|
||||
dev-python/packaging[${PYTHON_USEDEP}]
|
||||
dev-python/pexpect[${PYTHON_USEDEP}]
|
||||
dev-python/pytest-rerunfailures[${PYTHON_USEDEP}]
|
||||
dev-python/pytest-timeout[${PYTHON_USEDEP}]
|
||||
$(python_gen_cond_dep '
|
||||
dev-python/gmpy2[${PYTHON_USEDEP}]
|
||||
' 'python3*')
|
||||
test-full? (
|
||||
dev-python/matplotlib[${PYTHON_USEDEP}]
|
||||
)
|
||||
)
|
||||
"
|
||||
|
||||
EPYTEST_XDIST=1
|
||||
distutils_enable_tests pytest
|
||||
|
||||
PATCHES=(
|
||||
# https://github.com/aleaxit/gmpy/pull/566
|
||||
# https://github.com/mpmath/mpmath/pull/969/commits/9ad6a13925922711ca004686194daf8f110feaea
|
||||
"${FILESDIR}/${P}-valueerror.patch"
|
||||
)
|
||||
|
||||
python_test() {
|
||||
local EPYTEST_DESELECT=()
|
||||
|
||||
# CLI crashes otherwise, sigh (not a regression)
|
||||
# https://github.com/mpmath/mpmath/issues/907
|
||||
> "${HOME}/.python_history" || die
|
||||
|
||||
local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
|
||||
epytest -p rerunfailures --reruns=5 -p timeout
|
||||
}
|
||||
|
||||
pkg_postinst() {
|
||||
optfeature "gmp support" dev-python/gmpy2
|
||||
optfeature "matplotlib support" dev-python/matplotlib
|
||||
}
|
||||
Reference in New Issue
Block a user