[Numpy-discussion] types as functions convert 1 elm arrays to scalars
Hoyt Koepke
hoytak@gmail....
Tue Apr 29 01:28:14 CDT 2008
Hello,
I have a quick question that I'm hoping will improve my numpy
understanding. I noticed some behavior when using float64 to convert
a matrix type that I didn't expect:
In [35]: b1 = array([1.0])
In [36]: float64(b1)
Out[36]: 1.0
In [37]: b2 = array([1.0, 2.0])
In [38]: float64(b2)
Out[38]: array([ 1., 2.])
I didn't expect calling float64 would convert b1 to a scalar. Seems
like an inconsistency. I assume this is intentional, as someone would
have noticed it a long time ago if not, so could someone explain the
reasoning behind it? (or point me to a source that will help?)
Thanks!
--Hoyt
--
+++++++++++++++++++++++++++++++++++
Hoyt Koepke
UBC Department of Computer Science
http://www.cs.ubc.ca/~hoytak/
hoytak@gmail.com
+++++++++++++++++++++++++++++++++++
More information about the Numpy-discussion
mailing list