[Numpy-discussion] Functions for indexing into certain parts of an array (2d)
Sat Jun 6 16:01:31 CDT 2009
On Sat, Jun 6, 2009 at 13:30, Fernando Perez <firstname.lastname@example.org> wrote:
> On Sat, Jun 6, 2009 at 12:09 AM, Robert Kern<email@example.com> wrote:
> OK, thanks. I'll try to get it ready.
>> diag_indices() can be made more efficient, but these are fine.
> Suggestion? Right now it's not obvious to me...
Oops! Never mind. I thought it was using mask_indices like the others.
There is a neat trick for accessing the diagonal of an existing array
(a.flat[::a.shape+1]), but it won't work to implement
> A few more questions:
> - Are doctests considered enough testing for numpy, or are separate
> tests also required?
I don't think we have the testing machinery hooked up to test the
docstrings on the functions themselves (we made the decision to keep
examples as clean and pedagogical as possible rather than complete
tests). You can use doctests in the test directories, though.
> - Where should these go?
numpy/lib/twodim_base.py to go with their existing counterparts, I would think.
> - Any interest in also having the stuff below? I'm needing to build
> structured random arrays a lot (symmetric, anti-symmetric, symmetric
> with a particular diagonal, etc), and these are coming in handy. If
> you want them, I'll put the whole thing together (these use the
> indexing utilities from the previous suggestion).
I wouldn't mind having a little gallery of matrix generators in numpy,
but someone else has already made a much more complete collection:
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion