Jeff Mast
2011-02-14 16:43:22 UTC
I am having trouble using float arrays with pyublas and am getting "did
not match C++ signature" at runtime when I change
pyublas::numpy_vector<double> to pyublas::numpy_vector<float>
Seems like this should just work, but I have no idea what is going wrong.
Compile line:
gcc -I/usr/include/python2.6 -fPIC -g -fpic -shared
-Wl,-soname,sample_ext.so sample_ext.cpp -lboost_python-mt-py26
-lpython2.6 -o sample_ext.so
pyublas from tip of git repository
(46d422f55d4a38282d8eecfb3c59e6ac13712f6e)
ubuntu 10.10
gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
boost 4.2
python2.6
ldd sample_ext.so
linux-vdso.so.1 => (0x00007fffa15ff000)
libboost_python-py26.so.1.42.0 =>
/usr/lib/libboost_python-py26.so.1.42.0 (0x00007fd062879000)
libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0
(0x00007fd0623ca000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007fd0621b3000)
libc.so.6 => /lib/libc.so.6 (0x00007fd061e30000)
libutil.so.1 => /lib/libutil.so.1 (0x00007fd061c2d000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007fd061a0f000)
libdl.so.2 => /lib/libdl.so.2 (0x00007fd06180b000)
librt.so.1 => /lib/librt.so.1 (0x00007fd061603000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fd0612fc000)
libm.so.6 => /lib/libm.so.6 (0x00007fd061079000)
libssl.so.0.9.8 => /lib/libssl.so.0.9.8 (0x00007fd060e27000)
libcrypto.so.0.9.8 => /lib/libcrypto.so.0.9.8 (0x00007fd060a9a000)
libz.so.1 => /lib/libz.so.1 (0x00007fd060882000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd062d0a000)
modified sample_ext.cpp:
#include <pyublas/numpy.hpp>
pyublas::numpy_vector<float> doublify(pyublas::numpy_vector<float> x)
{
return 2*x;
}
BOOST_PYTHON_MODULE(sample_ext)
{
boost::python::def("doublify", doublify);
}
output from running sample.py:
[ 1. 1. 1. 1. 1.]
Traceback (most recent call last):
File "sample.py", line 7, in <module>
print sample_ext.doublify(vec)
Boost.Python.ArgumentError: Python argument types in
sample_ext.doublify(numpy.ndarray)
did not match C++ signature:
doublify(pyublas::numpy_vector<float>)
Thanks,
-- Jeff
not match C++ signature" at runtime when I change
pyublas::numpy_vector<double> to pyublas::numpy_vector<float>
Seems like this should just work, but I have no idea what is going wrong.
Compile line:
gcc -I/usr/include/python2.6 -fPIC -g -fpic -shared
-Wl,-soname,sample_ext.so sample_ext.cpp -lboost_python-mt-py26
-lpython2.6 -o sample_ext.so
pyublas from tip of git repository
(46d422f55d4a38282d8eecfb3c59e6ac13712f6e)
ubuntu 10.10
gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
boost 4.2
python2.6
ldd sample_ext.so
linux-vdso.so.1 => (0x00007fffa15ff000)
libboost_python-py26.so.1.42.0 =>
/usr/lib/libboost_python-py26.so.1.42.0 (0x00007fd062879000)
libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0
(0x00007fd0623ca000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007fd0621b3000)
libc.so.6 => /lib/libc.so.6 (0x00007fd061e30000)
libutil.so.1 => /lib/libutil.so.1 (0x00007fd061c2d000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007fd061a0f000)
libdl.so.2 => /lib/libdl.so.2 (0x00007fd06180b000)
librt.so.1 => /lib/librt.so.1 (0x00007fd061603000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fd0612fc000)
libm.so.6 => /lib/libm.so.6 (0x00007fd061079000)
libssl.so.0.9.8 => /lib/libssl.so.0.9.8 (0x00007fd060e27000)
libcrypto.so.0.9.8 => /lib/libcrypto.so.0.9.8 (0x00007fd060a9a000)
libz.so.1 => /lib/libz.so.1 (0x00007fd060882000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd062d0a000)
modified sample_ext.cpp:
#include <pyublas/numpy.hpp>
pyublas::numpy_vector<float> doublify(pyublas::numpy_vector<float> x)
{
return 2*x;
}
BOOST_PYTHON_MODULE(sample_ext)
{
boost::python::def("doublify", doublify);
}
output from running sample.py:
[ 1. 1. 1. 1. 1.]
Traceback (most recent call last):
File "sample.py", line 7, in <module>
print sample_ext.doublify(vec)
Boost.Python.ArgumentError: Python argument types in
sample_ext.doublify(numpy.ndarray)
did not match C++ signature:
doublify(pyublas::numpy_vector<float>)
Thanks,
-- Jeff