bug in http://www.scipy.org/NumPy_for_Matlab_Users
now there is MATLAB NDArray Matrix size(a,n) a.shape[n] a.shape[n] but it should be size(a,n) a.shape[n-1] a.shape[n-1] WBR, D.
No, the nth index of a Python sequence is a[n], where n starts from zero. Thus, if I want the nth dimension of array a, I want a.shape[n]. I reverted the page to its original form and added a couple explanatory comments about zero vs one based indexing. dmitrey wrote:
now there is MATLAB NDArray Matrix size(a,n) a.shape[n] a.shape[n]
but it should be size(a,n) a.shape[n-1] a.shape[n-1]
WBR, D. _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
I think it's better to add "see remark!" inside the cells because not all people read the text from 4th column and this can lead to serious mistakes and lot of time elapsed for bug hunting. WBR, D. Andrew Straw wrote:
No, the nth index of a Python sequence is a[n], where n starts from zero. Thus, if I want the nth dimension of array a, I want a.shape[n].
I reverted the page to its original form and added a couple explanatory comments about zero vs one based indexing.
dmitrey wrote:
now there is MATLAB NDArray Matrix size(a,n) a.shape[n] a.shape[n]
but it should be size(a,n) a.shape[n-1] a.shape[n-1]
WBR, D. _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
On Sun, 29 Apr 2007, Andrew Straw apparently wrote:
No, the nth index of a Python sequence is a[n], where n starts from zero. Thus, if I want the nth dimension of array a, I want a.shape[n].
So now we have no seventh day of the week? Even the Python reference manual has Monday as the *first* (not zeroth) day of the week, with index 0. Cheers, Alan Isaac
On 4/29/07, Andrew Straw
No, the nth index of a Python sequence is a[n], where n starts from zero. Thus, if I want the nth dimension of array a, I want a.shape[n].
I reverted the page to its original form and added a couple explanatory comments about zero vs one based indexing.
Would it be better to replace n with a number, say, 2? size(a, 2) a.shape[1]
On 4/29/07, Andrew Straw
No, the nth index of a Python sequence is a[n], where n starts from zero. Thus, if I want the nth dimension of array a, I want a.shape[n].
I reverted the page to its original form and added a couple explanatory comments about zero vs one based indexing.
Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
On 4/29/07, Kevin Jacobs
On 4/29/07, Andrew Straw
wrote: No, the nth index of a Python sequence is a[n], where n starts from zero. Thus, if I want the nth dimension of array a, I want a.shape[n].
I reverted the page to its original form and added a couple explanatory comments about zero vs one based indexing.
Those among us who value correct English will continue to insist that ordinal numbers begin with "first" and the concept of "zeroth" is an unnatural technological bastardization. (This is not to say that zero-based indexing is bad -- just distinct from the ordinal.)
Ordinals begin with the empty set, 0, and continue 1 := {0}, 2 := {0, {0}}, 3 := {0, {0}, {{0, {0}}}, ... The first index of 'a' is 0, the first element is a[0], the second index is
1 and the second element is a[1], etc. Thus, the n-th index or element, a contraction of ordinal numbering, is correctly and canonically written as a[n-1] in a zero-based index scheme. The linguistics of "n-th" are that of ordinality in both English and mathematics, requiring an explicitly mapping to the technological concept of a given indexing syntax.
Fortran by default uses 1 based indexing, but uses a "magic" pointer so that actual indexing is zero based, look at the internals of a Fortran compiler sometime an see. I think this points out that zero based indexing is more natural. Glossing over that difference, especially when it contradicts the most
natural conventions of the target audience, is unfriendly and counterintuitive. The only reason why it makes sense to you only because of your disadvantage of already understanding that which you are trying to explain.
I love these little flame wars, not that there aren't things I *really* should be doing. Chuck http://projects.scipy.org/mailman/listinfo/numpy-discussion
participants (6)
-
Alan G Isaac
-
Andrew Straw
-
Charles R Harris
-
dmitrey
-
Keith Goodman
-
Kevin Jacobs <jacobs@bioinformed.com>