[Numpy-discussion] Bugfix for numpy.info bug
Fernando Perez
fperez.net@gmail....
Tue Jun 19 18:25:22 CDT 2007
Bug
===
In [8]: N.info(N.ones(3))
class: ndarray
shape: (3,)
strides: (8,)
itemsize: 8
aligned: True
contiguous: True
fortran: True
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/fperez/research/code/mwadap-stable/mwadap/test/<ipython console>
in <module>()
/home/fperez/usr/opt/lib/python2.5/site-packages/numpy/lib/utils.py in
info(object, maxwidth, output, toplevel)
298 elif isinstance(object, ndarray):
299 import numpy.numarray as nn
--> 300 nn.info(object, output=output, numpy=1)
301 elif isinstance(object, str):
302 if _namedict is None:
/home/fperez/usr/opt/lib/python2.5/site-packages/numpy/numarray/functions.py
in info(obj, output, numpy)
377 extra = ""
378 tic = ""
--> 379 print >> output, "data pointer: %s%s" %
(hex(obj.ctypes._as_parameter_), extra)
380 print >> output, "byteorder: ",
381 endian = obj.dtype.byteorder
TypeError: hex() argument can't be converted to hex
In [9]: debug
> /home/fperez/usr/opt/lib/python2.5/site-packages/numpy/numarray/functions.py(379)info()
378 tic = ""
--> 379 print >> output, "data pointer: %s%s" %
(hex(obj.ctypes._as_parameter_), extra)
380 print >> output, "byteorder: ",
Fix
===
planck[numpy]> svn diff
Index: numpy/numarray/functions.py
===================================================================
--- numpy/numarray/functions.py (revision 3874)
+++ numpy/numarray/functions.py (working copy)
@@ -376,7 +376,7 @@
else:
extra = ""
tic = ""
- print >> output, "data pointer: %s%s" %
(hex(obj.ctypes._as_parameter_), extra)
+ print >> output, "data pointer: %s%s" %
(hex(obj.ctypes._as_parameter_.value), extra)
print >> output, "byteorder: ",
endian = obj.dtype.byteorder
if endian in ['|','=']:
Question
========
any objection if I commit this? Since I don't really touch the
codebase often, I'd rather ask the real core people. I also don't
know if it's really the right thing to do, I just tabbed into the
object and picked what seemed to be the most reasonable answer. It's
trivial, but I'd rather double check.
Cheers,
f
More information about the Numpy-discussion
mailing list