Guest User

Untitled

a guest
Aug 20th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. C , Python, Incompatible Types of Numbers
  2. class_<std::vector<double> >("PyVecDouble")
  3. .def(vector_indexing_suite<std::vector<double> >());
  4.  
  5. class_<std::vector<long> >("PyVecLong")
  6. .def(vector_indexing_suite<std::vector<long> >());
  7.  
  8. def NumpyArrayToPyVecDouble(vec):
  9. n = len(vec)
  10. p_vec = jp.PyVecDouble()
  11.  
  12. for i in xrange(0,n):
  13. p_vec.append(vec[i])
  14.  
  15. return p_vec
  16.  
  17. def NumpyArrayToPyVecLong(vec):
  18. n = len(vec)
  19. p_vec = jp.PyVecLong()
  20.  
  21. for i in xrange(0,n):
  22. p_vec.append(vec[i])
  23.  
  24. return p_vec
  25.  
  26. example_array = np.array([1.1, 2.2, 3.3, 4.4])
  27. example = NumpyArrayToPyVecDouble(double_array)
  28.  
  29. dates_array = np.array([01122011, 01062012, 01122012, 01062013])
  30. dates = NumpyArrayToPyVecLong(dates_array)
  31.  
  32. TypeError: Attempting to append an invalid type
Add Comment
Please, Sign In to add comment