[mpmath] r1231 committed - check BACKEND in ctx_mp instead of using try/except ImportError...

8 views
Skip to first unread message

mpm...@googlecode.com

unread,
Feb 27, 2011, 2:05:49 PM2/27/11
to mpmath-...@googlegroups.com
Revision: 1231
Author: fredrik.johansson
Date: Sun Feb 27 11:04:46 2011
Log: check BACKEND in ctx_mp instead of using try/except ImportError

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

Reply all
Reply to author
Forward
0 new messages