Howdy,
Is there any nicer syntax for the following operations on arrays?

Append a row:
a = vstack((a,row))

Append a column:
a = hstack((a,col))

Append a row of zeros:
a = vstack((a,zeros((1,a.shape[1]))))

Append a col of zeros:
a = hstack((a,zeros((a.shape[0],1))))

Insert a row before row j
a = vstack(( a[:j], row, a[j:] ))

Insert a column before col j
a = hstack(( a[:j], col, a[j:] ))

Insert a row of zeros before row j
a = vstack(( a[:j], zeros((1,a.shape[1])), a[j:] ))

Insert a column of zeros before col j
a = hstack(( a[:j], zeros((a.shape[0],1)), a[j:] ))

Delete row j:
a = vstack(( a[:j], a[j+1:] ))

Delete col j:
a = hstack(( a[:j], a[j+1:] ))

...And in more general the same types of operations for N-d arrays.

I find myself using python lists of lists a lot just for the easy
readability of a.append(row) compared to a = vstack((a,row)).

I guess, though, if I'm building an array by appending a row at a
time, then maybe it *is* better to use a python list o list for that?
Then each 'append' only copies pointers of the existing rows rather
than copying the data in each row.  Is that correct?  Also do python
lists over-allocate in order to avoid having to re-allocate and copy
every time there's an append()?  Numpy arrays don't over-allocate I
assume.

Thanks,
--bb

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to