Discussion:
[Pyublas] did not match C++ signature for pyublas::numpy_vector<float>
Jeff Mast
2011-02-14 16:43:22 UTC
Permalink
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
Andreas Kloeckner
2011-02-14 17:05:53 UTC
Permalink
Hi Jeff,
Post by Jeff Mast
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.
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)
#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);
}
Sample.py passed numpy.float values, which correspond to double in
C++. To make this work, you need to pass float32. I've thought about
allowing copy+conversion in PyUblas by some means, but for now PyUblas
only allows you to do the efficient thing.

HTH,
Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.tiker.net/pipermail/pyublas/attachments/20110214/131c4319/attachment.pgp>
Neal Becker
2011-02-14 17:53:09 UTC
Permalink
Post by Andreas Kloeckner
Hi Jeff,
Post by Jeff Mast
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.
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)
#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);
}
Sample.py passed numpy.float values, which correspond to double in
C++. To make this work, you need to pass float32. I've thought about
allowing copy+conversion in PyUblas by some means, but for now PyUblas
only allows you to do the efficient thing.
HTH,
Andreas
explicit is better than implicit. I don't want silent conversions.
Andreas Kloeckner
2011-02-14 18:38:10 UTC
Permalink
Post by Neal Becker
explicit is better than implicit. I don't want silent conversions.
Of course--it'd be something like pyublas::conversion_ok< stuff >.

Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.tiker.net/pipermail/pyublas/attachments/20110214/069e6784/attachment.pgp>
Loading...