Update of /cvsroot/jython/jython/org/python/core
In directory usw-pr-cvs1:/tmp/cvs-serv11635
Modified Files:
PyArray.java
Log Message:
Support negative step slices for java array.
Index: PyArray.java
===================================================================
RCS file: /cvsroot/jython/jython/org/python/core/PyArray.java,v
retrieving revision 2.8
retrieving revision 2.9
diff -C2 -d -r2.8 -r2.9
*** PyArray.java 6 Jan 2002 21:19:13 -0000 2.8
--- PyArray.java 26 May 2002 21:00:49 -0000 2.9
***************
*** 83,91 ****
protected PyObject getslice(int start, int stop, int step) {
! if (step != 1)
! throw Py.TypeError("step != 1 not implemented yet");
! int n = stop-start;
PyArray ret = new PyArray(type, n);
! System.arraycopy(data, start, ret.data, 0, n);
return ret;
}
--- 83,100 ----
protected PyObject getslice(int start, int stop, int step) {
! if (step > 0 && stop < start)
! stop = start;
! int n = sliceLength(start, stop, step);
!
PyArray ret = new PyArray(type, n);
! if (step == 1) {
! System.arraycopy(data, start, ret.data, 0, n);
! return ret;
! }
! int j = 0;
! for (int i = start; j < n; i += step) {
! Array.set(ret.data, j, Array.get(data, i));
! j++;
! }
return ret;
}
|