Re: [Python-Dev] C basetype mapping protocol difference between 2.2.1 and 2.3
Doesn't the current wrapper narrow the acceptable definitions for _ndarray_subscript? The reason I noticed this is that my 2.2.1 code raises an exception:
import numarray a=numarray.arange(10) a Traceback (most recent call last): File "<stdin>", line 1, in ? File "/home/jmiller/lib/python2.2/site-packages/numarray/numarray.py", line 622, in __repr__ MAX_LINE_WIDTH, PRECISION, SUPPRESS_SMALL, ', ', 1) File "/home/jmiller/lib/python2.2/site-packages/numarray/arrayprint.py", line 156, in array2string separator, array_output) File "/home/jmiller/lib/python2.2/site-packages/numarray/arrayprint.py", line 112, in _array2string max_str_len = max(len(str(max_reduce(data))), File "/home/jmiller/lib/python2.2/site-packages/numarray/ufunc.py", line 759, in reduce r = self.areduce(inarr, dim, outarr) File "/home/jmiller/lib/python2.2/site-packages/numarray/ufunc.py", line 745, in areduce _outarr1 = self._cumulative("reduce", _inarr, _outarr0) File "/home/jmiller/lib/python2.2/site-packages/numarray/ufunc.py", line 653, in _cumulative toutarr = self._reduce_out(inarr, outarr, outtype) File "/home/jmiller/lib/python2.2/site-packages/numarray/ufunc.py", line 591, in _reduce_out toutarr = inarr[...,0].copy().astype(outtype) TypeError: an integer is required
I guess that means it's going through the *sequence* getitem, not the *mapping* getitem. Have you tried leaving the sequence getitem slot NULL, and doing everything through your mapping getitem slot? That should work in 2.2. --Guido van Rossum (home page: http://www.python.org/~guido/)
Guido van Rossum wrote:
Doesn't the current wrapper narrow the acceptable definitions for _ndarray_subscript? The reason I noticed this is that my 2.2.1 code raises an exception:
import numarray a=numarray.arange(10) a Traceback (most recent call last): File "<stdin>", line 1, in ? File "/home/jmiller/lib/python2.2/site-packages/numarray/numarray.py", line 622, in __repr__ MAX_LINE_WIDTH, PRECISION, SUPPRESS_SMALL, ', ', 1) File "/home/jmiller/lib/python2.2/site-packages/numarray/arrayprint.py", line 156, in array2string separator, array_output) File "/home/jmiller/lib/python2.2/site-packages/numarray/arrayprint.py", line 112, in _array2string max_str_len = max(len(str(max_reduce(data))), File "/home/jmiller/lib/python2.2/site-packages/numarray/ufunc.py", line 759, in reduce r = self.areduce(inarr, dim, outarr) File "/home/jmiller/lib/python2.2/site-packages/numarray/ufunc.py", line 745, in areduce _outarr1 = self._cumulative("reduce", _inarr, _outarr0) File "/home/jmiller/lib/python2.2/site-packages/numarray/ufunc.py", line 653, in _cumulative toutarr = self._reduce_out(inarr, outarr, outtype) File "/home/jmiller/lib/python2.2/site-packages/numarray/ufunc.py", line 591, in _reduce_out toutarr = inarr[...,0].copy().astype(outtype) TypeError: an integer is required
I guess that means it's going through the *sequence* getitem, not the
Yes.
*mapping* getitem. Have you tried leaving the sequence getitem slot NULL, and doing everything through your mapping getitem slot?
No.
That should work in 2.2.
It does now.
--Guido van Rossum (home page: http://www.python.org/~guido/)
Thanks! Todd -- Todd Miller jmiller@stsci.edu STSCI / SSG
participants (2)
-
Guido van Rossum
-
Todd Miller