Skip to content

Commit af1c1d0

Browse files
committed
Switched to xtensor 0.10.0
1 parent 7365275 commit af1c1d0

File tree

8 files changed

+20
-15
lines changed

8 files changed

+20
-15
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ install:
2323
- conda update -q conda
2424
- conda info -a
2525
- conda install gtest cmake -c conda-forge
26-
- conda install xtensor==0.9.0 pytest numpy pybind11==2.1.1 -c conda-forge
26+
- conda install xtensor==0.10.0 pytest numpy pybind11==2.1.1 -c conda-forge
2727
- "set PYTHONHOME=%MINICONDA%"
2828
- cmake -G "NMake Makefiles" -D CMAKE_INSTALL_PREFIX=%MINICONDA%\\Library -D BUILD_TESTS=ON -D PYTHON_EXECUTABLE=%MINICONDA%\\python.exe .
2929
- nmake test_xtensor_python

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ install:
9494
- conda update -q conda
9595
# Useful for debugging any issues with conda
9696
- conda info -a
97-
- conda install xtensor==0.9.0 pytest numpy pybind11==2.1.1 -c conda-forge
97+
- conda install xtensor==0.10.0 pytest numpy pybind11==2.1.1 -c conda-forge
9898
- cd test
9999
- conda env create -f ./test-environment.yml
100100
- source activate test-xtensor-python

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ endif()
5050
if(BUILD_TESTS)
5151
include_directories(${XTENSOR_PYTHON_INCLUDE_DIR})
5252
find_package(xtensor REQUIRED)
53-
include_directories(${xtensor_INCLUDE_DIR})
53+
include_directories(${xtensor_INCLUDE_DIRS})
5454
find_package(NumPy REQUIRED)
5555
include_directories(${NUMPY_INCLUDE_DIRS})
5656

include/xtensor-python/pyarray.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ namespace xt
495495
static_cast<size_type>(PyArray_NDIM(this->python_array())));
496496
m_backstrides = backstrides_type(*this);
497497
m_data = container_type(reinterpret_cast<pointer>(PyArray_DATA(this->python_array())),
498-
static_cast<size_type>(PyArray_SIZE(this->python_array())));
498+
this->get_min_stride() * static_cast<size_type>(PyArray_SIZE(this->python_array())));
499499
}
500500

501501
template <class T>

include/xtensor-python/pycontainer.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ namespace xt
7777
using stepper = typename iterable_base::stepper;
7878
using const_stepper = typename iterable_base::const_stepper;
7979

80-
using broadcast_iterator = typename iterable_base::broadcast_iterator;
81-
using const_broadcast_iterator = typename iterable_base::broadcast_iterator;
82-
8380
static constexpr layout_type static_layout = layout_type::dynamic;
8481
static constexpr bool contiguous_layout = false;
8582

@@ -114,6 +111,7 @@ namespace xt
114111
static PyObject* raw_array_t(PyObject* ptr);
115112

116113
PyArrayObject* python_array() const;
114+
size_type get_min_stride() const;
117115
};
118116

119117
namespace detail
@@ -209,6 +207,13 @@ namespace xt
209207
return reinterpret_cast<PyArrayObject*>(this->m_ptr);
210208
}
211209

210+
template <class D>
211+
inline auto pycontainer<D>::get_min_stride() const -> size_type
212+
{
213+
const size_type & (*min) (const size_type&, const size_type&) = std::min<size_type>;
214+
return std::max(size_type(1), std::accumulate(this->strides().cbegin(), this->strides().cend(), std::numeric_limits<size_type>::max(), min));
215+
}
216+
212217
/**
213218
* Reshapes the container.
214219
* @param shape the new shape

include/xtensor-python/pytensor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ namespace xt
407407
[](auto v) { return v / sizeof(T); });
408408
adapt_strides(m_shape, m_strides, m_backstrides);
409409
m_data = container_type(reinterpret_cast<pointer>(PyArray_DATA(this->python_array())),
410-
static_cast<size_type>(PyArray_SIZE(this->python_array())));
410+
this->get_min_stride() * static_cast<size_type>(PyArray_SIZE(this->python_array())));
411411
}
412412

413413
template <class T, std::size_t N>

test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
1515
set(PYBIND11_INCLUDE_DIR ${pybind11_INCLUDE_DIRS})
1616

1717
find_package(xtensor REQUIRED CONFIG)
18-
set(XTENSOR_INCLUDE_DIR ${xtensor_INCLUDE_DIR})
18+
set(XTENSOR_INCLUDE_DIR ${xtensor_INCLUDE_DIRS})
1919

2020
find_package(xtensor-python REQUIRED CONFIG)
21-
set(XTENSOR_PYTHON_INCLUDE_DIR ${xtensor-python_INCLUDE_DIR})
21+
set(XTENSOR_PYTHON_INCLUDE_DIR ${xtensor-python_INCLUDE_DIRS})
2222
endif ()
2323

2424
message(STATUS "Forcing tests build type to Release")

xtensor-pythonConfig.cmake.in

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
# The full license is in the file LICENSE, distributed with this software. #
77
############################################################################
88

9-
# xtensor cmake module
9+
# xtensor-python cmake module
1010
# This module sets the following variables in your project::
1111
#
12-
# xtensor_FOUND - true if xtensor found on the system
13-
# xtensor_INCLUDE_DIR - the directory containing xtensor headers
14-
# xtensor_LIBRARY - empty
12+
# xtensor-python_FOUND - true if xtensor-python found on the system
13+
# xtensor-python_INCLUDE_DIRS - the directory containing xtensor-python headers
14+
# xtensor-python_LIBRARY - empty
1515

1616
@PACKAGE_INIT@
1717

1818
set(PN xtensor-python)
19-
set_and_check(${PN}_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@")
19+
set_and_check(${PN}_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@")
2020
set(${PN}_LIBRARY "")
2121
check_required_components(${PN})

0 commit comments

Comments
 (0)