Hi Travis, Travis Oliphant wrote: > Ryan Gutenkunst wrote: >> I notice that numpy_array.item() will give me the first element as a >> normal scalar. Would it be possible for numpy_array.item(N) to return >> the Nth element of the array as a normal scalar? >> > Now this is an interesting idea. It would allow you to by-pass the > slow-indexing as well as the array scalar computation should you desire > it. I like it and am going to add it unless there are convincing > objections. > > -Travis
Thanks for the quick response, but either there's a bug, or I'm using things wrong. It appears to work to work in the N-D case, but not 1-D. I looked at the change you made, but my grasp of the C-API is too weak to isolate the problem. >>> import numpy >>> numpy.__version__ '1.0rc1.dev3154' >>> a = numpy.array([[1.0, 2.0], [3.0, 4.0]]) >>> a.item(1,1) 4.0 >>> a = numpy.array([1.0, 2.0]) >>> a.item(0) 1.0 >>> a.item(1) 1.7765824089018436e-307 >>> a.item((1,)) 1.7765824089018436e-307 Thanks for your help, Ryan -- Ryan Gutenkunst | Cornell LASSP | "It is not the mountain | we conquer but ourselves." Clark 535 / (607)227-7914 | -- Sir Edmund Hillary AIM: JepettoRNG | http://www.physics.cornell.edu/~rgutenkunst/ ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion