[Numpy-discussion] RE: [Numpy-user] possible error with isarrtype

O'Keefe, Michael Michael_OKeefe at nrel.gov
Tue Jan 31 13:07:14 CST 2006


> Now, the data-type object itself is the preferred way.  I need to figure 
> out what to do with these functions now and see if they even have any 
> use anymore.

Thanks Travis. 

With regard to what to do with the functions, I only ended up trying them because they were there. From my point of view, I'd love to learn how to code the "right" way. To that end, any means of informing the user of "deprecated" functions (or just taking them out) would be fine with me. However, I realize some may have legacy code and so I would defer to their opinions.

> What use were you making of them?

I was just migrating some working scipy/numeric code I'd been using to the newer numpy (0.9.4), python (2.4.2), and scipy (0.4.4).

When I ran my unit-tests, one line that gave me problems was:

import scipy as sp
...
assert( type(deltaTime_sec)==float )

This line of code was there to inform me if I was accidentally passing in an array type instead of a scalar. This no longer worked in the new environment. The type of deltaTime_sec came out as float64_arrtype which did not equal type float causing the assertion to trip which I believe to be caused by the following:

>>> a=sp.array([1.],float)
>>> type(a)
<type 'numpy.ndarray'>
>>> type(a[0]) # somewhere I assign deltaTime_sec = someArray[0]
<type 'float64_arrtype'>

I ended up fixing it with the following code which seems to do the trick (though I'm always keen to learn better ways of doing things):

assert( sp.size(deltaTime_sec)==1 )

Thanks!

Michael




More information about the Numpy-discussion mailing list