I when iterating over slices in list comprehensions a quirk in the end-condition slicing can show up:
a[::] # all elements of a
a[::0] # no element of a
the code below demonstrates that issue
def test(data,coeff):
k=len(coeff)//2
Data1 = np.array([data[ :-2]*coeff[0],data[1:-1]*coeff[1],data[2: ]*coeff[2]])
Data2 = np.array([data[i :i-2*k]*coeff[i] for i in np.arange(2*k)])
# crashes for i==2k
Data3 = np.array([data[i :i-2*k]*coeff[i] for i in np.arange(2*k+1)])
if __name__ =='__main__':
data = np.array([[0,0],[1,1],[2,0],[3,1],[4,2],[5,3],[6,0]])
test(data, np.array([1,2,4]))
data = np.array([[0,0],[1,1],[2,0],[3,1],[4,2],[5,3],[6,0],[7,5]])
test(data, np.array([1,2,4]))
Question:
has the implication of interpreting 0 as positive number and thus denoting empty slices when used as the end condition been noticed when slicing was specified, resp. how and where to suggest a change of its interpretation?
As demonstrated in the code the current interpretation rules out the elegant solution to an (IMHO important) usecase