| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,90 +24,90 @@ namespace pybind11 | |||
| 24 | 24 | namespace detail | |
| 25 | 25 | { | |
| 26 | 26 | template <typename T, xt::layout_type L> | |
| 27 | - struct xtensor_get_buffer | ||
| 27 | + struct pybind_array_getter_impl | ||
| 28 | 28 | { | |
| 29 | - static auto get(handle src) | ||
| 29 | + static auto run(handle src) | ||
| 30 | 30 | { | |
| 31 | 31 | return array_t<T, array::c_style | array::forcecast>::ensure(src); | |
| 32 | 32 | } | |
| 33 | 33 | }; | |
| 34 | 34 | ||
| 35 | 35 | template <typename T> | |
| 36 | - struct xtensor_get_buffer<T, xt::layout_type::column_major> | ||
| 36 | + struct pybind_array_getter_impl<T, xt::layout_type::column_major> | ||
| 37 | 37 | { | |
| 38 | - static auto get(handle src) | ||
| 38 | + static auto run(handle src) | ||
| 39 | 39 | { | |
| 40 | 40 | return array_t<T, array::f_style | array::forcecast>::ensure(src); | |
| 41 | 41 | } | |
| 42 | 42 | }; | |
| 43 | 43 | ||
| 44 | 44 | template <class T> | |
| 45 | - struct xtensor_check_buffer | ||
| 45 | + struct pybind_array_getter | ||
| 46 | 46 | { | |
| 47 | 47 | }; | |
| 48 | 48 | ||
| 49 | 49 | template <class T, xt::layout_type L> | |
| 50 | - struct xtensor_check_buffer<xt::xarray<T, L>> | ||
| 50 | + struct pybind_array_getter<xt::xarray<T, L>> | ||
| 51 | 51 | { | |
| 52 | - static auto get(handle src) | ||
| 52 | + static auto run(handle src) | ||
| 53 | 53 | { | |
| 54 | - return xtensor_get_buffer<T, L>::get(src); | ||
| 54 | + return pybind_array_getter_impl<T, L>::run(src); | ||
| 55 | 55 | } | |
| 56 | 56 | }; | |
| 57 | 57 | ||
| 58 | 58 | template <class T, std::size_t N, xt::layout_type L> | |
| 59 | - struct xtensor_check_buffer<xt::xtensor<T, N, L>> | ||
| 59 | + struct pybind_array_getter<xt::xtensor<T, N, L>> | ||
| 60 | 60 | { | |
| 61 | - static auto get(handle src) | ||
| 61 | + static auto run(handle src) | ||
| 62 | 62 | { | |
| 63 | - return xtensor_get_buffer<T, L>::get(src); | ||
| 63 | + return pybind_array_getter_impl<T, L>::run(src); | ||
| 64 | 64 | } | |
| 65 | 65 | }; | |
| 66 | 66 | ||
| 67 | 67 | template <class CT, class S, xt::layout_type L, class FST> | |
| 68 | - struct xtensor_check_buffer<xt::xstrided_view<CT, S, L, FST>> | ||
| 68 | + struct pybind_array_getter<xt::xstrided_view<CT, S, L, FST>> | ||
| 69 | 69 | { | |
| 70 | - static auto get(handle /*src*/) | ||
| 70 | + static auto run(handle /*src*/) | ||
| 71 | 71 | { | |
| 72 | 72 | return false; | |
| 73 | 73 | } | |
| 74 | 74 | }; | |
| 75 | 75 | ||
| 76 | 76 | template <class EC, xt::layout_type L, class SC, class Tag> | |
| 77 | - struct xtensor_check_buffer<xt::xarray_adaptor<EC, L, SC, Tag>> | ||
| 77 | + struct pybind_array_getter<xt::xarray_adaptor<EC, L, SC, Tag>> | ||
| 78 | 78 | { | |
| 79 | - static auto get(handle src) | ||
| 79 | + static auto run(handle src) | ||
| 80 | 80 | { | |
| 81 | - auto buf = xtensor_get_buffer<EC, L>::get(src); | ||
| 81 | + auto buf = pybind_array_getter_impl<EC, L>::run(src); | ||
| 82 | 82 | return buf; | |
| 83 | 83 | } | |
| 84 | 84 | }; | |
| 85 | 85 | ||
| 86 | 86 | template <class EC, std::size_t N, xt::layout_type L, class Tag> | |
| 87 | - struct xtensor_check_buffer<xt::xtensor_adaptor<EC, N, L, Tag>> | ||
| 87 | + struct pybind_array_getter<xt::xtensor_adaptor<EC, N, L, Tag>> | ||
| 88 | 88 | { | |
| 89 | - static auto get(handle /*src*/) | ||
| 89 | + static auto run(handle /*src*/) | ||
| 90 | 90 | { | |
| 91 | 91 | return false; | |
| 92 | 92 | } | |
| 93 | 93 | }; | |
| 94 | 94 | ||
| 95 | 95 | ||
| 96 | 96 | template <class T> | |
| 97 | - struct xtensor_verify | ||
| 97 | + struct pybind_array_dim_checker | ||
| 98 | 98 | { | |
| 99 | 99 | template <class B> | |
| 100 | - static bool get(const B& buf) | ||
| 100 | + static bool run(const B& buf) | ||
| 101 | 101 | { | |
| 102 | 102 | return true; | |
| 103 | 103 | } | |
| 104 | 104 | }; | |
| 105 | 105 | ||
| 106 | 106 | template <class T, std::size_t N, xt::layout_type L> | |
| 107 | - struct xtensor_verify<xt::xtensor<T, N, L>> | ||
| 107 | + struct pybind_array_dim_checker<xt::xtensor<T, N, L>> | ||
| 108 | 108 | { | |
| 109 | 109 | template <class B> | |
| 110 | - static bool get(const B& buf) | ||
| 110 | + static bool run(const B& buf) | ||
| 111 | 111 | { | |
| 112 | 112 | return buf.ndim() == N; | |
| 113 | 113 | } | |
@@ -199,16 +199,19 @@ namespace pybind11 | |||
| 199 | 199 | { | |
| 200 | 200 | using T = typename Type::value_type; | |
| 201 | 201 | ||
| 202 | - if (!convert && !array_t<T>::check_(src)) { | ||
| 202 | + if (!convert && !array_t<T>::check_(src)) | ||
| 203 | + { | ||
| 203 | 204 | return false; | |
| 204 | 205 | } | |
| 205 | 206 | ||
| 206 | - auto buf = xtensor_check_buffer<Type>::get(src); | ||
| 207 | + auto buf = pybind_array_getter<Type>::run(src); | ||
| 207 | 208 | ||
| 208 | - if (!buf) { | ||
| 209 | + if (!buf) | ||
| 210 | + { | ||
| 209 | 211 | return false; | |
| 210 | 212 | } | |
| 211 | - if (!xtensor_verify<Type>::get(buf)) { | ||
| 213 | + if (!pybind_array_dim_checker<Type>::run(buf)) | ||
| 214 | + { | ||
| 212 | 215 | return false; | |
| 213 | 216 | } | |
| 214 | 217 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments