This suggests that maybe the first line is a buglet (without any real 
consequence), since there happens to be no good reason to require that 
array to be single precision.  I think it's reasonable to say that we 
should use double precision (float/float_/float64) everywhere floating 
point is needed, since a) that's what Python floats are and b) it's on 
the safe side precision-wise, and c) that's what most (if not all) of 
the C++ extensions, such as _backend_agg.cpp expect.  Exceptions would 
be when some binary interface or file format etc. requires otherwise. 

Note, the first line also has a moderate performance penalty since the 
array might be converted twice (once for asarray, and once for astype).  
It would be better to do:

  x = np.asarray(x, np.float_)

As for the distinction between the last two, I think it is primarily a 
style issue.  I don't have a strong feeling either way, but consistency 
would be an improvement, I suppose.

Cheers,
Mike

Stéfan van der Walt wrote:
> 2008/6/12 Manuel Metz <[EMAIL PROTECTED]>:
>   
>> When looking, e.g. at axes.py, I see 3 different arguments passed to
>> numpy astype()/array()/zero() and friends:
>>
>>   x = np.asarray(x).astype(np.float32)
>>   x = np.zeros( x, np.float_ )
>>   x = np.ones((col,), float)
>>
>> Is there a preferred one to stick to ?!
>>     
>
> Both `np.float_` and the Python `float` are interpreted as
> `np.float64`.  The only time you really need something other than
> `float` is if you require a width other than 64 (like in the first
> line you showed).
>
> Regards
> Stéfan
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>   

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to