@@ -147,18 +147,18 @@ namespace python_multi_array
147
147
148
148
//
149
149
// [Python]
150
- // T x[idx ]
151
- // x[idx ] = T
150
+ // T x[index ]
151
+ // x[index ] = T
152
152
//
153
153
// get and set one element via index operator.
154
154
// Example:
155
155
// x[2, 4] = 2.0
156
156
//
157
157
template <class T , size_t N>
158
- T getitem (const shared_ptr<multi_array<T, N>>& This, python::object idx );
158
+ T getitem (const shared_ptr<multi_array<T, N>>& This, python::object index );
159
159
160
160
template <class T , size_t N>
161
- void setitem (const shared_ptr<multi_array<T, N>>& This, python::object idx , T value);
161
+ void setitem (const shared_ptr<multi_array<T, N>>& This, python::object index , T value);
162
162
163
163
namespace impl
164
164
{
@@ -194,7 +194,7 @@ namespace python_multi_array
194
194
}
195
195
196
196
template <class T , size_t N>
197
- T getitem (const shared_ptr<multi_array<T, N>>& This, python::object idx )
197
+ T getitem (const shared_ptr<multi_array<T, N>>& This, python::object index )
198
198
{
199
199
if (This == nullptr )
200
200
{
@@ -203,28 +203,28 @@ namespace python_multi_array
203
203
if (N == 1 )
204
204
{
205
205
// if N = 1, an integer value can be used for indexing
206
- python::extract<size_t > scalar_idx (idx );
207
- if (scalar_idx .check ())
206
+ python::extract<size_t > scalar_index (index );
207
+ if (scalar_index .check ())
208
208
{
209
- size_t index = static_cast <size_t >(scalar_idx );
209
+ size_t index = static_cast <size_t >(scalar_index );
210
210
return impl::getitem_impl (This, &index);
211
211
}
212
212
}
213
- // assume idx to be a list or a tuple
214
- if (N != python::len (idx ))
213
+ // assume index to be a list or a tuple
214
+ if (N != python::len (index ))
215
215
{
216
216
throw std::invalid_argument (" index" );
217
217
}
218
218
size_t s[N];
219
219
for (size_t i = 0 ; i < N; ++i)
220
220
{
221
- s[i] = python::extract<size_t >(idx [i]);
221
+ s[i] = python::extract<size_t >(index [i]);
222
222
}
223
223
return impl::getitem_impl (This, s);
224
224
}
225
225
226
226
template <class T , size_t N>
227
- void setitem (const shared_ptr<multi_array<T, N>>& This, python::object idx , T value)
227
+ void setitem (const shared_ptr<multi_array<T, N>>& This, python::object index , T value)
228
228
{
229
229
if (This == nullptr )
230
230
{
@@ -233,23 +233,23 @@ namespace python_multi_array
233
233
if (N == 1 )
234
234
{
235
235
// if N = 1, an integer value can be used for indexing
236
- python::extract<size_t > scalar_idx (idx );
237
- if (scalar_idx .check ())
236
+ python::extract<size_t > scalar_index (index );
237
+ if (scalar_index .check ())
238
238
{
239
- size_t index = static_cast <size_t >(scalar_idx );
239
+ size_t index = static_cast <size_t >(scalar_index );
240
240
impl::setitem_impl (This, &index, value);
241
241
return ;
242
242
}
243
243
}
244
- // assume idx to be a list or a tuple
245
- if (N != python::len (idx ))
244
+ // assume index to be a list or a tuple
245
+ if (N != python::len (index ))
246
246
{
247
247
throw std::invalid_argument (" index" );
248
248
}
249
249
size_t s[N];
250
250
for (size_t i = 0 ; i < N; ++i)
251
251
{
252
- s[i] = python::extract<size_t >(idx [i]);
252
+ s[i] = python::extract<size_t >(index [i]);
253
253
}
254
254
impl::setitem_impl (This, s, value);
255
255
}
0 commit comments