On Thu, 2003-09-18 at 13:53, Tim Hochberg wrote:
I'm just starting to move some of my code over to numarray and I was dismayed to find that basic operation between Numeric and numarray arrays fail.
import Numeric as np import numarray as na a = na.arange(5) p = np.arange(5) a + p ['vector', 'vector'] Traceback (most recent call last): File "<stdin>", line 1, in ? File "C:\Python23\Lib\site-packages\numarray\numarraycore.py", line 648, in __add__ def __add__(self, operand): return ufunc.add(self, operand) File "C:\Python23\lib\site-packages\numarray\ufunc.py", line 818, in _cache_miss2 key = (_digest(n1), _digest(n2), _digest(out), safethread.get_ident()) KeyError: '_digest force cache miss'
I suspect (hope!) that this is just a bug and not something inherent in numarray.
It's an interoperability issue. Please let us know if you find others.
I dug around in unfunc.py a bit and it appears that the bug is shallow and can be fixed simply by replacing::
if not (_sequence(n1) or _sequence(n2)): key = (_digest(n1), _digest(n2), _digest(out), safethread.get_ident()) self._cache[ key ] = cached
with::
try: key = (_digest(n1), _digest(n2), _digest(out), safethread.get_ident()) except KeyError: pass else: self._cache[ key ] = cached
in _cache_miss2 and _cache_miss1. If this were done, _sequence could probably be deleted as well.
I'm not very familiar with the numarray code yet, so it's quite possible I'm missing something, but I'm willing to do more digging to fix this if this turns out to not be sufficient.
I ran into the same problem trying to port MA to numarray, and came up with an identical work around. A fix like this will be part of numarray-0.8. Todd -- Todd Miller jmiller@stsci.edu STSCI / ESS / SSB