Flattening lists

Rhamphoryncus rhamph at gmail.com
Sun Feb 8 18:05:31 EST 2009


On Feb 7, 3:07 pm, <mma... at gmx.net> wrote:
> On Sat, 7 Feb 2009 12:50:22 -0800 (PST)
> Rhamphoryncus <rha... at gmail.com> wrote:
> > Can you explain this in a little more detail?
>
> In the application, there is one main numpy array of type "O".
> Each element of the array corresponds to one cell in a grid. The user
> may enter a Python expression into the grid cell. The input is
> evaled and the result is stored in the numpy array (the actual process
> is a bit more complicated). Therefore, the object inside a numpy array
> element may be an inconsistent, nested, iterable type.
>
> The user now may access the result grid via __getitem__. When doing
> this, a numpy array that is as flat as possible while comprising the
> maximum possible data depth is returned, i.e.:
>
> 1. Non-string and non-unicode iterables of similar length for each of
> the cells form extra dimensions.
>
> 2. In order to remove different container types, the result is
> flattened, cast into a numpy.array and re-shaped.
>
> 3. Dimensions of length 1 are eliminated.
>
> Therefore, the user can conveniently use numpy ufuncs on the results.
>
> I am referring to the flatten operation in step 2

I'm afraid I still don't understand it, but I'm only minimally
familiar with numpy, nevermind your spreadsheet app.



More information about the Python-list mailing list