Skip to content

Commit

Permalink
Unbundle mpmath: fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Jan 1, 2015
1 parent e26289d commit a410dc8
Show file tree
Hide file tree
Showing 43 changed files with 93 additions and 89 deletions.
2 changes: 1 addition & 1 deletion examples/advanced/autowrap_ufuncify.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
if not np:
sys.exit("Cannot import numpy. Exiting.")

import sympy.mpmath as mpmath
import mpmath
from sympy.utilities.autowrap import ufuncify
from sympy.utilities.lambdify import implemented_function
from sympy import symbols, legendre, Plot, pprint
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced/pidigits.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
computation of the digits of pi.
"""

from sympy.mpmath import libmp, pi
from sympy.mpmath import functions as mpf_funs
from mpmath import libmp, pi
from mpmath import functions as mpf_funs

import math
from time import clock
Expand Down
2 changes: 1 addition & 1 deletion sympy/combinatorics/permutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
has_dups, runs)
from sympy.polys.polytools import lcm
from sympy.matrices import zeros
from sympy.mpmath.libmp.libintmath import ifac
from mpmath.libmp.libintmath import ifac


def _af_rmul(a, b):
Expand Down
18 changes: 9 additions & 9 deletions sympy/core/evalf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@

import math

import sympy.mpmath.libmp as libmp
from sympy.mpmath import (
import mpmath.libmp as libmp
from mpmath import (
make_mpc, make_mpf, mp, mpc, mpf, nsum, quadts, quadosc, workprec)
from sympy.mpmath import inf as mpmath_inf
from sympy.mpmath.libmp import (from_int, from_man_exp, from_rational, fhalf,
from mpmath import inf as mpmath_inf
from mpmath.libmp import (from_int, from_man_exp, from_rational, fhalf,
fnan, fnone, fone, fzero, mpf_abs, mpf_add,
mpf_atan, mpf_atan2, mpf_cmp, mpf_cos, mpf_e, mpf_exp, mpf_log, mpf_lt,
mpf_mul, mpf_neg, mpf_pi, mpf_pow, mpf_pow_int, mpf_shift, mpf_sin,
mpf_sqrt, normalize, round_nearest, to_int, to_str)
from sympy.mpmath.libmp import bitcount as mpmath_bitcount
from sympy.mpmath.libmp.backend import MPZ
from sympy.mpmath.libmp.libmpc import _infs_nan
from sympy.mpmath.libmp.libmpf import dps_to_prec, prec_to_dps
from sympy.mpmath.libmp.gammazeta import mpf_bernoulli
from mpmath.libmp import bitcount as mpmath_bitcount
from mpmath.libmp.backend import MPZ
from mpmath.libmp.libmpc import _infs_nan
from mpmath.libmp.libmpf import dps_to_prec, prec_to_dps
from mpmath.libmp.gammazeta import mpf_bernoulli

from .compatibility import SYMPY_INTS
from .sympify import sympify
Expand Down
4 changes: 2 additions & 2 deletions sympy/core/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .decorators import _sympifyit, call_highest_priority
from .cache import cacheit
from .compatibility import reduce, as_int, default_sort_key, xrange
from sympy.mpmath.libmp import mpf_log, prec_to_dps
from mpmath.libmp import mpf_log, prec_to_dps

from collections import defaultdict

Expand Down Expand Up @@ -388,7 +388,7 @@ def _random(self, n=None, re_min=-1, im_min=-1, re_max=1, im_max=1):
# increase the precision up to the default maximum
# precision to see if we can get any significance

from sympy.mpmath.libmp.libintmath import giant_steps
from mpmath.libmp.libintmath import giant_steps
from sympy.core.evalf import DEFAULT_MAXPREC as target

# evaluate
Expand Down
8 changes: 4 additions & 4 deletions sympy/core/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
from sympy.utilities.iterables import uniq
from sympy.core.evaluate import global_evaluate

from sympy import mpmath
import sympy.mpmath.libmp as mlib
import mpmath
import mpmath.libmp as mlib

import inspect

Expand Down Expand Up @@ -460,7 +460,7 @@ def _eval_evalf(self, prec):
try:
args = [arg._to_mpmath(prec + 5) for arg in self.args]
def bad(m):
from sympy.mpmath import mpf, mpc
from mpmath import mpf, mpc
# the precision of an mpf value is the last element
# if that is 1 (and m[1] is not 1 which would indicate a
# power of 2), then the eval failed; so check that none of
Expand Down Expand Up @@ -1223,7 +1223,7 @@ def doit_numerically(self, z0):
When we can represent derivatives at a point, this should be folded
into the normal evalf. For now, we need a special method.
"""
from sympy import mpmath
import mpmath
from sympy.core.expr import Expr
if len(self.free_symbols) != 1 or len(self.variables) != 1:
raise NotImplementedError('partials and higher order derivatives')
Expand Down
10 changes: 5 additions & 5 deletions sympy/core/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
from sympy.core.compatibility import (
as_int, integer_types, long, string_types, with_metaclass, HAS_GMPY,
SYMPY_INTS)
import sympy.mpmath as mpmath
import sympy.mpmath.libmp as mlib
from sympy.mpmath.libmp import mpf_pow, mpf_pi, mpf_e, phi_fixed
from sympy.mpmath.ctx_mp import mpnumeric
from sympy.mpmath.libmp.libmpf import (
import mpmath
import mpmath.libmp as mlib
from mpmath.libmp import mpf_pow, mpf_pi, mpf_e, phi_fixed
from mpmath.ctx_mp import mpnumeric
from mpmath.libmp.libmpf import (
finf as _mpf_inf, fninf as _mpf_ninf,
fnan as _mpf_nan, fzero as _mpf_zero, _normalize as mpf_normalize,
prec_to_dps)
Expand Down
2 changes: 1 addition & 1 deletion sympy/core/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .compatibility import as_int, xrange
from .evaluate import global_evaluate

from sympy.mpmath.libmp import sqrtrem as mpmath_sqrtrem
from mpmath.libmp import sqrtrem as mpmath_sqrtrem
from sympy.utilities.iterables import sift


Expand Down
4 changes: 2 additions & 2 deletions sympy/core/tests/test_evalf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
Sum, Product, Integral)
from sympy.core.evalf import complex_accuracy, PrecisionExhausted, scaled_zero
from sympy.core.compatibility import long
from sympy.mpmath import inf, ninf, nan
from mpmath import inf, ninf, nan
from sympy.abc import n, x, y
from sympy.mpmath.libmp.libmpf import from_float
from mpmath.libmp.libmpf import from_float
from sympy.utilities.pytest import raises, XFAIL


