Re: [Numpy-discussion] RFC: out of range slice indexes
Neal Becker wrote: I've never liked that python silently ignores slices with out of range indexes. I believe this is a source of bugs (it has been for me). It goes completely counter to the python philosophy. I vote to ban them from numpy. from numpy import array x = array (xrange (10)) x[11] Traceback (most recent call last): File stdin, line 1, in module IndexError: index out of bounds x[:12] = 2 x array([2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) len (x) 10 Silently ignoring the error x[:12] is a bad idea, IMO. If it meant to _extend_ x to have lenght 12, at least _that_ would be reasonable (but I'm not advocating that position). I believe that out of bounds indexes should always throw IndexError. We can't change that in Python now, but maybe we can in numpy. OK, here's another idea: How about an _optional_ warning, which relies on numpy.warn setting? Could be a big aid in debugging. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] RFC: out of range slice indexes
I've never liked that python silently ignores slices with out of range indexes. I believe this is a source of bugs (it has been for me). It goes completely counter to the python philosophy. I vote to ban them from numpy. from numpy import array x = array (xrange (10)) x[11] Traceback (most recent call last): File stdin, line 1, in module IndexError: index out of bounds x[:12] = 2 x array([2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) len (x) 10 Silently ignoring the error x[:12] is a bad idea, IMO. If it meant to _extend_ x to have lenght 12, at least _that_ would be reasonable (but I'm not advocating that position). I believe that out of bounds indexes should always throw IndexError. We can't change that in Python now, but maybe we can in numpy. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] RFC: out of range slice indexes
Neal Becker wrote: I've never liked that python silently ignores slices with out of range indexes. I believe this is a source of bugs (it has been for me). It goes completely counter to the python philosophy. I vote to ban them from numpy. from numpy import array x = array (xrange (10)) x[11] Traceback (most recent call last): File stdin, line 1, in module IndexError: index out of bounds x[:12] = 2 x array([2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) len (x) 10 Silently ignoring the error x[:12] is a bad idea, IMO. If it meant to _extend_ x to have lenght 12, at least _that_ would be reasonable (but I'm not advocating that position). I believe that out of bounds indexes should always throw IndexError. We can't change that in Python now, but maybe we can in numpy. -1. Regardless of the merits if we had a blank slate, there is code that depends on this, specifically my code. It simplifies certain operations that would otherwise need tedious special case-handling. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] RFC: out of range slice indexes
Neal Becker wrote: Robert Kern wrote: Neal Becker wrote: I've never liked that python silently ignores slices with out of range indexes. I believe this is a source of bugs (it has been for me). It goes completely counter to the python philosophy. I vote to ban them from numpy. from numpy import array x = array (xrange (10)) x[11] Traceback (most recent call last): File stdin, line 1, in module IndexError: index out of bounds x[:12] = 2 x array([2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) len (x) 10 Silently ignoring the error x[:12] is a bad idea, IMO. If it meant to _extend_ x to have lenght 12, at least _that_ would be reasonable (but I'm not advocating that position). I believe that out of bounds indexes should always throw IndexError. We can't change that in Python now, but maybe we can in numpy. -1. Regardless of the merits if we had a blank slate, there is code that depends on this, specifically my code. It simplifies certain operations that would otherwise need tedious special case-handling. For example? def ichunk(arr, chunk_size=10): for i in range(0, len(arr), chunk_size): yield arr[i:i+chunk_size] -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] RFC: out of range slice indexes
Robert Kern wrote: Neal Becker wrote: I've never liked that python silently ignores slices with out of range indexes. I believe this is a source of bugs (it has been for me). It goes completely counter to the python philosophy. I vote to ban them from numpy. from numpy import array x = array (xrange (10)) x[11] Traceback (most recent call last): File stdin, line 1, in module IndexError: index out of bounds x[:12] = 2 x array([2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) len (x) 10 Silently ignoring the error x[:12] is a bad idea, IMO. If it meant to _extend_ x to have lenght 12, at least _that_ would be reasonable (but I'm not advocating that position). I believe that out of bounds indexes should always throw IndexError. We can't change that in Python now, but maybe we can in numpy. -1. Regardless of the merits if we had a blank slate, there is code that depends on this, specifically my code. It simplifies certain operations that would otherwise need tedious special case-handling. For example? ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] RFC: out of range slice indexes
On Jan 14, 2008 12:37 PM, Neal Becker [EMAIL PROTECTED] wrote: I've never liked that python silently ignores slices with out of range indexes. I believe this is a source of bugs (it has been for me). It goes completely counter to the python philosophy. I vote to ban them from numpy. from numpy import array x = array (xrange (10)) x[11] Traceback (most recent call last): File stdin, line 1, in module IndexError: index out of bounds x[:12] = 2 x array([2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) len (x) 10 Silently ignoring the error x[:12] is a bad idea, IMO. If it meant to _extend_ x to have lenght 12, at least _that_ would be reasonable (but I'm not advocating that position). I believe that out of bounds indexes should always throw IndexError. We can't change that in Python now, but maybe we can in numpy. http://projects.scipy.org/mailman/listinfo/numpy-discussion -1. Regardless of the possible merit of this on it's face, I think this is an area we should maintain compatibility with Python sequences. Not to mention that it would likely break a bunch of code, including my own. -- . __ . |-\ . . [EMAIL PROTECTED] ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion