Buffer types only allowed as function local variables

721 צפיות
מעבר להודעה הראשונה שלא נקראה

Rekveld

לא נקראה,
28 בדצמ׳ 2009, 12:49:0928.12.2009
עד cython-users
Hi,

I was getting 'Buffer types only allowed as function local variables'
errors when I tried to declare my array in the class, rather than in
the method.
I found this question and reply for the same problem:
<http://codespeak.net/pipermail/cython-dev/2009-April/005214.html>

but the last workaround that was mentioned I do not understand well
enough.

Is there sombody who can write the cython code that would do the
following so that I can understand it ?
I think I understand what it means, but I don't know how to do it in
Cython.

(start quote)

I'm afraid the only solution right now is
to store it as numpy.ndarray and access the data field (i.e.
self.data.data), casted to numpy.float_t*. You must then make sure
you
work with a contiguous array:

if not data.flags['C_CONTIGUOUS']:
data = data.copy()
self.data = data

(end quote)

how do I cast self.data.data to soemthing and how do I use it as I
would use an array ?

any insights welcome,

Joost.

M. Yurko

לא נקראה,
15 בינו׳ 2010, 17:46:3815.1.2010
עד cython-users
Hello All,

I would like to second Rekveld's request. I've run into the same issue
and can't wuite understand what Dag was trying to say for his
workaround suggestion.

Thanks,
Mike

Michael Yurko

לא נקראה,
20 בינו׳ 2010, 20:25:3020.1.2010
עד cython...@googlegroups.com
I've figured out what Dag meant in his original post. I've attached a quick example in case anyone else is having the same issue.

--
Mike Yurko
cnp_tester.py
class_numpy.pyx
השב לכולם
השב למחבר
העבר לנמענים
0 הודעות חדשות