[Numpy-discussion] recarrays and lists of lists
Sun Sep 11 02:58:20 CDT 2011
On Sun, Sep 11, 2011 at 00:30, Travis Vaught <firstname.lastname@example.org> wrote:
> Is there a particular reason why a list of lists can't be passed in to create a recarray given a particular dtype?
> A list of tuples works fine. I keep getting bitten by this and was thinking it should be an easy check/convert for an allowance for a row to be a list _or_ a tuple?
As a rule, tuples are considered "scalar" records and lists are
recursed upon. This rule helps numpy.array() figure out which
sequences are records and which are other sequences to be recursed
upon; i.e. which sequences create another dimension and which are the
atomic elements. Otherwise, it has to make some guesses and do some
intelligent backtracking. It's not that intelligent.
"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