I'm trying to get a simple example working pointing at a couple of integers atm but will eventually be std::vector
--
---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
If you don't mind I have a few clarification questions.
What is the role of the Pyd file? I've built simple examples before, such as this https://gist.github.com/CyclingNinja/9e8477277d14272785371324c8ab9a38 where I've had issues getting it working till I put the contents of the Pyd file into the top of the pyx file.
Also, I've not seen the my.pybld file before, is it just a straight swap for setup.py or is it more robust?
Also, also, is defining a vector as simple as `aname(x, y)` and is all the pratting around with std::vector not needed?
I presume i can use __callcoc__ to pass out a calculated vector?
Hope that makes sense and isn't just garbled nonsense.Which I think is complaining about the initialiser brackets and allocated space. I suspect I need to define the length of the vector first however I'm not sure how to do that with the bracing notation. Or what the notation is called so I can find the docs.However I'm getting an error of.pyxI'll looking to read out several separate vectors. I'm currently working with and adapting your code. At the moment, I'm trying to initialise vectors of length 1 and then expand them like thisThanks man, that’s all really good.As for the vector clarification.
cdef class PyStruct:
cdef OutVectors *thisptr # hold a c++ instance of the structure
def __cinit__(self, vector[double] A={1.0}, vector[double] B={1.0}):
self.thisptr = new OutVectors(A, B)
def __dealloc__(self):
del self.thisptr
def RetVals(self):
s = PySquare()
for i in range(10):
print(i)
self.thisptr.A.push_back(i)
self.thisptr.B.push_back(s.get_sqr(i))
return self.thisptr.A, self.thisptr.BPySquare is a class of methods which I built up learning the basics of Cython, in this case get_sqr(x) returns x squared (shockingly enough)and the .h
#include <vector>
namespace ops {
struct OutVectors {
std::vector<double> A, B;
OutVectors(std::vector<double> A_={1.0}, std::vector<double> B_={1.0}) : A(A_), B(B_) {}
};
error: converting to ‘std::vector<double>’ from initializer list would use explicit constructor ‘std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const value_type&, const allocator_type&) [with _Tp = double; _Alloc = std::allocator<double>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = double; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<double>]’
squaremod.h:11:71: warning: narrowing conversion of ‘1.0e+0’ from ‘double’ to ‘std::vector<double>::size_type {aka long unsigned int}’ inside { } is ill-formed in C++11 [-Wnarrowing]
I'll looking to read out several separate vectors. I'm currently working with and adapting your code. At the moment, I'm trying to initialise vectors of length 1 and then expand them like thisThanks man, that’s all really good.As for the vector clarification.
--
powers_wrapper.pyx:45:40: Cannot convert 'OutVectors' to Python object