[SciPy-dev] Re: [SciPy-user] scipy choice of defaults for matrix manipulation

Robert Kern rkern at ucsd.edu
Thu Aug 5 20:26:39 CDT 2004

Alan G Isaac wrote:


> Looking at briefly at Numeric and numarray, it seems they
> have made an effort to standardize on axis=0.  

No, they don't. It's a fairly even mix of axis=0 and axis=-1.

> This is also
> true in the Matlab module.  Wouldn't it be wise for SciPy
> to join the parade? 

Not at this time. There's too much SciPy code that would need to be 
rewritten, namely SciPy itself. The axis=-1 convention will be staying.

> (I.e., shouldn't these closely related
> and interdependent packages share a convention?
> Otherwise, this is going to be VERY confusing for users.
> (As it was for me.)  Now when I call a such a function,
> I have to remember: is it a SciPy function, or a
> Numeric/numarray function?  

Well, if it's SciPy, axis=-1 almost always (the deviations usually being 
the functions which shadow Numeric functions). If it's Numeric, you also 
have to remember if it's axis=0 or axis=-1. If it's numarray, then you 
have other problems since SciPy is currently all-Numeric. The real 
question you have to ask yourself when coding is "did SciPy overwrite 
this Numeric function?", a question that needs to be asked for reasons 
other than the choice of default axis.

I would also note that having a terminal running IPython is invaluable 
when coding. The ? and ?? magic is usually better than a reference manual.

> Not a good situation, right?

It's arguable that SciPy functions which shadow Numeric functions should 
have the same defaults. It is also arguable that SciPy functions should 
be internally consistent, so when a Numeric function is overwritten (to 
add genericity or whatever) it should follow the SciPy convention. 
Neither choice has been rigorously implemented although after I poked 
around in IPython for a minute or two, cumsum() appears to be the only 
deviation from the first option. This might qualify as a bug.

> Thanks,
> Alan

Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

More information about the Scipy-dev mailing list