[SciPy-user] arr.type() becomes arr.dtype - BOTH in scipyCore AND numarray !?
oliphant at ee.byu.edu
Fri Nov 4 14:21:43 CST 2005
Sebastian Haase wrote:
>I'm really excited about the progress of scipy - great work, Travis !
>Also I always need to thank Todd et al. for numarray which we are using for
>about 4 years now.
>I was following - I thought - all the postings here, but I don't remember when
>and what the reason was when a.type() changed to a.dtype (also there is a
>"dtypecode" somewhere !?). Any reference or explanation would be great.
>I have to say that the (old) parenthesis where always quite "annoying" ! ;-)
There is a dtypechar that gives a character string.
The problem is that it can get very confusing to distinguish between
Python's use of the word type and an array's use of type. So, we
changed the array's use of the word type to "dtype" for data-type.
All ndarray's have the same type (scipy.ndarray), but they can have
different data types.
>Question: does the way allow assignments like "a.dtype = Float32".
Yes, you can do that (if the itemsizes are compatible). It doesn't
change any data, but just changes the array information header so that a
now thinks the data is float32.
Attributes are intrinsic parts of the array. Setting them changes the
array directly. You can also get a float32 view of the array without
changing the original as
b = a.view(float32)
The old capitalized names are supported, but the lower-case names are
The module scipy.base.convertcode has functions that can automatically
change your source code to be compatible with any new naming
conventions. You can look at the file to see all the changes. These
changes are also documented in Chapter 2 of my book which is available
for free at http://www.tramy.us/guidetoscipy.html
>UCSF, Sedat Lab
>SciPy-user mailing list
>SciPy-user at scipy.net
More information about the SciPy-user