Upgrading mpmath 0.19 to 1
Breaking0.19 → 1.4.1Breaking8Security1Platform2Deprecated7New46Changed12Fixed52Other28
SecurityFixed ReDOS vulnerability in mpmathify (CVE-2021-29063) (Vinzent Steinberg).GHSA-f865-m6cq-j9vx · CVE-2021-29063 ↗
BreakingUpgrade verdict
8 breaking changes and 2 platform requirement changes and a security fix.
In plain terms
- The package no longer works on Python 2.
- Removes an internal number class; use the backend's Rational class instead.
- Removes two helper functions used for pickling numbers.
- The SageMath backend is no longer available.
Must act Top 5 of 18 that need code or config changes
Requires Python >=3.9 from 1.4.0a4 (none stated before).
What you must change
Breaking8
Drops Python 2 support.
Drops the private mpq class in favor of Rational's provided by the backend.
mpqRationalDrops the to_pickable() and from_pickable() helpers.
to_pickable()from_pickable()Removes the sage backend.
Drops the MPMATH_STRICT environment variable.
MPMATH_STRICTDrops mpf.__complex__() and works around 1/z division for acot/asec/acsc/acoth.
mpf.__complex__()acotasecacscacothDrops the sign from nstr(mpf('inf')) output.
nstrmpfmpf.__round__() now returns mpf instead of int.
mpf.__round__()Security1
Fixed ReDOS vulnerability in mpmathify (CVE-2021-29063) (Vinzent Steinberg).
Platform2
Drops support for Python versions below 3.9.
Dropped support for Python 3.4 (Sergey B Kirpichev).
Deprecations to plan for
Deprecated7
Deprecates direct access to _mpf_ tuples; use from/to_man_exp() and special constants instead.
_mpf_from_man_exp()to_man_exp()finffninffnanDeprecates the current descending order of coefficients in polyval() and similar functions.
polyval()Deprecates mpmath.math2.
mpmath.math2Deprecates importing from mpmath.libmp submodules; import from mpmath.libmp instead.
mpmath.libmpDeprecates the bitcount function.
bitcountDeprecates mpf/mpc_log.
mpf_logmpc_logDeprecates fp.is_special().
fp.is_special()API changes
Generated by DepDelta from published Python source. Not mixed with prose notes.
- removed:
function doctests(filter=…) - removed:
function runtests() - added:
export math2 - added:
export rational - added:
variable eta - added:
variable exp2 - added:
variable foxh - added:
variable invertlaplace - added:
variable invlapdehoog - added:
variable invlapstehfest - added:
variable invlaptalbot - added:
variable log1p - added:
variable log2 - added:
variable lower_gamma - added:
variable quadsubdiv - added:
variable rank - added:
variable sawtoothw - added:
variable sigmoid - added:
variable spherical_jn - added:
variable spherical_yn - added:
variable squarew - added:
variable trianglew - added:
variable unit_triangle - added:
variable upper_gamma
- changed:
function chebyfit(ctx, f, interval, N, error=…) → function chebyfit(ctx, f, interval, N, error=…, asc=…)
- changed:
class CalculusMethods(object) → class CalculusMethods
- removed:
function cartesian_product(args) - removed:
variable izip - removed:
variable next
- added:
class Cohen(InverseLaplaceTransform) - added:
class FixedTalbot(InverseLaplaceTransform) - added:
class InverseLaplaceTransform - added:
class LaplaceTransformInversionMethods - added:
class Stehfest(InverseLaplaceTransform) - added:
class deHoog(InverseLaplaceTransform) - added:
constructor InverseLaplaceTransform(ctx) - added:
constructor LaplaceTransformInversionMethods(*args, **kwargs) - added:
method Cohen.calc_laplace_parameter(t, **kwargs) - added:
method Cohen.calc_time_domain_solution(fp, t, manual_prec=…) - added:
method FixedTalbot.calc_laplace_parameter(t, **kwargs) - added:
method FixedTalbot.calc_time_domain_solution(fp, t, manual_prec=…) - added:
method InverseLaplaceTransform.calc_laplace_parameter(t, **kwargs) - added:
method InverseLaplaceTransform.calc_time_domain_solution(fp) - added:
method LaplaceTransformInversionMethods.invertlaplace(f, t, **kwargs) - added:
method LaplaceTransformInversionMethods.invlapcohen(*args, **kwargs) - added:
method LaplaceTransformInversionMethods.invlapdehoog(*args, **kwargs) - added:
method LaplaceTransformInversionMethods.invlapstehfest(*args, **kwargs) - added:
method LaplaceTransformInversionMethods.invlaptalbot(*args, **kwargs) - added:
method Stehfest.calc_laplace_parameter(t, **kwargs) - added:
method Stehfest.calc_time_domain_solution(fp, t, manual_prec=…) - added:
method deHoog.calc_laplace_parameter(t, **kwargs) - added:
method deHoog.calc_time_domain_solution(fp, t, manual_prec=…)
- changed:
class ODEMethods(object) → class ODEMethods
- changed:
class OptimizationMethods(object) → class OptimizationMethods
- changed:
function polyroots(ctx, coeffs, maxsteps=…, cleanup=…, extraprec=…, error=…) → function polyroots(ctx, coeffs, maxsteps=…, cleanup=…, extraprec=…, error=…, roots_init=…, asc=…) - changed:
function polyval(ctx, coeffs, x, derivative=…) → function polyval(ctx, coeffs, x, derivative=…, asc=…)
- changed:
class QuadratureMethods(object) → class QuadratureMethods - changed:
class QuadratureRule(object) → class QuadratureRule - added:
method QuadratureMethods.quadsubdiv(f, interval, tol=…, maxintervals=…, **kwargs)
- removed:
variable rootdir
- changed:
class Context(object) → class Context - changed:
class StandardBaseContext(Context, SpecialFunctions, RSCache, QuadratureMethods, CalculusMethods, MatrixMethods, MatrixCalculusMethods, LinearAlgebraMethods, Eigen, IdentificationMethods, OptimizationMethods, ODEMethods, VisualizationMethods) → class StandardBaseContext(Context, SpecialFunctions, RSCache, QuadratureMethods, LaplaceTransformInversionMethods, CalculusMethods, MatrixMethods, MatrixCalculusMethods, LinearAlgebraMethods, Eigen, IdentificationMethods, OptimizationMethods, ODEMethods, VisualizationMethods) - added:
method StandardBaseContext.rand()
- removed:
field FPContext.dps - removed:
field FPContext.prec - removed:
method FPContext.arg(z) - removed:
method FPContext.atan2(x, y) - changed:
method FPContext.bernoulli(n) → method FPContext.bernoulli(n, plus=…) - changed:
method FPContext.hypsum(p, q, types, coeffs, z, maxterms=…, **kwargs) → method FPContext.hypsum(p, q, flags, coeffs, z, maxterms=…, **kwargs) - added:
field FPContext.acosh - added:
field FPContext.arg - added:
field FPContext.asinh - added:
field FPContext.atan2 - added:
field FPContext.atanh - added:
field FPContext.hypot - added:
field FPContext.loggamma - added:
method FPContext.isfinite(x) - added:
property FPContext.dps - added:
property FPContext.prec
- changed:
class ivmpc(object) → class ivmpc - changed:
class ivmpf(object) → class ivmpf - added:
method ivmpf.cast(cls, f_convert)
- removed:
variable new - changed:
constructor MPContext() → constructor MPContext(prec=…, rounding=…, trap_complex=…) - changed:
method MPContext.bernoulli(n) → method MPContext.bernoulli(n, plus=…)
- removed:
function binary_op(name, with_mpf=…, with_int=…, with_mpc=…) - removed:
method PythonMPContext.isnan(x) - removed:
variable mpf_binary_op - removed:
variable mpf_pow_same - removed:
variable return_mpc - removed:
variable return_mpf - changed:
class PythonMPContext(object) → class PythonMPContext - changed:
class mpnumeric(object) → class mpnumeric - added:
field PythonMPContext.pretty_dps - added:
field PythonMPContext.rounding - added:
method PythonMPContext.npconvert(x)
- added:
variable exp2 - added:
variable foxh - added:
variable log1p - added:
variable log2 - added:
variable lower_gamma - added:
variable sawtoothw - added:
variable sigmoid - added:
variable squarew - added:
variable trianglew - added:
variable unit_triangle - added:
variable upper_gamma
- added:
export signals
- changed:
function besselk(ctx, n, z, **kwargs) → function besselk(ctx, n, z, derivative=…, **kwargs) - added:
function spherical_jn(ctx, n, z) - added:
function spherical_yn(ctx, n, z)
- changed:
function RJ_calc(ctx, x, y, z, p, r) → function RJ_calc(ctx, x, y, z, p, r, integration) - changed:
function elliprj(ctx, x, y, z, p) → function elliprj(ctx, x, y, z, p, integration=…) - added:
function eta(ctx, tau)
- added:
function lower_gamma(ctx, z, b, regularized=…) - added:
function upper_gamma(ctx, z, a, regularized=…)
- removed:
function loggamma_old(ctx, z)
- changed:
class SpecialFunctions(object) → class SpecialFunctions - added:
function exp2(ctx, x) - added:
function log1p(ctx, x) - added:
function log2(ctx, x)
- added:
function foxh(ctx, aA_s, bB_s, z, r=…, series=…, **kwargs)
- changed:
class RSCache(object) → class RSCache
- added:
function sawtoothw(ctx, t, amplitude=…, period=…) - added:
function sigmoid(ctx, t, amplitude=…) - added:
function squarew(ctx, t, amplitude=…, period=…) - added:
function trianglew(ctx, t, amplitude=…, period=…) - added:
function unit_triangle(ctx, t, amplitude=…)
- changed:
class IdentificationMethods(object) → class IdentificationMethods - changed:
function findpoly(ctx, x, n=…, **kwargs) → function findpoly(ctx, x, n=…, asc=…, **kwargs)
- added:
function cotpi(x) - added:
function e1(z) - added:
function ei(z, _e1=…) - added:
function ei_asymp(z, _e1=…) - added:
function ei_taylor(z, _e1=…) - added:
function factorial(x) - added:
function loggamma(x) - added:
function nthroot(x, n) - added:
function rgamma(x) - added:
function zeta(s) - added:
variable EI_ASYMP_CONVERGENCE_RADIUS - added:
variable INF - added:
variable acos - added:
variable acosh - added:
variable asin - added:
variable asinh - added:
variable atan - added:
variable atanh - added:
variable cbrt - added:
variable ceil - added:
variable cos - added:
variable cos_sin - added:
variable cosh - added:
variable cospi - added:
variable digamma - added:
variable euler - added:
variable exp - added:
variable floor - added:
variable gamma - added:
variable gauss42 - added:
variable log - added:
variable logpi - added:
variable pi - added:
variable pow - added:
variable sin - added:
variable sinh - added:
variable sinpi - added:
variable sqrt - added:
variable tan - added:
variable tanh
- removed:
export HASH_BITS - removed:
export HASH_MODULUS - removed:
export MPZ_TYPE - removed:
export STRICT - removed:
export fnzero - removed:
export from_bstr - removed:
export math_float_inf - removed:
export mpc_factorial_old - removed:
export mpc_gamma_old - removed:
export mpc_mul_imag_mpf - removed:
export mpf_factorial_old - removed:
export mpf_gamma_old - removed:
export normalize1 - removed:
export sage - removed:
export to_bstr - added:
export MPQ - added:
export format_mpc - added:
export format_mpf - added:
export from_Decimal - added:
export from_npfloat - added:
export giant_steps - added:
export mpc_ln - added:
export mpc_mpf_sub - added:
export mpf_ln
- removed:
variable HASH_BITS - removed:
variable HASH_MODULUS - removed:
variable MPZ_TYPE - removed:
variable STRICT - removed:
variable basestring - removed:
variable python3 - removed:
variable sage - removed:
variable sage_utils - removed:
variable xrange - added:
variable MPQ
- removed:
function calc_spouge_coefficients(a, prec) - removed:
function get_spouge_coefficients(prec) - removed:
function mpc_factorial_old(x, prec, rounding=…) - removed:
function mpc_gamma_old(x, prec, rounding=…, p1=…) - removed:
function mpf_factorial_old(x, prec, rounding=…) - removed:
function mpf_gamma_int_old(n, prec, rounding=…) - removed:
function mpf_gamma_old(x, prec, rounding=…, p1=…) - removed:
function spouge_sum_complex(re, im, prec, a, c) - removed:
function spouge_sum_rational(p, q, prec, a, c) - removed:
function spouge_sum_real(x, prec, a, c) - removed:
variable spouge_cache - changed:
function bernfrac(n) → function bernfrac(n, plus=…) - changed:
function mpf_bernoulli(n, prec, rnd=…) → function mpf_bernoulli(n, prec, rnd=…, plus=…) - added:
variable local
- removed:
function mpf_log(x, prec, rnd=…) - removed:
variable cos_sin_fixed - removed:
variable exp_fixed - removed:
variable log_int_fixed - removed:
variable mpf_cos - removed:
variable mpf_exp - removed:
variable mpf_pow - removed:
variable mpf_sin - removed:
variable mpf_sqrt - added:
function mpf_ln(x, prec, rnd=…) - added:
function mpf_log1p(x, prec, rnd=…) - added:
variable local
- changed:
function mpc_besseljn(n, z, prec, rounding=…) → function mpc_besseljn(n, z, prec, rnd=…) - changed:
function mpf_besseljn(n, x, prec, rounding=…) → function mpf_besseljn(n, x, prec, rnd=…)
- removed:
function gcd(*args) - removed:
function gmpy_bitcount(n) - removed:
function gmpy_trailing(n) - removed:
function ifac(n, memo=…) - removed:
function python_bitcount(n) - removed:
function python_trailing(n) - removed:
function sage_trailing(n) - removed:
variable MAX_EULER_CACHE - removed:
variable bitcount - removed:
variable lshift - removed:
variable powers - removed:
variable rshift - removed:
variable sage_bitcount - removed:
variable trailing - changed:
function eulernum(m, _cache=…) → function eulernum(m) - changed:
function ifib(n, _cache=…) → function ifib(n) - added:
function bitcount(n) - added:
function trailing(n) - added:
variable gcd - added:
variable ifac2 - added:
variable ifac2_python - added:
variable ifib_python - added:
variable isprime - added:
variable isprime_python - added:
variable small_trailing
- removed:
function mpc_log(z, prec, rnd=…) - removed:
function mpc_mul_imag_mpf(z, x, prec, rnd=…) - removed:
variable mpc_exp - removed:
variable mpc_sqrt - changed:
function mpc_to_complex(z, strict=…) → function mpc_to_complex(z, strict=…, rnd=…) - added:
function mpc_ln(z, prec, rnd=…) - added:
function mpc_mpf_sub(p, z, prec=…, rnd=…) - added:
variable mpc_log
- removed:
function from_bstr(x) - removed:
function gmpy_mpf_mul(s, t, prec=…, rnd=…) - removed:
function python_mpf_mul(s, t, prec=…, rnd=…) - removed:
function strict_normalize(sign, man, exp, bc, prec, rnd) - removed:
function strict_normalize1(sign, man, exp, bc, prec, rnd) - removed:
function to_bstr(x) - removed:
variable fnzero - removed:
variable getrandbits - removed:
variable intern - removed:
variable mpf_add - removed:
variable mpf_div - removed:
variable mpf_mul - removed:
variable mpf_sqrt - removed:
variable mpf_sub - removed:
variable normalize - removed:
variable normalize1 - changed:
function from_str(x, prec, rnd=…) → function from_str(x, prec=…, rnd=…, base=…) - changed:
function to_digits_exp(s, dps) → function to_digits_exp(s, dps, base=…) - changed:
function to_float(s, strict=…) → function to_float(s, strict=…, rnd=…) - changed:
function to_man_exp(s) → function to_man_exp(s, signed=…) - changed:
function to_str(s, dps, strip_zeros=…, min_fixed=…, max_fixed=…, show_zero_exponent=…) → function to_str(s, dps, strip_zeros=…, min_fixed=…, max_fixed=…, show_zero_exponent=…, base=…, binary_exp=…, rnd=…) - added:
function calc_padding(nchars, width, align) - added:
function fill_sep(digits, sep, prev, nmod, sep_range) - added:
function format_binary(s, dps, rnd=…) - added:
function format_digits(num, format_dict, prec, rnd, _pretty_repr_dps) - added:
function format_fixed(s, dps, rnd=…) - added:
function format_hexadecimal(s, dps, rnd=…) - added:
function format_mpc(num, format_spec, prec, rnd, _pretty_repr_dps) - added:
function format_mpf(num, format_spec, prec, rnd, _pretty_repr_dps) - added:
function format_scientific(s, dps, rnd=…) - added:
function from_Decimal(x, prec=…, rnd=…) - added:
function from_npfloat(x, prec=…, rnd=…) - added:
function mpf_mul(s, t, prec=…, rnd=…) - added:
function normalize(sign, man, exp, bc, prec, rnd) - added:
function read_format_spec(format_spec) - added:
function round_digits(sign, digits, dps, base, rnd=…, fixed=…) - added:
variable blog2_10
- removed:
class Iterator(object) - removed:
class MovedAttribute(_LazyDescr) - removed:
class MovedModule(_LazyDescr) - removed:
class X(object) - removed:
constructor MovedAttribute(name, old_mod, new_mod, old_attr=…, new_attr=…) - removed:
constructor MovedModule(name, old, new=…) - removed:
function add_move(move) - removed:
function advance_iterator(it) - removed:
function b(s) - removed:
function callable(obj) - removed:
function exec_(code, globs=…, locs=…) - removed:
function get_unbound_function(unbound) - removed:
function int2byte(i) - removed:
function iteritems(d) - removed:
function iterkeys(d) - removed:
function itervalues(d) - removed:
function print_(*args, **kwargs) - removed:
function remove_move(name) - removed:
function reraise(tp, value, tb=…) - removed:
function u(s) - removed:
function with_metaclass(meta, base=…) - removed:
method Iterator.next() - removed:
variable BytesIO - removed:
variable Iterator - removed:
variable MAXSIZE - removed:
variable PY3 - removed:
variable StringIO - removed:
variable advance_iterator - removed:
variable binary_type - removed:
variable callable - removed:
variable class_types - removed:
variable exec_ - removed:
variable get_function_code - removed:
variable get_function_defaults - removed:
variable get_method_function - removed:
variable get_method_self - removed:
variable int2byte - removed:
variable integer_types - removed:
variable moves - removed:
variable next - removed:
variable print_ - removed:
variable string_types - removed:
variable text_type
- removed:
function arg(x) - removed:
function cotpi(x) - removed:
function e1(z) - removed:
function ei(z, _e1=…) - removed:
function ei_asymp(z, _e1=…) - removed:
function ei_taylor(z, _e1=…) - removed:
function erf(x) - removed:
function erfc(x) - removed:
function factorial(x) - removed:
function loggamma(x) - removed:
function math_log(x) - removed:
function math_sqrt(x) - removed:
function nthroot(x, n) - removed:
function rgamma(x) - removed:
function tanpi(x) - removed:
function zeta(s) - removed:
variable EI_ASYMP_CONVERGENCE_RADIUS - removed:
variable EPS - removed:
variable INF - removed:
variable NAN - removed:
variable NINF - removed:
variable acos - removed:
variable apery - removed:
variable asin - removed:
variable atan - removed:
variable catalan - removed:
variable cbrt - removed:
variable ceil - removed:
variable cos - removed:
variable cos_sin - removed:
variable cosh - removed:
variable cospi - removed:
variable digamma - removed:
variable e - removed:
variable euler - removed:
variable exp - removed:
variable floor - removed:
variable gamma - removed:
variable gauss42 - removed:
variable khinchin - removed:
variable ln10 - removed:
variable ln2 - removed:
variable log - removed:
variable logpi - removed:
variable math_log - removed:
variable math_sqrt - removed:
variable phi - removed:
variable pi - removed:
variable pow - removed:
variable sin - removed:
variable sinh - removed:
variable sinpi - removed:
variable sqrt - removed:
variable sqrt2 - removed:
variable sqrt5 - removed:
variable tan - removed:
variable tanh
- changed:
class MatrixCalculusMethods(object) → class MatrixCalculusMethods
- changed:
class Eigen(object) → class Eigen
- changed:
class LinearAlgebraMethods(object) → class LinearAlgebraMethods - added:
method LinearAlgebraMethods.rank(A, iszerofunc=…)
- removed:
variable colsep - removed:
variable rowsep - changed:
class MatrixMethods(object) → class MatrixMethods
- removed:
class mpq(object) - removed:
function create_reduced(p, q, _cache=…) - removed:
variable mpq_0 - removed:
variable mpq_1 - removed:
variable mpq_1_16 - removed:
variable mpq_1_2 - removed:
variable mpq_1_4 - removed:
variable mpq_3_16 - removed:
variable mpq_3_2 - removed:
variable mpq_3_4 - removed:
variable mpq_5_2 - removed:
variable mpq_5_4 - removed:
variable mpq_7_4 - removed:
variable new
- changed:
class VisualizationMethods(object) → class VisualizationMethods - changed:
function cplot(ctx, f, re=…, im=…, points=…, color=…, verbose=…, file=…, dpi=…, axes=…) → function cplot(ctx, f, re=…, im=…, points=…, color=…, verbose=…, file=…, dpi=…, axes=…, imshow_kwargs=…) - changed:
function plot(ctx, f, xlim=…, ylim=…, points=…, file=…, dpi=…, singularities=…, axes=…) → function plot(ctx, f, xlim=…, ylim=…, points=…, file=…, dpi=…, singularities=…, axes=…, plot_kwargs=…) - changed:
function splot(ctx, f, u=…, v=…, points=…, keep_aspect=…, wireframe=…, file=…, dpi=…, axes=…) → function splot(ctx, f, u=…, v=…, points=…, keep_aspect=…, wireframe=…, file=…, dpi=…, axes=…, plot3d_kwargs=…) - added:
function phase_color_function(ctx, z) - added:
variable blue_orange_colors