This should allow mpmath to optionally function in non-sage mode on systems
where sage is available.
http://code.google.com/p/mpmath/source/detail?r=1231
Modified:
/trunk/mpmath/ctx_mp.py
=======================================
--- /trunk/mpmath/ctx_mp.py Fri Jan 28 12:37:56 2011
+++ /trunk/mpmath/ctx_mp.py Sun Feb 27 11:04:46 2011
@@ -8,7 +8,7 @@
from .ctx_base import StandardBaseContext
-from .libmp.backend import basestring
+from .libmp.backend import basestring, BACKEND
from . import libmp
@@ -43,12 +43,11 @@
get_complex = re.compile(r'^\(?(?P<re>[\+\-]?\d*\.?\d*(e[\+\-]?\d+)?)??'
r'(?P<im>[\+\-]?\d*\.?\d*(e[\+\-]?\d+)?j)?\)?$')
-
-try:
+if BACKEND == 'sage':
from sage.libs.mpmath.ext_main import Context as BaseMPContext
# pickle hack
import sage.libs.mpmath.ext_main as _mpf_module
-except ImportError:
+else:
from .ctx_mp_python import PythonMPContext as BaseMPContext
from . import ctx_mp_python as _mpf_module