[Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Jeremy Conlin
I have a need to index my array(s) starting with a 1 instead of a 0. The reason for this is to be consistent with the documentation of a format I'm accessing. I know I can just '-1' from what the documentation says, but that can get cumbersome. Is there a magic flag I can pass to a numpy array

Re: [Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Stéfan van der Walt
Hi Jeremy On Thu, Jul 28, 2011 at 3:19 PM, Jeremy Conlin jlcon...@gmail.com wrote: I have a need to index my array(s) starting with a 1 instead of a 0. The reason for this is to be consistent with the documentation of a format I'm accessing. I know I can just '-1' from what the documentation

Re: [Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Anne Archibald
Don't forget the everything-looks-like-a-nail approach: make all your arrays one bigger than you need and ignore element zero. Anne On 7/28/11, Stéfan van der Walt ste...@sun.ac.za wrote: Hi Jeremy On Thu, Jul 28, 2011 at 3:19 PM, Jeremy Conlin jlcon...@gmail.com wrote: I have a need to

Re: [Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Stéfan van der Walt
On Thu, Jul 28, 2011 at 4:10 PM, Anne Archibald aarch...@physics.mcgill.ca 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

Re: [Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Derek Homeier
On 29.07.2011, at 1:19AM, Stéfan van der Walt wrote: On Thu, Jul 28, 2011 at 4:10 PM, Anne Archibald aarch...@physics.mcgill.ca 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

Re: [Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Stéfan van der Walt
On Thu, Jul 28, 2011 at 4:26 PM, Derek Homeier de...@astro.physik.uni-goettingen.de wrote: 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

Re: [Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Anne Archibald
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

Re: [Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Derek Homeier
On 29.07.2011, at 1:38AM, Anne Archibald wrote: 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