xtensor-stack / xtensor-python

Python bindings for xtensor
BSD 3-Clause "New" or "Revised" License
347 stars 58 forks source link

Documentation test and benchmark #204

Closed zhujun98 closed 4 years ago

zhujun98 commented 5 years ago

Could we add some documentation about test and benchmark similar to what's in the readthedocs of xtensor.

I run xtensor-python in anaconda and I post my terminal input and the problems I encountered here:

Build the c++ test suite of xtensor-python:

cd test
mkdir build
cd build
cmake -DBUILD_TESTS=ON -DDOWNLOAD_GTEST=ON ../
# maybe needed to find the correct Python lib in an anaconda environment
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/anaconda/env/name/lib
make xtest

Build the Python test suite of xtensor-python:

cd test_python
# python setup.py build_ext --inplace
pytest .

Build the benchmark suite of xtensor-python:

I cannot run make xbenchmark because of the following error

../xtensor-python/benchmark/main.cpp:1:31: fatal error: pybind11/pybind11.h: No such file or directory
 #include "pybind11/pybind11.h"

Instead, I tried

cd benchmark
python setup.py build_ext --inplace
pytest .

and got

main.cpp: In function ‘void pybind11_init_benchmark_xtensor_python(pybind11::module&)’:
main.cpp:20:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
         return nullptr;

I simply removed the following lines in main.cpp and I could run the above commands:

    if(_import_array() < 0)
    {
        PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
        return nullptr;
    }

However, I got segfault when I ran

python benchmark_pyarray.py
python benchmark_pytensor.py
benchmark_pyvectorize.py

The rest two are fine.