Buffer types only allowed as function local variables

721 views
Skip to first unread message

Rekveld

unread,
Dec 28, 2009, 12:49:09 PM12/28/09
to 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

unread,
Jan 15, 2010, 5:46:38 PM1/15/10
to 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

unread,
Jan 20, 2010, 8:25:30 PM1/20/10
to 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
Reply all
Reply to author
Forward
0 new messages