[SciPy-user] problem referencing single element arrays
Alan Jackson
alan at ajackson.org
Wed Apr 30 23:03:41 EDT 2008
On Wed, 30 Apr 2008 21:39:53 -0500
"Robert Kern" <robert.kern at gmail.com> wrote:
> On Wed, Apr 30, 2008 at 9:11 PM, Alan Jackson <alan at ajackson.org> wrote:
> > Having a problem with numpy that has me stumped.
> >
> > I have a large set of arrays. I want to set up cross reference lists of
> > elements within those arrays, with the lists just being pointers to the objects
> > (floating point numbers) stored in the arrays.
> >
> > The problem is that some arrays have only a single element, so when I try to
> > store a[0] for a single element array, I get an error, "0-d arrays can't be
> > indexed". How do I get a pointer to the object stored and not the array for
> > single element arrays?
>
> a[()]
>
> > Or maybe I don't want to be doing this?
>
> Quite possibly. Can you expand on your use case?
>
Imagine a 3D coordinate system. I have connected, non-recumbent sheets
of various sizes in this 3D space. I set up a dictionary of arrays where
a set of 3 arrays contains the X, Y, Z-values of the points on a sheet,
the dictionary so I can name each sheet.
I'd also like to access the data points vertically, at a particular X,Y
what are all the sheets and points? That's the purpose of my cross reference.
It's actually a bit more complicated than this - I have multiple attributes
attached to each point on each sheet, as well as sheet-level attributes.
I did this in perl a few years ago - I think it will be much better with
numpy.
I like that bit of magic you showed.
--
-----------------------------------------------------------------------
| Alan K. Jackson | To see a World in a Grain of Sand |
| alan at ajackson.org | And a Heaven in a Wild Flower, |
| www.ajackson.org | Hold Infinity in the palm of your hand |
| Houston, Texas | And Eternity in an hour. - Blake |
-----------------------------------------------------------------------
More information about the SciPy-User
mailing list