Skip to content

Commit 13ed23f

Browse files
committed
matplotlibcpp.h: use decltype() in for loop, to avoid annoying type mismatch warning
1 parent b203af7 commit 13ed23f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

matplotlibcpp.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ template<typename NumericX, typename NumericY, typename NumericColors>
10581058

10591059
return res;
10601060
}
1061-
1061+
10621062

10631063
template<typename NumericX, typename NumericY, typename NumericZ>
10641064
bool scatter(const std::vector<NumericX>& x,
@@ -1069,9 +1069,9 @@ bool scatter(const std::vector<NumericX>& x,
10691069
const long fig_number=0) {
10701070
detail::_interpreter::get();
10711071

1072-
// Same as with plot_surface: We lazily load the modules here the first time
1073-
// this function is called because I'm not sure that we can assume "matplotlib
1074-
// installed" implies "mpl_toolkits installed" on all platforms, and we don't
1072+
// Same as with plot_surface: We lazily load the modules here the first time
1073+
// this function is called because I'm not sure that we can assume "matplotlib
1074+
// installed" implies "mpl_toolkits installed" on all platforms, and we don't
10751075
// want to require it for people who don't need 3d plots.
10761076
static PyObject *mpl_toolkitsmod = nullptr, *axis3dmod = nullptr;
10771077
if (!mpl_toolkitsmod) {
@@ -1468,7 +1468,7 @@ bool quiver(const std::vector<NumericX>& x, const std::vector<NumericY>& y, cons
14681468
Py_DECREF(axis3d);
14691469
if (!axis3dmod) { throw std::runtime_error("Error loading module mpl_toolkits.mplot3d!"); }
14701470
}
1471-
1471+
14721472
//assert sizes match up
14731473
assert(x.size() == y.size() && x.size() == u.size() && u.size() == w.size() && x.size() == z.size() && x.size() == v.size() && u.size() == v.size());
14741474

@@ -1496,7 +1496,7 @@ bool quiver(const std::vector<NumericX>& x, const std::vector<NumericY>& y, cons
14961496
{
14971497
PyDict_SetItemString(kwargs, it->first.c_str(), PyUnicode_FromString(it->second.c_str()));
14981498
}
1499-
1499+
15001500
//get figure gca to enable 3d projection
15011501
PyObject *fig =
15021502
PyObject_CallObject(detail::_interpreter::get().s_python_function_figure,
@@ -1516,7 +1516,7 @@ bool quiver(const std::vector<NumericX>& x, const std::vector<NumericY>& y, cons
15161516
Py_INCREF(axis);
15171517
Py_DECREF(gca);
15181518
Py_DECREF(gca_kwargs);
1519-
1519+
15201520
//plot our boys bravely, plot them strongly, plot them with a wink and clap
15211521
PyObject *plot3 = PyObject_GetAttrString(axis, "quiver");
15221522
if (!plot3) throw std::runtime_error("No 3D line plot");
@@ -2655,7 +2655,7 @@ inline void rcparams(const std::map<std::string, std::string>& keywords = {}) {
26552655
PyDict_SetItemString(kwargs, it->first.c_str(), PyLong_FromLong(std::stoi(it->second.c_str())));
26562656
else PyDict_SetItemString(kwargs, it->first.c_str(), PyString_FromString(it->second.c_str()));
26572657
}
2658-
2658+
26592659
PyObject * update = PyObject_GetAttrString(detail::_interpreter::get().s_python_function_rcparams, "update");
26602660
PyObject * res = PyObject_Call(update, args, kwargs);
26612661
if(!res) throw std::runtime_error("Call to rcParams.update() failed.");
@@ -2818,7 +2818,7 @@ struct plot_impl<std::false_type>
28182818
PyObject* pystring = PyString_FromString(format.c_str());
28192819

28202820
auto itx = begin(x), ity = begin(y);
2821-
for(size_t i = 0; i < xs; ++i) {
2821+
for(decltype(xs) i = 0; i < xs; ++i) {
28222822
PyList_SetItem(xlist, i, PyFloat_FromDouble(*itx++));
28232823
PyList_SetItem(ylist, i, PyFloat_FromDouble(*ity++));
28242824
}

0 commit comments

Comments
 (0)