On Friday 25 August 2006 16:16, Travis Oliphant wrote: > Sebastian Haase wrote: > > On Friday 25 August 2006 08:01, Travis Oliphant wrote: > >> Travis Oliphant wrote: > >>>> Now of course: I often needed to "insert" a column, row or section, > >>>> ... ? I made a quick and dirty implementation for that myself: > >>>> def insert(arr, i, entry, axis=0): > >>>> """returns new array with new element inserted at index i along > >>>> axis if arr.ndim>1 and if entry is scalar it gets filled in (ref. > >>>> broadcasting) > >>>> > >>>> note: (original) arr does not get affected > >>>> """ > >>>> if i > arr.shape[axis]: > >>>> raise IndexError, "index i larger than arr size" > >>>> shape = list(arr.shape) > >>>> shape[axis] += 1 > >>>> a= N.empty(dtype=arr.dtype, shape=shape) > >>>> aa=N.transpose(a, [axis]+range(axis)+range(axis+1,a.ndim)) > >>>> aarr=N.transpose(arr, [axis]+range(axis)+range(axis+1,arr.ndim)) > >>>> aa[:i] = aarr[:i] > >>>> aa[i+1:] = aarr[i:] > >>>> aa[i] = entry > >>>> return a > >>> > >>> Sure, it makes sense to parallel the delete function. > >> > >> Although there is already and insert function present in numpy.... > >> > >> -Travis > > > > Yeah - I saw that ... > > maybe one could introduce consistent namings like > > arr.copy_insert() > > arr.copy_delete() > > arr.copy_append() > > I've come up with adding the functions (not methods at this point) > > deletefrom > insertinto > > appendto (syntatic sugar for concatenate but with a separate argument > for the array and the extra stuff) --- is this needed?
not for me. -S. ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion