[SciPy-user] arr.type() becomes arr.dtype - BOTH in scipyCore AND numarray !?

Travis Oliphant oliphant at ee.byu.edu
Fri Nov 4 14:21:43 CST 2005


Sebastian Haase wrote:

>Hi,
>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.

a.dtypechar

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 
now standard.

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


-Travis

>Sebastian Haase
>UCSF, Sedat Lab
>
>_______________________________________________
>SciPy-user mailing list
>SciPy-user at scipy.net
>http://www.scipy.net/mailman/listinfo/scipy-user
>  
>



More information about the SciPy-user mailing list