I am using mpmath.hyp2f1 in a bioinformatics application which requires high precision arithmetic in order to avoid rounding issues with important input domains. The application requires quite a bit of repeated computation of this function, and we were hoping that setting up gmpy would significantly improve our performance. From the home page:
I first tried installing gmpy2, which lead to the following error:
Traceback (most recent call last):
File "beta_rat.py", line 7, in <module>
import mpmath
File "/home/matsengrp/python-local/lib/python2.7/site-packages/mpmath/__init__.py", line 5, in <module>
from .ctx_fp import FPContext
File "/home/matsengrp/python-local/lib/python2.7/site-packages/mpmath/ctx_fp.py", line 1, in <module>
from .ctx_base import StandardBaseContext
File "/home/matsengrp/python-local/lib/python2.7/site-packages/mpmath/ctx_base.py", line 3, in <module>
from .libmp.backend import xrange
File "/home/matsengrp/python-local/lib/python2.7/site-packages/mpmath/libmp/__init__.py", line 1, in <module>
from .libmpf import (prec_to_dps, dps_to_prec, repr_dps,
File "/home/matsengrp/python-local/lib/python2.7/site-packages/mpmath/libmp/libmpf.py", line 20, in <module>
from .libintmath import (giant_steps,
File "/home/matsengrp/python-local/lib/python2.7/site-packages/mpmath/libmp/libintmath.py", line 302, in <module>
sqrtrem = gmpy.sqrtrem
AttributeError: 'module' object has no attribute 'sqrtrem'
Hunting around, I was able to find that only gmpy1 is supported with mpmath. While it's not the main point of my enquiry here, may I suggest clarifying this in the home page by doing
s/gmpy/gmpy1/?
After removing gmpy2 and installing gmpy, I reran my program, and though the errors above went away, I didn't notice any performance boost. I would imagine that since it was (apparently) able to find gmpy2, mpmath probably is finding (and presumably using) gmpy1. Is there any way to tell whether this is the case? Is it possible that there are components of mpmath (such as hyp2f1) that aren't set up to use gmpy? Or is gmpy just not the silver bullet that I was hoping it would be?
I very much appreciate any feedback you might be able to provide in this matter.
Best Wishes
Christopher Small
Programmer and Systems Analysis
Computational Biology Program
Fred Hutchinson Cancer Research Center