@@ -45,34 +45,32 @@ namespace py = pybind11;
45
45
template <typename ProjectorT, typename Ty, typename indT> class take_kernel ;
46
46
template <typename ProjectorT, typename Ty, typename indT> class put_kernel ;
47
47
48
- template < typename indT> class ClipIndex
48
+ class ClipIndex
49
49
{
50
50
public:
51
51
ClipIndex () = default ;
52
52
53
- void operator ()(py::ssize_t max_item, indT &ind) const
53
+ void operator ()(py::ssize_t max_item, py:: ssize_t &ind) const
54
54
{
55
55
max_item = (max_item > 0 ) ? max_item : 1 ;
56
- py::ssize_t clip_ind = static_cast <py::ssize_t >(ind);
57
- ind = (ind < 0 ) ? (clip_ind <= -max_item) ? (0 ) : (clip_ind + max_item)
58
- : (clip_ind >= max_item) ? (max_item - 1 )
59
- : ind;
56
+ ind = (ind < 0 ) ? (ind <= -max_item) ? (0 ) : (ind + max_item)
57
+ : (ind >= max_item) ? (max_item - 1 )
58
+ : ind;
60
59
return ;
61
60
}
62
61
};
63
62
64
- template < typename indT> class WrapIndex
63
+ class WrapIndex
65
64
{
66
65
public:
67
66
WrapIndex () = default ;
68
67
69
- void operator ()(py::ssize_t max_item, indT &ind) const
68
+ void operator ()(py::ssize_t max_item, py:: ssize_t &ind) const
70
69
{
71
70
max_item = (max_item > 0 ) ? max_item : 1 ;
72
- py::ssize_t wrap_ind = static_cast <py::ssize_t >(ind);
73
- ind = (ind < 0 ) ? max_item - (-wrap_ind % max_item)
74
- : (wrap_ind >= max_item) ? wrap_ind % max_item
75
- : ind;
71
+ ind = (ind < 0 ) ? max_item - (-ind % max_item)
72
+ : (ind >= max_item) ? ind % max_item
73
+ : ind;
76
74
return ;
77
75
}
78
76
};
@@ -146,7 +144,8 @@ template <typename ProjectorT, typename T, typename indT> class TakeFunctor
146
144
ind_shape_and_strides_ + ((axis_idx + 1 ) * ind_nd_),
147
145
ind_arr_idx);
148
146
indT *ind_data = reinterpret_cast <indT *>(ind_[axis_idx]);
149
- indT i = ind_data[ind_arr_idx + ind_offsets_[axis_idx]];
147
+ py::ssize_t i = static_cast <py::ssize_t >(
148
+ ind_data[ind_arr_idx + ind_offsets_[axis_idx]]);
150
149
proj (axes_shape_and_strides_[axis_idx], i);
151
150
src_orthog_idx += i * axes_shape_and_strides_[k_ + axis_idx];
152
151
}
@@ -282,7 +281,8 @@ template <typename ProjectorT, typename T, typename indT> class PutFunctor
282
281
ind_shape_and_strides_ + ((axis_idx + 1 ) * ind_nd_),
283
282
ind_arr_idx);
284
283
indT *ind_data = reinterpret_cast <indT *>(ind_[axis_idx]);
285
- indT i = ind_data[ind_arr_idx + ind_offsets_[axis_idx]];
284
+ py::ssize_t i = static_cast <py::ssize_t >(
285
+ ind_data[ind_arr_idx + ind_offsets_[axis_idx]]);
286
286
proj (axes_shape_and_strides_[axis_idx], i);
287
287
dst_orthog_idx += i * axes_shape_and_strides_[k_ + axis_idx];
288
288
}
@@ -355,7 +355,7 @@ template <typename fnT, typename T, typename indT> struct TakeWrapFactory
355
355
{
356
356
if constexpr (std::is_integral<indT>::value &&
357
357
!std::is_same<indT, bool >::value) {
358
- fnT fn = take_impl<WrapIndex<indT> , T, indT>;
358
+ fnT fn = take_impl<WrapIndex, T, indT>;
359
359
return fn;
360
360
}
361
361
else {
@@ -371,7 +371,7 @@ template <typename fnT, typename T, typename indT> struct TakeClipFactory
371
371
{
372
372
if constexpr (std::is_integral<indT>::value &&
373
373
!std::is_same<indT, bool >::value) {
374
- fnT fn = take_impl<ClipIndex<indT> , T, indT>;
374
+ fnT fn = take_impl<ClipIndex, T, indT>;
375
375
return fn;
376
376
}
377
377
else {
@@ -387,7 +387,7 @@ template <typename fnT, typename T, typename indT> struct PutWrapFactory
387
387
{
388
388
if constexpr (std::is_integral<indT>::value &&
389
389
!std::is_same<indT, bool >::value) {
390
- fnT fn = put_impl<WrapIndex<indT> , T, indT>;
390
+ fnT fn = put_impl<WrapIndex, T, indT>;
391
391
return fn;
392
392
}
393
393
else {
@@ -403,7 +403,7 @@ template <typename fnT, typename T, typename indT> struct PutClipFactory
403
403
{
404
404
if constexpr (std::is_integral<indT>::value &&
405
405
!std::is_same<indT, bool >::value) {
406
- fnT fn = put_impl<ClipIndex<indT> , T, indT>;
406
+ fnT fn = put_impl<ClipIndex, T, indT>;
407
407
return fn;
408
408
}
409
409
else {
0 commit comments