[Numpy-discussion] Array printing differences between 64- and 32-bit platforms

2008-10-15 Thread Ken Basye
Hi Folks,
  In porting some code to a 64-bit machine, I ran across the following 
issue. 
On the 64-bit machine, an array with dtype=int32 prints the dtype 
explicitly, whereas on
a 32 bit machine it doesn't.  The same is true for dtype=intc (since 
'intc is int32' -- True),
and the converse is true for dtype=int64 and dtype=longlong.  Arrays 
with dtype of plain int
both print without the dtype, but then you're not using the same 
underlying size anymore.
  I think this is handled in core/numeric.py in array_repr and just 
above, where certain types
are added to _typelessdata if they are subclasses of 'int'.  The 
issubclass test returns different values
on platforms with different word lengths.
  This difference can make doctests fail and although there are doctest 
tricks to prevent the failure,
they're a bit annoying to use.  I was wondering about introducing a new 
print setting that forced
dtypes to be printed always.   Is there any support for that? 
  Any other ideas would also be most welcome.

Thanks,
Ken Basye
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Array printing differences between 64- and 32-bit platforms

2008-10-15 Thread Charles R Harris
On Wed, Oct 15, 2008 at 10:52 AM, Ken Basye [EMAIL PROTECTED] wrote:

 Hi Folks,
  In porting some code to a 64-bit machine, I ran across the following
 issue.
 On the 64-bit machine, an array with dtype=int32 prints the dtype
 explicitly, whereas on
 a 32 bit machine it doesn't.  The same is true for dtype=intc (since
 'intc is int32' -- True),
 and the converse is true for dtype=int64 and dtype=longlong.  Arrays
 with dtype of plain int
 both print without the dtype, but then you're not using the same
 underlying size anymore.
  I think this is handled in core/numeric.py in array_repr and just
 above, where certain types
 are added to _typelessdata if they are subclasses of 'int'.  The
 issubclass test returns different values
 on platforms with different word lengths.
  This difference can make doctests fail and although there are doctest
 tricks to prevent the failure,
 they're a bit annoying to use.  I was wondering about introducing a new
 print setting that forced
 dtypes to be printed always.   Is there any support for that?
  Any other ideas would also be most welcome.


I'm inclined to say always print the type, but that is a behavior change and
might break some current code. I'm not sure how we should handle small
fixups like that.

Chuck
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion