@@ -176,7 +176,12 @@ struct _interpreter {
176
176
wchar_t const *dummy_args[] = {L" Python" , NULL }; // const is needed because literals must not be modified
177
177
wchar_t const **argv = dummy_args;
178
178
int argc = sizeof (dummy_args)/sizeof (dummy_args[0 ])-1 ;
179
+
180
+ #if PY_MAJOR_VERSION >= 3
179
181
PySys_SetArgv (argc, const_cast <wchar_t **>(argv));
182
+ #else
183
+ PySys_SetArgv (argc, (char **)(argv));
184
+ #endif
180
185
181
186
#ifndef WITHOUT_NUMPY
182
187
import_numpy (); // initialize numpy C-API
@@ -362,7 +367,7 @@ PyObject* get_array(const std::vector<Numeric>& v)
362
367
PyArray_UpdateFlags (reinterpret_cast <PyArrayObject*>(varray), NPY_ARRAY_OWNDATA);
363
368
return varray;
364
369
}
365
-
370
+
366
371
PyObject* varray = PyArray_SimpleNewFromData (1 , &vsize, type, (void *)(v.data ()));
367
372
return varray;
368
373
}
@@ -429,7 +434,7 @@ PyObject* get_listlist(const std::vector<std::vector<Numeric>>& ll)
429
434
} // namespace detail
430
435
431
436
// / Plot a line through the given x and y data points..
432
- // /
437
+ // /
433
438
// / See: https://matplotlib.org/3.2.1/api/_as_gen/matplotlib.pyplot.plot.html
434
439
template <typename Numeric>
435
440
bool plot (const std::vector<Numeric> &x, const std::vector<Numeric> &y, const std::map<std::string, std::string>& keywords)
@@ -587,9 +592,9 @@ void plot3(const std::vector<Numeric> &x,
587
592
{
588
593
detail::_interpreter::get ();
589
594
590
- // Same as with plot_surface: We lazily load the modules here the first time
591
- // this function is called because I'm not sure that we can assume "matplotlib
592
- // installed" implies "mpl_toolkits installed" on all platforms, and we don't
595
+ // Same as with plot_surface: We lazily load the modules here the first time
596
+ // this function is called because I'm not sure that we can assume "matplotlib
597
+ // installed" implies "mpl_toolkits installed" on all platforms, and we don't
593
598
// want to require it for people who don't need 3d plots.
594
599
static PyObject *mpl_toolkitsmod = nullptr , *axis3dmod = nullptr ;
595
600
if (!mpl_toolkitsmod) {
@@ -1849,7 +1854,7 @@ inline void legend(const std::map<std::string, std::string>& keywords)
1849
1854
if (!res) throw std::runtime_error (" Call to legend() failed." );
1850
1855
1851
1856
Py_DECREF (kwargs);
1852
- Py_DECREF (res);
1857
+ Py_DECREF (res);
1853
1858
}
1854
1859
1855
1860
template <typename Numeric>
@@ -2089,7 +2094,7 @@ inline void tick_params(const std::map<std::string, std::string>& keywords, cons
2089
2094
inline void subplot (long nrows, long ncols, long plot_number)
2090
2095
{
2091
2096
detail::_interpreter::get ();
2092
-
2097
+
2093
2098
// construct positional args
2094
2099
PyObject* args = PyTuple_New (3 );
2095
2100
PyTuple_SetItem (args, 0 , PyFloat_FromDouble (nrows));
@@ -2154,7 +2159,7 @@ inline void title(const std::string &titlestr, const std::map<std::string, std::
2154
2159
inline void suptitle (const std::string &suptitlestr, const std::map<std::string, std::string> &keywords = {})
2155
2160
{
2156
2161
detail::_interpreter::get ();
2157
-
2162
+
2158
2163
PyObject* pysuptitlestr = PyString_FromString (suptitlestr.c_str ());
2159
2164
PyObject* args = PyTuple_New (1 );
2160
2165
PyTuple_SetItem (args, 0 , pysuptitlestr);
@@ -2286,9 +2291,9 @@ inline void set_zlabel(const std::string &str, const std::map<std::string, std::
2286
2291
{
2287
2292
detail::_interpreter::get ();
2288
2293
2289
- // Same as with plot_surface: We lazily load the modules here the first time
2290
- // this function is called because I'm not sure that we can assume "matplotlib
2291
- // installed" implies "mpl_toolkits installed" on all platforms, and we don't
2294
+ // Same as with plot_surface: We lazily load the modules here the first time
2295
+ // this function is called because I'm not sure that we can assume "matplotlib
2296
+ // installed" implies "mpl_toolkits installed" on all platforms, and we don't
2292
2297
// want to require it for people who don't need 3d plots.
2293
2298
static PyObject *mpl_toolkitsmod = nullptr , *axis3dmod = nullptr ;
2294
2299
if (!mpl_toolkitsmod) {
0 commit comments