The can is open and the worms are everywhere, so: The big problem with one-based indexing for numpy is interpretation. In python indexing, -1 is the last element of the array, and ranges have a specific meaning. In a hypothetical one-based indexing scheme, would the last element be element 0? if not, what does looking up zero do? What about ranges - do ranges still include the first endpoint and not the second? I suppose one could choose the most pythonic of the 1-based conventions, but do any of them provide from-the-end indexing without special syntax?
Once one had decided what to do, implementation would be pretty easy - just make a subclass of ndarray that replaces the indexing function. Anne On 28 July 2011 19:26, Derek Homeier <[email protected]> wrote: > On 29.07.2011, at 1:19AM, Stéfan van der Walt wrote: > >> On Thu, Jul 28, 2011 at 4:10 PM, Anne Archibald >> <[email protected]> wrote: >>> Don't forget the everything-looks-like-a-nail approach: make all your >>> arrays one bigger than you need and ignore element zero. >> >> Hehe, why didn't I think of that :) >> >> I guess the kind of problem I struggle with more frequently is books >> written with summations over -m to +n. In those cases, it's often >> convenient to use the mapping function, so that I can enter the >> formulas as they occur. > > I don't want to open any cans of worms at this point, but given that > Fortran90 supports such indexing (arbitrary limits, including negative ones), > there definitely are use cases for it (or rather, instances where it is very > convenient at least, like in Stéfan's books). So I am wondering how much it > would take to implement such an enhancement for the standard ndarray... > > Cheers, > Derek > > _______________________________________________ > NumPy-Discussion mailing list > [email protected] > http://mail.scipy.org/mailman/listinfo/numpy-discussion > _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
