[NumPy-Tickets] [NumPy] #1441: rollaxis() has confusing error messages and should maybe interpret negative start argument differently

NumPy Trac numpy-tickets@scipy....
Tue Sep 21 14:24:47 CDT 2010


#1441: rollaxis() has confusing error messages and should maybe interpret negative
start argument differently
------------------------+---------------------------------------------------
 Reporter:  kbasye      |       Owner:  somebody      
     Type:  defect      |      Status:  needs_decision
 Priority:  normal      |   Milestone:  Unscheduled   
Component:  numpy.core  |     Version:                
 Keywords:              |  
------------------------+---------------------------------------------------

Comment(by kbasye):

 Replying to [comment:1 rgommers]:
 > The documentation in your proposed new version for "start" is actually
 consistent only with the current behavior. I found rollaxis confusing at
 first too, but when I read the docstring now it makes sense.

 I assume you are referring to the sentence describing the semantics of the
 'start' argument: "The axis is rolled until it lies before this position."

 I actually don't think this is worded very well; I'd prefer 'at' rather
 than 'before'.  Assuming that the positions of the shape are numbered
 starting with 0 (which is how the 'axis' argument works), then, as the
 first example shows, using a 'start' value of 1 rolls the specified axis
 until it lies *at* position 1.  To me, 'before' position 1 would have to
 mean 'at' position 0, which isn't what happens.  And with that change, the
 interpretation of '-1' for 'start' should mean the last position, which is
 how my change would work.

 I suppose one reading that would make the current version correct is "The
 axis is rolled until it lies before <<the axis currently at>> this
 position" - in which case you're correct that it doesn't accurately
 describe the new behavior I propose.  But then I don't think there is any
 good way to describe moving something to the last position (as in the
 third example), since there's no current axis at position 4 to be 'before'
 (as it were), which seems like another reason to prefer the 'at' version.

 > Either way, since you're proposing to modify existing behavior, the
 correct place to discuss this on the mailing list. Since it will break a
 lot of existing code I don't think there's a lot of chance this gets
 accepted though.

 Yeah, I know.  I'm somewhat tempted to see if folks would go for the
 addition of moveaxis() which would work this way.  Calling this function
 'rollaxis' seems sort of odd, given that only one axis moves - compare the
 roll() function, which really does roll in the usual register sense.  BTW,
 all this came up because it seemed like there really should be a better
 way to get the first (or any other axis) into the last position than doing
 np.rollaxis(a, axis, len(a.shape)) but right now I don't think there is.
 I'll float it on the list and see what happens.

 > Your extra examples and more accurate error message should be included I
 think even if the proposed change is rejected.

 I'd settle for that.

 And thanks for replying!

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1441#comment:2>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list