[Numpy-discussion] convertcode.py and float defaults

Ed Schofield schofield at ftw.at
Sat Jul 1 06:52:46 EDT 2006


On 30/06/2006, at 10:11 PM, Travis Oliphant wrote:

> I should have worded this as:
>
> "People who want arange to return floats *as a default* should be
> directed to linspace"
>
> So, basically, arange is not going to change.
>
> Because of this, shifting over was a cinch.   I still need to write  
> the
> convert-script code that inserts dtype=int
> in routines that use old defaults:  *plea* anybody want to write  
> that??

Hmm ... couldn't we make the transition easier and more robust by  
writing compatibility interfaces for zeros, ones, empty, called e.g.  
intzeros, intones, intempty?  These functions could of course live in  
oldnumeric.py.  Then we can get convertcode.py to do a simple search  
and replace -- and, more importantly, it's easy for users to do the  
same manually should they choose not to use convertcode.py.

I could work on this this weekend.

I'm pleased we're changing the defaults to float.  The combination of  
the int defaults and silent downcasting with in-place operators trips  
me up once every few months when I forget to specify dtype=float  
explicitly.  Another wart gone from NumPy!  I'm surprised and  
impressed that the community's willing to make this change after 10+  
years with int defaults.  I think it's a small but important  
improvement in usability.

-- Ed





More information about the NumPy-Discussion mailing list