samehkhamis/pylibdai — pull request #1 by sebastien-bratieres (2014-08-08 11:40:44+00:00)
Title: support Python 2.7 and 3.3

now works with both :-) as shown below on my system

(py33)sb358@fermat:~/git/pylibdai$ python setup.py install
running install
running build
running build_ext
skipping 'dai.cpp' Cython extension (up-to-date)
building 'dai' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/sb358/exp-nlpfast/external/libDAI-0.3.1/include -I/home/sb358/anaconda/envs/py33/include/python3.3m -c dai.cpp -o build/temp.linux-x86_64-3.3/dai.o
cc1plus: warning: command line option â-Wstrict-prototypesâ is valid for Ada/C/ObjC but not for C++ [enabled by default]
dai.cpp: In function âPyObject* __pyx_f_3dai_factors_cpp2py(std::vector >, __pyx_opt_args_3dai_factors_cpp2py*)â:
dai.cpp:1913:59: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
creating build/lib.linux-x86_64-3.3
g++ -pthread -shared build/temp.linux-x86_64-3.3/dai.o -L/home/sb358/exp-nlpfast/external/libDAI-0.3.1/lib -L/home/sb358/anaconda/envs/py33/lib -ldai -lgmp -lgmpxx -lpython3.3m -o build/lib.linux-x86_64-3.3/dai.cpython-33m.so
running install_lib
copying build/lib.linux-x86_64-3.3/dai.cpython-33m.so -> /home/sb358/anaconda/envs/py33/lib/python3.3/site-packages
running install_egg_info
Removing /home/sb358/anaconda/envs/py33/lib/python3.3/site-packages/UNKNOWN-0.0.0-py3.3.egg-info
Writing /home/sb358/anaconda/envs/py33/lib/python3.3/site-packages/UNKNOWN-0.0.0-py3.3.egg-info
(py33)sb358@fermat:~/git/pylibdai$ python test.py
LogZ = -1.6296

All beliefs:
Member: [0]
Prob: [ 0.69387755 0.30612245]
Member: [1]
Prob: [ 0.30612245 0.69387755]
Member: [0]
Prob: [ 0.69387755 0.30612245]
Member: [1]
Prob: [ 0.30612245 0.69387755]
Member: [0 1]
Prob: [[ 0.12244898 0.57142857]
[ 0.18367347 0.12244898]]

MaxDiff = 0.0000

Variable beliefs:
Member: [0]
Prob: [ 0.69387755 0.30612245]
Member: [1]
Prob: [ 0.30612245 0.69387755]

Factor beliefs:
Member: [0]
Prob: [ 0.69387755 0.30612245]
Member: [1]
Prob: [ 0.30612245 0.69387755]
Member: [0 1]
Prob: [[ 0.12244898 0.57142857]
[ 0.18367347 0.12244898]]

Map state = [ 0. 1.]

(py33)sb358@fermat:~/git/pylibdai$ source activate ~/anaconda/
bin/ docs/ Examples/ lib/ plugins/
conda-meta/ envs/ include/ LICENSE.txt share/
.conda-try-writemh1FfF etc/ .index/ pkgs/ var/
(py33)sb358@fermat:~/git/pylibdai$ source activate ~/anaconda/
discarding /home/sb358/anaconda/envs/py33/bin from PATH
prepending /home/sb358/anaconda/bin to PATH
(/home/sb358/anaconda)sb358@fermat:~/git/pylibdai$ python setup.py install
running install
running build
running build_ext
skipping 'dai.cpp' Cython extension (up-to-date)
building 'dai' extension
creating build/temp.linux-x86_64-2.7
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/sb358/exp-nlpfast/external/libDAI-0.3.1/include -I/home/sb358/anaconda/include/python2.7 -c dai.cpp -o build/temp.linux-x86_64-2.7/dai.o
cc1plus: warning: command line option â-Wstrict-prototypesâ is valid for Ada/C/ObjC but not for C++ [enabled by default]
dai.cpp: In function âPyObject* __pyx_f_3dai_factors_cpp2py(std::vector >, __pyx_opt_args_3dai_factors_cpp2py*)â:
dai.cpp:1913:59: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
creating build/lib.linux-x86_64-2.7
g++ -pthread -shared build/temp.linux-x86_64-2.7/dai.o -L/home/sb358/exp-nlpfast/external/libDAI-0.3.1/lib -L/home/sb358/anaconda/lib -ldai -lgmp -lgmpxx -lpython2.7 -o build/lib.linux-x86_64-2.7/dai.so
running install_lib
copying build/lib.linux-x86_64-2.7/dai.so -> /home/sb358/anaconda/lib/python2.7/site-packages
running install_egg_info
Removing /home/sb358/anaconda/lib/python2.7/site-packages/UNKNOWN-0.0.0-py2.7.egg-info
Writing /home/sb358/anaconda/lib/python2.7/site-packages/UNKNOWN-0.0.0-py2.7.egg-info
(/home/sb358/anaconda)sb358@fermat:~/git/pylibdai$ python test.py
LogZ = -1.6296
()
All beliefs:
Member: [0]
Prob: [ 0.69387755 0.30612245]
Member: [1]
Prob: [ 0.30612245 0.69387755]
Member: [0]
Prob: [ 0.69387755 0.30612245]
Member: [1]
Prob: [ 0.30612245 0.69387755]
Member: [0 1]
Prob: [[ 0.12244898 0.57142857]
[ 0.18367347 0.12244898]]
()
MaxDiff = 0.0000
()
Variable beliefs:
Member: [0]
Prob: [ 0.69387755 0.30612245]
Member: [1]
Prob: [ 0.30612245 0.69387755]
()
Factor beliefs:
Member: [0]
Prob: [ 0.69387755 0.30612245]
Member: [1]
Prob: [ 0.30612245 0.69387755]
Member: [0 1]
Prob: [[ 0.12244898 0.57142857]
[ 0.18367347 0.12244898]]
()
Map state = [ 0. 1.]
()