Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ before_install:
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
export CXX=clang++ CC=clang PYTHONHOME=$HOME/miniconda;
fi
- PYBIND11_VERSION=${PYBIND11_VERSION:-2.2.1}

install:
# Define the version of miniconda to download
Expand All @@ -126,8 +127,26 @@ install:
- conda update -q conda
# Useful for debugging any issues with conda
- conda info -a
- conda install pytest numpy pybind11==2.2.1 -c conda-forge
- conda install pytest numpy -c conda-forge
- conda install cmake gtest -c conda-forge
- |
if [[ "$PYBIND11_VERSION" == "master" ]]; then
conda_root=$(cd $(dirname $(which conda))/.. && pwd)
mkdir -p $conda_root/tmp
cd $conda_root/tmp
curl -sSL -o pybind11.tar.gz https://github.com/pybind/pybind11/archive/master.tar.gz
rm -rf pybind11-master
tar xf pybind11.tar.gz
cd pybind11-master
python setup.py install
mkdir -p build
cd build
cmake -DPYBIND11_TEST=OFF -DPYTHON_EXECUTABLE:FILEPATH=`which python` -DCMAKE_INSTALL_PREFIX=${conda_root} ..
make install
cd $TRAVIS_BUILD_DIR
else
conda install pybind11==${PYBIND11_VERSION} -c conda-forge
fi
- conda install xtensor==0.17.3 -c QuantStack
- cmake -D BUILD_TESTS=ON -D CMAKE_INSTALL_PREFIX=$HOME/miniconda -D PYTHON_EXECUTABLE=$PY_EXE .
- make -j2 test_xtensor_python
Expand Down
6 changes: 6 additions & 0 deletions include/xtensor-python/pyarray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace pybind11
{
namespace detail
{
#ifdef PYBIND11_DESCR // The macro is removed from pybind11 since 2.3
template <class T, xt::layout_type L>
struct handle_type_name<xt::pyarray<T, L>>
{
Expand All @@ -39,6 +40,7 @@ namespace pybind11
return _("numpy.ndarray[") + npy_format_descriptor<T>::name() + _("]");
}
};
#endif

template <typename T, xt::layout_type L>
struct pyobject_caster<xt::pyarray<T, L>>
Expand All @@ -63,7 +65,11 @@ namespace pybind11
return src.inc_ref();
}

#ifdef PYBIND11_DESCR // The macro is removed from pybind11 since 2.3
PYBIND11_TYPE_CASTER(type, handle_type_name<type>::name());
#else
PYBIND11_TYPE_CASTER(type, _("numpy.ndarray[") + npy_format_descriptor<T>::name + _("]"));
#endif
};

// Type caster for casting ndarray to xexpression<pyarray>
Expand Down
6 changes: 6 additions & 0 deletions include/xtensor-python/pytensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace pybind11
{
namespace detail
{
#ifdef PYBIND11_DESCR // The macro is removed from pybind11 since 2.3
template <class T, std::size_t N, xt::layout_type L>
struct handle_type_name<xt::pytensor<T, N, L>>
{
Expand All @@ -40,6 +41,7 @@ namespace pybind11
return _("numpy.ndarray[") + npy_format_descriptor<T>::name() + _("]");
}
};
#endif

template <class T, std::size_t N, xt::layout_type L>
struct pyobject_caster<xt::pytensor<T, N, L>>
Expand All @@ -65,7 +67,11 @@ namespace pybind11
return src.inc_ref();
}

#ifdef PYBIND11_DESCR // The macro is removed from pybind11 since 2.3
PYBIND11_TYPE_CASTER(type, handle_type_name<type>::name());
#else
PYBIND11_TYPE_CASTER(type, _("numpy.ndarray[") + npy_format_descriptor<T>::name + _("]"));
#endif
};

// Type caster for casting ndarray to xexpression<pytensor>
Expand Down
2 changes: 2 additions & 0 deletions include/xtensor-python/xtensor_type_caster_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ namespace pybind11
return cast_impl(src, policy, parent);
}

#ifdef PYBIND11_DESCR // The macro is removed from pybind11 since 2.3
static PYBIND11_DESCR name()
{
return _("xt::xtensor");
}
#endif

template <typename T>
using cast_op_type = cast_op_type<T>;
Expand Down