Expand Down
12 changes: 6 additions & 6 deletions sympy/core/tests/test_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from sympy.core.compatibility import long, u
from sympy.core.power import integer_nthroot
from sympy.core.numbers import igcd, ilcm, igcdex, seterr, _intcache, mpf_norm
from sympy.mpmath import mpf
from mpmath import mpf
from sympy.utilities.pytest import XFAIL, slow, raises
from sympy import mpmath
import mpmath


def test_integers_cache():
Expand Down Expand Up @@ -1356,8 +1356,8 @@ def test_issue_4172():

@XFAIL
def test_mpmath_issues():
from sympy.mpmath.libmp.libmpf import _normalize
import sympy.mpmath.libmp as mlib
from mpmath.libmp.libmpf import _normalize
import mpmath.libmp as mlib
rnd = mlib.round_nearest
mpf = (0, long(0), -123, -1, 53, rnd) # nan
assert _normalize(mpf, 53) != (0, long(0), 0, 0)
Expand All @@ -1366,7 +1366,7 @@ def test_mpmath_issues():
mpf = (1, long(0), -789, -3, 53, rnd) # -inf
assert _normalize(mpf, 53) != (0, long(0), 0, 0)

from sympy.mpmath.libmp.libmpf import fnan
from mpmath.libmp.libmpf import fnan
assert mlib.mpf_eq(fnan, fnan)


Expand Down Expand Up @@ -1397,7 +1397,7 @@ def test_int_NumberSymbols():


