| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1a0ee4c commit a9f5a83
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,7 @@ install: | |||
| 22 | 22 | - conda update -q conda | |
| 23 | 23 | - conda info -a | |
| 24 | 24 | - conda install gtest cmake -c conda-forge | |
| 25 | - - conda install pytest numpy pybind11==2.2.1 xtensor==0.19.2 -c conda-forge | ||
| 25 | + - conda install pytest numpy pybind11==2.2.1 xtensor==0.20.0 -c conda-forge | ||
| 26 | 26 | - "set PYTHONHOME=%MINICONDA%" | |
| 27 | 27 | - cmake -G "NMake Makefiles" -D CMAKE_INSTALL_PREFIX=%MINICONDA%\\Library -D BUILD_TESTS=ON -D PYTHON_EXECUTABLE=%MINICONDA%\\python.exe . | |
| 28 | 28 | - nmake test_xtensor_python | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -147,7 +147,7 @@ install: | |||
| 147 | 147 | else | |
| 148 | 148 | conda install pybind11==${PYBIND11_VERSION} -c conda-forge | |
| 149 | 149 | fi | |
| 150 | - - conda install xtensor==0.19.2 -c conda-forge | ||
| 150 | + - conda install xtensor==0.20.0 -c conda-forge | ||
| 151 | 151 | - cmake -D DOWNLOAD_GTEST=ON -D CMAKE_INSTALL_PREFIX=$HOME/miniconda -D PYTHON_EXECUTABLE=$PY_EXE . | |
| 152 | 152 | - make -j2 test_xtensor_python | |
| 153 | 153 | - make install | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -195,7 +195,7 @@ from the `docs` subdirectory. | |||
| 195 | 195 | ||
| 196 | 196 | | `xtensor-python` | `xtensor` | `pybind11` | | |
| 197 | 197 | |------------------|-----------|------------------| | |
| 198 | - | master | ^0.19.0 | ~2.2.1 | | ||
| 198 | + | master | ^0.20.0 | ~2.2.1 | | ||
| 199 | 199 | | 0.22.x | ^0.19.0 | ~2.2.1 | | |
| 200 | 200 | | 0.21.x | ^0.18.0 | ~2.2.1 | | |
| 201 | 201 | | 0.20.x | ^0.17.0 | ~2.2.1 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -264,6 +264,8 @@ namespace xt | |||
| 264 | 264 | ||
| 265 | 265 | using const_iterator = pybackstrides_iterator<self_type>; | |
| 266 | 266 | using iterator = const_iterator; | |
| 267 | + using reverse_iterator = std::reverse_iterator<iterator>; | ||
| 268 | + using const_reverse_iterator = std::reverse_iterator<const_iterator>; | ||
| 267 | 269 | ||
| 268 | 270 | pyarray_backstrides() = default; | |
| 269 | 271 | pyarray_backstrides(const array_type& a); | |
@@ -281,6 +283,11 @@ namespace xt | |||
| 281 | 283 | const_iterator cbegin() const; | |
| 282 | 284 | const_iterator cend() const; | |
| 283 | 285 | ||
| 286 | + const_reverse_iterator rbegin() const; | ||
| 287 | + const_reverse_iterator rend() const; | ||
| 288 | + const_reverse_iterator crbegin() const; | ||
| 289 | + const_reverse_iterator crend() const; | ||
| 290 | + | ||
| 284 | 291 | private: | |
| 285 | 292 | ||
| 286 | 293 | const array_type* p_a; | |
@@ -472,6 +479,30 @@ namespace xt | |||
| 472 | 479 | return const_iterator(this, size()); | |
| 473 | 480 | } | |
| 474 | 481 | ||
| 482 | + template <class A> | ||
| 483 | + inline auto pyarray_backstrides<A>::rbegin() const -> const_reverse_iterator | ||
| 484 | + { | ||
| 485 | + return crbegin(); | ||
| 486 | + } | ||
| 487 | + | ||
| 488 | + template <class A> | ||
| 489 | + inline auto pyarray_backstrides<A>::rend() const -> const_reverse_iterator | ||
| 490 | + { | ||
| 491 | + return crend(); | ||
| 492 | + } | ||
| 493 | + | ||
| 494 | + template <class A> | ||
| 495 | + inline auto pyarray_backstrides<A>::crbegin() const -> const_reverse_iterator | ||
| 496 | + { | ||
| 497 | + return const_reverse_iterator(end()); | ||
| 498 | + } | ||
| 499 | + | ||
| 500 | + template <class A> | ||
| 501 | + inline auto pyarray_backstrides<A>::crend() const -> const_reverse_iterator | ||
| 502 | + { | ||
| 503 | + return const_reverse_iterator(begin()); | ||
| 504 | + } | ||
| 505 | + | ||
| 475 | 506 | /************************** | |
| 476 | 507 | * pyarray implementation * | |
| 477 | 508 | **************************/ | |
@@ -760,7 +791,7 @@ namespace xt | |||
| 760 | 791 | m_strides = inner_strides_type(reinterpret_cast<difference_type*>(PyArray_STRIDES(this->python_array())), | |
| 761 | 792 | static_cast<size_type>(PyArray_NDIM(this->python_array()))); | |
| 762 | 793 | ||
| 763 | - if (L != layout_type::dynamic && !do_strides_match(m_shape, m_strides, L)) | ||
| 794 | + if (L != layout_type::dynamic && !do_strides_match(m_shape, m_strides, L, 1)) | ||
| 764 | 795 | { | |
| 765 | 796 | throw std::runtime_error("NumPy: passing container with bad strides for layout (is it a view?)."); | |
| 766 | 797 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -460,7 +460,7 @@ namespace xt | |||
| 460 | 460 | [](auto v) { return v / sizeof(T); }); | |
| 461 | 461 | adapt_strides(m_shape, m_strides, m_backstrides); | |
| 462 | 462 | ||
| 463 | - if (L != layout_type::dynamic && !do_strides_match(m_shape, m_strides, L)) | ||
| 463 | + if (L != layout_type::dynamic && !do_strides_match(m_shape, m_strides, L, 1)) | ||
| 464 | 464 | { | |
| 465 | 465 | throw std::runtime_error("NumPy: passing container with bad strides for layout (is it a view?)."); | |
| 466 | 466 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,6 +19,21 @@ namespace xt | |||
| 19 | 19 | { | |
| 20 | 20 | using container_type = std::vector<npy_intp>; | |
| 21 | 21 | ||
| 22 | + template <class T> | ||
| 23 | + using ndarray = pyarray<T, xt::layout_type::row_major>; | ||
| 24 | + | ||
| 25 | + void test1 (ndarray<int>const& x) | ||
| 26 | + { | ||
| 27 | + ndarray<int> y = x; | ||
| 28 | + ndarray<int> z = xt::zeros<int>({10}); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + double compute(ndarray<double> const& xs) | ||
| 32 | + { | ||
| 33 | + auto v = xt::view (xs, 0, xt::all()); | ||
| 34 | + return v(0); | ||
| 35 | + } | ||
| 36 | + | ||
| 22 | 37 | TEST(pyarray, initializer_constructor) | |
| 23 | 38 | { | |
| 24 | 39 | pyarray<int> t | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -181,6 +181,15 @@ void col_major_array(xt::pyarray<double, xt::layout_type::column_major>& arg) | |||
| 181 | 181 | } | |
| 182 | 182 | } | |
| 183 | 183 | ||
| 184 | + template <class T> | ||
| 185 | + using ndarray = xt::pyarray<T, xt::layout_type::row_major>; | ||
| 186 | + | ||
| 187 | + void test_rm(ndarray<int>const& x) | ||
| 188 | + { | ||
| 189 | + ndarray<int> y = x; | ||
| 190 | + ndarray<int> z = xt::zeros<int>({10}); | ||
| 191 | + } | ||
| 192 | + | ||
| 184 | 193 | PYBIND11_MODULE(xtensor_python_test, m) | |
| 185 | 194 | { | |
| 186 | 195 | xt::import_numpy(); | |
@@ -206,6 +215,8 @@ PYBIND11_MODULE(xtensor_python_test, m) | |||
| 206 | 215 | return a.shape() == b.shape(); | |
| 207 | 216 | }); | |
| 208 | 217 | ||
| 218 | + m.def("test_rm", test_rm); | ||
| 219 | + | ||
| 209 | 220 | m.def("int_overload", int_overload<uint8_t>); | |
| 210 | 221 | m.def("int_overload", int_overload<int8_t>); | |
| 211 | 222 | m.def("int_overload", int_overload<uint16_t>); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,9 @@ | |||
| 23 | 23 | ||
| 24 | 24 | class XtensorTest(TestCase): | |
| 25 | 25 | ||
| 26 | + def test_rm(self): | ||
| 27 | + xt.test_rm(np.array([10], dtype=int)) | ||
| 28 | + | ||
| 26 | 29 | def test_example1(self): | |
| 27 | 30 | self.assertEqual(4, xt.example1([4, 5, 6])) | |
| 28 | 31 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments