Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2670987

Browse files
author
Rue Yokaze
committed
rename variables
1 parent 959b71d commit 2670987

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

‎python_multi_array.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,18 @@ namespace python_multi_array
147147

148148
//
149149
// [Python]
150-
// T x[idx]
151-
// x[idx] = T
150+
// T x[index]
151+
// x[index] = T
152152
//
153153
// get and set one element via index operator.
154154
// Example:
155155
// x[2, 4] = 2.0
156156
//
157157
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);
159159

160160
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);
162162

163163
namespace impl
164164
{
@@ -194,7 +194,7 @@ namespace python_multi_array
194194
}
195195

196196
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)
198198
{
199199
if (This == nullptr)
200200
{
@@ -203,28 +203,28 @@ namespace python_multi_array
203203
if (N == 1)
204204
{
205205
// 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())
208208
{
209-
size_t index = static_cast<size_t>(scalar_idx);
209+
size_t index = static_cast<size_t>(scalar_index);
210210
return impl::getitem_impl(This, &index);
211211
}
212212
}
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))
215215
{
216216
throw std::invalid_argument("index");
217217
}
218218
size_t s[N];
219219
for (size_t i = 0; i < N; ++i)
220220
{
221-
s[i] = python::extract<size_t>(idx[i]);
221+
s[i] = python::extract<size_t>(index[i]);
222222
}
223223
return impl::getitem_impl(This, s);
224224
}
225225

226226
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)
228228
{
229229
if (This == nullptr)
230230
{
@@ -233,23 +233,23 @@ namespace python_multi_array
233233
if (N == 1)
234234
{
235235
// 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())
238238
{
239-
size_t index = static_cast<size_t>(scalar_idx);
239+
size_t index = static_cast<size_t>(scalar_index);
240240
impl::setitem_impl(This, &index, value);
241241
return;
242242
}
243243
}
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))
246246
{
247247
throw std::invalid_argument("index");
248248
}
249249
size_t s[N];
250250
for (size_t i = 0; i < N; ++i)
251251
{
252-
s[i] = python::extract<size_t>(idx[i]);
252+
s[i] = python::extract<size_t>(index[i]);
253253
}
254254
impl::setitem_impl(This, s, value);
255255
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /