[Numpy-discussion] RE: default axis for numarray

Paul F Dubois paul at pfdubois.com
Wed Jun 12 15:43:01 EDT 2002

The users of Numeric at PCMDI found the 'view' semantics so annoying
that they insisted their CS staff write a separate version of Numeric
just to avoid it. We have since gotten out of that mess but that is the
reason MA has copy semantics.

Again, this is another issue where one is fighting over the right to
'own' the operator notation. I believe that copy semantics should win
this one because it is a **proven fact** that scientists trip over it,
and it is consistent with Python list semantics. People who really need
view semantics could get it as previously suggested by someone, with
something like x.sub[10:12, :]. 

There are now dead horses all over the landscape, and I for one am going
to shut up.

> -----Original Message-----
> From: numpy-discussion-admin at lists.sourceforge.net 
> [mailto:numpy-discussion-admin at lists.sourceforge.net] On 
> Behalf Of Paul Barrett
> Sent: Wednesday, June 12, 2002 8:54 AM
> To: numpy-discussion
> Subject: Re: [Numpy-discussion] RE: default axis for numarray
> eric jones wrote:
> > 
> > I think the consistency with Python is less of an issue 
> than it seems. 
> > I wasn't aware that add.reduce(x) would generated the same 
> results as 
> > the Python version of reduce(add,x) until Perry pointed it 
> out to me. 
> > There are some inconsistencies between Python the language 
> and Numeric 
> > because the needs of the Numeric community.  For instance, slices 
> > create views instead of copies as in Python.  This was a 
> correct break 
> > with consistency in a very utilized area of Python because 
> of efficiency.
> <Begin Rant>
> I think consistency is an issue, particularly for novices.  
> You cite the issue 
> of slices creating views instead of copies as being the 
> correct choice.  But 
> this decision is based solely on the perception that views 
> are 'inherently' more 
> efficient than copies and not on reasons of consistency or 
> usability.  I (a 
> seasoned user) find view behavior to be annoying and have 
> been caught out on 
> this several times.  For example, reversing in-place the 
> elements of any array 
> using slices, i.e. A = A[::-1], will give the wrong answer, 
> unless you 
> explicitly make a copy before doing the assignment.  Whereas, 
> copy behavior will 
> do the right thing.  I suggest that many novices will be 
> caught out by this and 
> similar examples, as I have been.  Copy behavior for slices 
> can be just as 
> efficient as view behavior, if implemented as copy-on-write.
> The beauty of Python is that it allows the developer to spend 
> much more time on 
> consistency and usability issues than on implementation 
> issues.  Sadly, I think 
> much of Numeric development is based solely on implementation 
> issues to the 
> detriment of consistency and usability.
> I don't have enough experience to definitely say whether 
> axis=0 should be 
> preferred over axis=-1 or vice versa. But is does appear that 
> for the most 
> general cases axis=0 is probably preferred.  This is the 
> default for the APL and 
> J programming of which Numeric is based.  Should we not 
> continue to follow their 
> lead?  It might be nice to see a list of examples where 
> axis=0 is the preferred 
> default and the same for axis=-1.
> <End Rant>
> -- 
> Paul Barrett, PhD      Space Telescope Science Institute
> Phone: 410-338-4475    ESS/Science Software Group
> FAX:   410-338-4767    Baltimore, MD 21218
> _______________________________________________________________
> Sponsored by:
> ThinkGeek at http://www.ThinkGeek.com/ 
> _______________________________________________
> Numpy-discussion mailing list Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion

More information about the NumPy-Discussion mailing list