Hi guys, Dag, the cython person who seems to deal with the numpy stuff, had this to say: > - cimport and import are different things; you need both. > - The "dimensions" field is in Cython renamed "shape" to be closer > to the Python interface. This is done in Cython/Includes/numpy.pxd
After including both the 'cimport' and 'import' lines, and changing 'dimensions' to 'shape', things work perfectly. And now the shoe is on the other foot -- I wonder why you guys were getting proper results with what Dag claims to be buggy code! Odd indeed. Zach On Mar 1, 2009, at 2:36 PM, Nadav Horesh wrote: > 1. "dimensions" is a field in the C struct, that describes the array > object. > 2. Is there a chance that the header file numpy/arrayobject.h > belongs to a > different numpy version that you run? > > I am not very experienced with cython (I suppose that Stefan has > some experience). > As you said, probably the cython list is a better place to look for > an answer. I would be happy to see how this issue resolved. > > Nadav > > > > -----הודעה מקורית----- > מאת: numpy-discussion-boun...@scipy.org בשם Zachary Pincus > נשלח: א 01-מרץ-09 20:59 > אל: Discussion of Numerical Python > נושא: Re: [Numpy-discussion] Bilateral filter > >>> Well, the latest cython doesn't help -- both errors still appear as >>> below. (Also, the latest cython can't run the numpy tests either.) >>> I'm >>> befuddled. >> >> That's pretty weird. Did you remove the .so that was build as well >> as >> any source files, before doing build_ext with the latest Cython? >> Also >> good to make sure that the latest Cython is, in fact, the one being >> used. > > Yeah... and I just tried that again, with the same results. I have no > idea what could be going wrong. E.g. why would 'cimport numpy as np' > not add np to the namespace on my machine whereas it does so on > yours... > > Also, I assume that constructs like: > cdef int i, dim = data.dimensions[0] > are some special numpy-support syntax that's supposed to be added by > the cimport numpy line? (Because numpy arrays don't expose a > 'dimensions' attribute to python code...) It's like for some reason on > my machine, cython isn't building its numpy support correctly. Which > is understandable in the light of the fact that cython can't pass the > numpy tests on my machine either. Odd indeed. Maybe I'll try on the > cython list, since you guys seem to have demonstrated that the problem > isn't in the bilateral code! > > Zach > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion@scipy.org > http://projects.scipy.org/mailman/listinfo/numpy-discussion > > <winmail.dat>_______________________________________________ > Numpy-discussion mailing list > Numpy-discussion@scipy.org > http://projects.scipy.org/mailman/listinfo/numpy-discussion _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion