|Status:||Resolved||Start date:||16 Nov 2016|
|Target version:||Sprint 33|
The test histogram2d.py fails under certain configurations (see buildbot). On my Arch setup it fails for clang+Python3 (but passes for gcc+Python3). It is also failing in the Ubuntu Yakkety clang nightly build. The problem is caused by the swig array to std::vector automatic conversion. For some reason clang treats the swig generated code differently and the conversion fails, giving a runtime error. (Possibly due to stricter casting rules? I did a bit of investigating but the problem is not immediately clear.)
#4 Updated by pospelov over 1 year ago
- Status changed from New to Sprint
- Target version set to Sprint 33
From the discussion with Jonathan and my wage remembering, it will be enough to use
Histogram2D(vector<vector<double>> data) // instead of current Histogram2D(const vector<vector<double>> &data)
So having a copy on the way from Python-numpy array transformation.
#6 Updated by pospelov over 1 year ago
- Status changed from Sprint to Resolved
Test was fixed by requiring numpy array to be of type dtype=float64.
Also we've discovered, that there is no 'automatic-swig-way' to pass arbitrary numpy array into BornAgain, except float64 type.
The code below works for Python 2 and Python 3
// on C++ side void fun(const std::vector<double>& data) # on Python side array = numpy.array([1, 2, 3], dtype=float64) ba.fun(array)
The code below doesnt' work for both, Python2 and Python3.
// on C++ side void fun(const std::vector<int>& data) # on Python side array = numpy.array([1, 2, 3], dtype=int32) ba.fun(array)
The code below works for Python 2, but not for Python 3
// on C++ side void fun(const std::vector<double>& data) # on Python side array = numpy.array([1, 2, 3], dtype=int64) ba.fun(array)
In the future we will have to return to the subject. Typical use case: define numpy array of dtype=bool to represent detector masks, and pass it inside BornAgain.
seems having very sophisticated swig bindings