def test_issue_6640():
from sympy.mpmath.libmp.libmpf import (
from mpmath.libmp.libmpf import (
_normalize as mpf_normalize, finf, fninf, fzero)
# fnan is not included because Float no longer returns fnan,
# but otherwise, the same sort of test could apply
Expand Down
2 changes: 1 addition & 1 deletion sympy/core/tests/test_sympify.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from sympy.abc import _clash, _clash1, _clash2
from sympy.core.compatibility import exec_, HAS_GMPY

from sympy import mpmath
import mpmath


def test_issue_3538():
Expand Down
5 changes: 3 additions & 2 deletions sympy/core/tests/test_wester.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@
bernoulli, hyper, hyperexpand, besselj, asin, assoc_legendre, Function, re,
im, DiracDelta, chebyshevt, legendre_poly, polylog, series, O,
atan, sinh, cosh, tanh, floor, ceiling, solve, asinh, acot, csc, sec,
LambertW, N, apart, sqrtdenest, factorial2, powdenest, Mul, S, mpmath, ZZ,
LambertW, N, apart, sqrtdenest, factorial2, powdenest, Mul, S, ZZ,
Poly, expand_func, E, Q, And, Or, Ne, Eq, Le, Lt,
ask, refine, AlgebraicNumber, continued_fraction_iterator as cf_i,
continued_fraction_periodic as cf_p, continued_fraction_convergents as cf_c,
continued_fraction_reduce as cf_r, FiniteSet, elliptic_e, elliptic_f,
powsimp, hessian, wronskian, fibonacci, sign, Lambda, Piecewise, Subs,
residue, Derivative, logcombine, Symbol, AlgebraicNumber)

import mpmath
from sympy.functions.combinatorial.numbers import stirling
from sympy.functions.special.zeta_functions import zeta
from sympy.integrals.deltafunctions import deltaintegrate
from sympy.utilities.pytest import XFAIL, slow, SKIP, skip, ON_TRAVIS
from sympy.utilities.iterables import partitions
from sympy.mpmath import mpi, mpc
from mpmath import mpi, mpc
from sympy.matrices import Matrix, GramSchmidt, eye
from sympy.matrices.expressions.blockmatrix import BlockMatrix, block_collapse
from sympy.matrices.expressions import MatrixSymbol, ZeroMatrix
Expand Down
2 changes: 1 addition & 1 deletion sympy/external/tests/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Matrix, lambdify, symarray, symbols, Integer)
import sympy

from sympy import mpmath
import mpmath
from sympy.abc import x, y, z
from sympy.utilities.decorator import conserve_mpmath_dps

Expand Down
8 changes: 4 additions & 4 deletions sympy/functions/combinatorial/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from sympy.functions.elementary.trigonometric import sin, cos, cot
from sympy.functions.combinatorial.factorials import factorial

from sympy.mpmath import bernfrac, workprec
from sympy.mpmath.libmp import ifib as _ifib
from mpmath import bernfrac, workprec
from mpmath.libmp import ifib as _ifib


def _product(a, b):
Expand Down Expand Up @@ -704,7 +704,7 @@ def eval(cls, m):
if m.is_odd:
return S.Zero
if m.is_Integer and m.is_nonnegative:
from sympy.mpmath import mp
from mpmath import mp
m = m._to_mpmath(mp.prec)
res = mp.eulernum(m, exact=True)
return Integer(res)
Expand All @@ -723,7 +723,7 @@ def _eval_evalf(self, prec):
m = self.args[0]

if m.is_Integer and m.is_nonnegative:
from sympy.mpmath import mp
from mpmath import mp
from sympy import Expr
m = m._to_mpmath(prec)
with workprec(prec):
Expand Down
8 changes: 4 additions & 4 deletions sympy/functions/special/bessel.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,8 @@ def jn_zeros(n, k, method="sympy", dps=15):
from math import pi

