multidimensional array of objects in scipy core

S

Stormslayer

Folks: How do you create a multidimesional array of objects w/ the size
of the array entered at runtime? So basically, for an arbitrary class,
create an array and then *.resize it to be of size NXM, and then
populate the elements of the objects.

thanks for any help.
Scott
 
R

Robert Kern

Stormslayer said:
Folks: How do you create a multidimesional array of objects w/ the size
of the array entered at runtime? So basically, for an arbitrary class,
create an array and then *.resize it to be of size NXM, and then
populate the elements of the objects.

First, asking on the scipy mailing list will get you a better response.

Second, scipy_core does allow arrays of arbitrary Python objects, but
it doesn't do any kind of type-checking for those arrays. It is up to
you to populate the array with the kind of objects that you want.

arr = empty((N, M), object)
arr[i, j] = MyClass(i, j)

should work (can't check at the moment, though).

Please note that object arrays have always been tricky since Numeric,
so if you encounter strange behaviour, we would appreciate a report on
the scipy mailing list.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top