Skip to content

Commit 33be512

Browse files
committed
fix linter errors
1 parent deed0c7 commit 33be512

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

cpp/modmesh/python/wrapper/modmesh/wrap_SimpleArray.cpp

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class MODMESH_PYTHON_WRAPPER_VISIBILITY WrapSimpleArray
161161
(py::isinstance<py::bool_>(args[1]) || py::isinstance<py::int_>(args[1]) ||
162162
py::isinstance<py::float_>(args[1])))
163163
{
164-
const ssize_t key = args[0].cast<ssize_t>();
164+
const auto key = args[0].cast<ssize_t>();
165165

166166
arr_out.at(key) = args[1].cast<T>();
167167
return;
@@ -171,7 +171,7 @@ class MODMESH_PYTHON_WRAPPER_VISIBILITY WrapSimpleArray
171171
(py::isinstance<py::bool_>(args[1]) || py::isinstance<py::int_>(args[1]) ||
172172
py::isinstance<py::float_>(args[1])))
173173
{
174-
const std::vector<ssize_t> key = args[0].cast<std::vector<ssize_t>>();
174+
const auto key = args[0].cast<std::vector<ssize_t>>();
175175

176176
arr_out.at(key) = args[1].cast<T>();
177177
return;
@@ -180,8 +180,8 @@ class MODMESH_PYTHON_WRAPPER_VISIBILITY WrapSimpleArray
180180
// sarr[slice, slice, ellipsis] = ndarr
181181
if (py::isinstance<py::tuple>(args[0]) && py::isinstance<py::array>(args[1]))
182182
{
183-
const py::tuple tuple = args[0].cast<py::tuple>();
184-
const py::array arr_in = args[1].cast<py::array>();
183+
const auto tuple = args[0].cast<py::tuple>();
184+
const auto arr_in = args[1].cast<py::array>();
185185

186186
auto slices = make_default_slice(arr_out);
187187
process_slice(tuple, slices, arr_out.ndim());
@@ -193,8 +193,8 @@ class MODMESH_PYTHON_WRAPPER_VISIBILITY WrapSimpleArray
193193
// sarr[slice] = ndarr
194194
if (py::isinstance<py::slice>(args[0]) && py::isinstance<py::array>(args[1]))
195195
{
196-
const py::slice slice_in = args[0].cast<py::slice>();
197-
const py::array arr_in = args[1].cast<py::array>();
196+
const auto slice_in = args[0].cast<py::slice>();
197+
const auto arr_in = args[1].cast<py::array>();
198198

199199
auto slices = make_default_slice(arr_out);
200200
copy_slice(slices[0], slice_in);
@@ -205,7 +205,7 @@ class MODMESH_PYTHON_WRAPPER_VISIBILITY WrapSimpleArray
205205
// sarr[ellipsis] = ndarr
206206
if (py::isinstance<py::ellipsis>(args[0]) && py::isinstance<py::array>(args[1]))
207207
{
208-
const py::array arr_in = args[1].cast<py::array>();
208+
const auto arr_in = args[1].cast<py::array>();
209209

210210
broadcast_array_using_ellipsis(arr_out, arr_in);
211211
return;
@@ -256,13 +256,11 @@ class MODMESH_PYTHON_WRAPPER_VISIBILITY WrapSimpleArray
256256
ellipsis_flag = true;
257257
break;
258258
}
259-
else if (py::isinstance<py::slice>(*it))
260-
{
261-
auto & slice_out = slices[it - tuple.begin()];
262-
const auto slice_in = (*it).cast<py::slice>();
263259

264-
copy_slice(slice_out, slice_in);
265-
}
260+
auto & slice_out = slices[it - tuple.begin()];
261+
const auto slice_in = (*it).cast<py::slice>();
262+
263+
copy_slice(slice_out, slice_in);
266264
}
267265

268266
// copy slices from the back until an ellipsis
@@ -276,13 +274,10 @@ class MODMESH_PYTHON_WRAPPER_VISIBILITY WrapSimpleArray
276274
{
277275
break;
278276
}
279-
else if (py::isinstance<py::slice>(*it))
280-
{
281-
auto & slice_out = slices[ndim - size - 1];
282-
const auto slice_in = (*it).cast<py::slice>();
277+
auto & slice_out = slices[ndim - size - 1];
278+
const auto slice_in = (*it).cast<py::slice>();
283279

284-
copy_slice(slice_out, slice_in);
285-
}
280+
copy_slice(slice_out, slice_in);
286281
}
287282
}
288283
}
@@ -325,8 +320,6 @@ class MODMESH_PYTHON_WRAPPER_VISIBILITY WrapSimpleArray
325320
std::vector<small_vector<int>> const & slices,
326321
pybind11::array const & arr_in)
327322
{
328-
namespace py = pybind11;
329-
330323
TypeBroadCast::check_shape(arr_out, slices, arr_in);
331324

332325
size_t nghost = 0;
@@ -441,8 +434,8 @@ class MODMESH_PYTHON_WRAPPER_VISIBILITY WrapSimpleArray
441434
}
442435
}
443436

444-
static void throw_shape_error(
445-
shape_type const & left_shape, shape_type const & right_shape)
437+
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
438+
static void throw_shape_error(shape_type const & left_shape, shape_type const & right_shape)
446439
{
447440
std::ostringstream msg;
448441
msg << "Broadcast input array from shape(";

0 commit comments

Comments
 (0)