[Numpy-discussion] List with numpy semantics

Nikolaus Rath Nikolaus at rath.org
Tue Nov 2 22:02:17 EDT 2010


Gerrit Holl <gerrit.holl at gmail.com> writes:
> On 31 October 2010 17:10, Nikolaus Rath <Nikolaus at rath.org> wrote:
>> Hello,
>>
>> I have a couple of numpy arrays which belong together. Unfortunately
>> they have different dimensions, so I can't bundle them into a higher
>> dimensional array.
>>
>> My solution was to put them into a Python list instead. But
>> unfortunately this makes it impossible to use any ufuncs.
>>
>> Has someone else encountered a similar problem and found a nice
>> solution? Something like a numpy list maybe?
>
> You could try a record array with a clever dtype, maybe?

It seems that this requires more cleverness than I have... Could you
give me an example? How do I replace l in the following code with a
record array?

l = list()
l.append(np.arange(3))
l.append(np.arange(42))
l.append(np.arange(9))

for i in range(len(l)):
   l[i] += 32

   
Thanks,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C



More information about the NumPy-Discussion mailing list