if method == "sympy":
from sympy.mpmath import besseljzero
from sympy.mpmath.libmp.libmpf import dps_to_prec
from mpmath import besseljzero
from mpmath.libmp.libmpf import dps_to_prec
from sympy import Expr
prec = dps_to_prec(dps)
return [Expr._from_mpmath(besseljzero(S(n + 0.5)._to_mpmath(prec),
Expand Down Expand Up @@ -1209,7 +1209,7 @@ def fdiff(self, argindex=1):
raise ArgumentIndexError(self, argindex)

def _eval_evalf(self, prec):
from sympy.mpmath import mp, workprec
from mpmath import mp, workprec
from sympy import Expr
z = self.args[0]._to_mpmath(prec)
with workprec(prec):
Expand Down Expand Up @@ -1365,7 +1365,7 @@ def fdiff(self, argindex=1):
raise ArgumentIndexError(self, argindex)

def _eval_evalf(self, prec):
from sympy.mpmath import mp, workprec
from mpmath import mp, workprec
from sympy import Expr
z = self.args[0]._to_mpmath(prec)
with workprec(prec):
Expand Down
2 changes: 1 addition & 1 deletion sympy/functions/special/error_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ class li(Function):
We can even compute Soldner's constant by the help of mpmath:
>>> from sympy.mpmath import findroot
>>> from mpmath import findroot
>>> findroot(li, 2)
1.45136923488338
Expand Down
4 changes: 2 additions & 2 deletions sympy/functions/special/gamma_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def eval(cls, a, x):
return (cls(a + 1, x) + x**a * C.exp(-x))/a

def _eval_evalf(self, prec):
from sympy.mpmath import mp, workprec
from mpmath import mp, workprec
from sympy import Expr
a = self.args[0]._to_mpmath(prec)
z = self.args[1]._to_mpmath(prec)
Expand Down Expand Up @@ -400,7 +400,7 @@ def fdiff(self, argindex=2):
raise ArgumentIndexError(self, argindex)

def _eval_evalf(self, prec):
from sympy.mpmath import mp, workprec
from mpmath import mp, workprec
from sympy import Expr
a = self.args[0]._to_mpmath(prec)
z = self.args[1]._to_mpmath(prec)
Expand Down
3 changes: 2 additions & 1 deletion sympy/functions/special/hyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,8 @@ def _eval_evalf(self, prec):
# (carefully so as not to loose the branch information), and evaluate
# G(z'**(1/r)) = G(z'**n) = G(z).
from sympy.functions import exp_polar, ceiling
from sympy import mpmath, Expr
from sympy import Expr
import mpmath
z = self.argument
znum = self.argument._eval_evalf(prec)
if znum.has(exp_polar):
Expand Down
2 changes: 1 addition & 1 deletion sympy/functions/special/spherical_harmonics.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def _eval_evalf(self, prec):
# Note: works without this function by just calling
# mpmath for Legendre polynomials. But using
# the dedicated function directly is cleaner.
from sympy.mpmath import mp, workprec
from mpmath import mp, workprec
from sympy import Expr
n = self.args[0]._to_mpmath(prec)
m = self.args[1]._to_mpmath(prec)
Expand Down
2 changes: 1 addition & 1 deletion sympy/liealgebras/weyl_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from sympy.core import Basic, Rational
from sympy.core.numbers import igcd
from .cartan_type import CartanType
from sympy.mpmath import fac
from mpmath import fac
from operator import itemgetter
from itertools import groupby
from sympy.matrices import Matrix, eye
Expand Down
4 changes: 2 additions & 2 deletions sympy/matrices/matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ def LUsolve(self, rhs, iszerofunc=_iszero):
"""Solve the linear system Ax = rhs for x where A = self.
This is for symbolic matrices, for real or complex ones use
sympy.mpmath.lu_solve or sympy.mpmath.qr_solve.
mpmath.lu_solve or mpmath.qr_solve.
See Also
========
Expand Down Expand Up @@ -1615,7 +1615,7 @@ def QRsolve(self, b):
to use QRsolve.
This is mainly for educational purposes and symbolic matrices, for real
(or complex) matrices use sympy.mpmath.qr_solve.
(or complex) matrices use mpmath.qr_solve.
See Also
========
Expand Down
2 changes: 1 addition & 1 deletion sympy/ntheory/partitions_.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import print_function, division

from sympy.mpmath.libmp import (fzero,
from mpmath.libmp import (fzero,
from_man_exp, from_int, from_rational,
fone, fhalf, bitcount, to_int, to_str, mpf_mul, mpf_div, mpf_sub,
mpf_add, mpf_sqrt, mpf_pi, mpf_cosh_sinh, pi_fixed, mpf_cos)
Expand Down
2 changes: 1 addition & 1 deletion sympy/physics/quantum/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sympy.core.singleton import Singleton
from sympy.core.compatibility import u, with_metaclass
from sympy.printing.pretty.stringpict import prettyForm
import sympy.mpmath.libmp as mlib
import mpmath.libmp as mlib

#-----------------------------------------------------------------------------
# Constants
Expand Down
2 changes: 1 addition & 1 deletion sympy/physics/quantum/qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from sympy.physics.quantum.matrixutils import (
numpy_ndarray, scipy_sparse_matrix
)
from sympy.mpmath.libmp.libintmath import bitcount
from mpmath.libmp.libintmath import bitcount

__all__ = [
'Qubit',
Expand Down
2 changes: 1 addition & 1 deletion sympy/polys/domains/groundtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self, obj):
gmpy_qdiv = None


import sympy.mpmath.libmp as mlib
import mpmath.libmp as mlib


def python_sqrt(n):
Expand Down
Loading

0 comments on commit a410dc8

Please sign in to comment.