Reputation: 1044
I have a function I'd like to abstract into an importable module:
cdef list generate_random_vectors(int num_vectors, int length, float scale=1):
cdef list return_list
np.random.seed()
return_list = []
for n in range(num_vectors):
return_list.append((1 - 2 * np.random.rand(length)) / scale)
return return_list
To put this in a module, I have to define it in the pxd file.
When I try this:
cdef list generate_random_vectors(int num_vectors, int length, float scale)
I get the error: Function signature does not match previous declaration.
When I try this:
cdef list generate_random_vectors(int num_vectors, int length, float scale=1)
I get the error: Expected ')', found 'INT'
Upvotes: 3
Views: 1685
Reputation: 1044
Found it. The syntax is different in pxd files.
I need to use:
cdef list generate_random_vectors(int num_vectors, int length, float scale=*)
Upvotes: 6