[Numpy-discussion] Deleting a row from a matrix
Bill Baxter
wbaxter at gmail.com
Sat Aug 26 08:13:15 EDT 2006
On 8/26/06, Travis Oliphant <oliphant.travis at ieee.org> wrote:
>
>
> I've come up with adding the functions (not methods at this point)
>
> deletefrom
> insertinto
"delete" and "insert" really would be better. The current "insert"
function seems inaptly named. What it does sounds more like "overlay" or
"set_masked".
... or the existing "putmask" which I see does a similar thing.
Actually there seems to be a little doc-bug there or something.
numpy.insert claims it differs from putmask in that it only accepts a vector
of values with same number of vals as the # of non-zero entries in the mask,
but a quick test revals it's quite happy with a different number and cycles
through them.
In [31]: a = numpy.zeros((3,3))
In [32]: numpy.insert(a, [[0,1,0],[1,0,0],[1,0,0]], [4,5])
In [33]: a
Out[33]:
array([[ 0., 4., 0.],
[ 5., 0., 0.],
[ 4., 0., 0.]])
Anyway, in the end nothing has really been inserted, existing entries have
just been replaced.
So "insert" seems like a much better name for a function that actually puts
in a new row or column.
--bb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20060826/d1a99761/attachment.html>
More information about the NumPy-Discussion
mailing list