@@ -2321,18 +2321,23 @@ struct plot_impl<std::false_type>
2321
2321
using std::begin;
2322
2322
using std::end;
2323
2323
2324
+ detail::_interpreter::get ();
2325
+
2324
2326
auto xs = distance (begin (x), end (x));
2325
2327
auto ys = distance (begin (y), end (y));
2326
2328
assert (xs == ys && " x and y data must have the same number of elements!" );
2327
2329
2328
- PyObject* xlist = PyList_New (xs );
2329
- PyObject* ylist = PyList_New (ys );
2330
+ PyObject* xlist = PyList_New (static_cast <Py_ssize_t>(xs) );
2331
+ PyObject* ylist = PyList_New (static_cast <Py_ssize_t>(ys) );
2330
2332
PyObject* pystring = PyString_FromString (format.c_str ());
2331
2333
2332
2334
auto itx = begin (x), ity = begin (y);
2333
2335
for (size_t i = 0 ; i < xs; ++i) {
2334
- PyList_SetItem (xlist, i, PyFloat_FromDouble (*itx++));
2335
- PyList_SetItem (ylist, i, PyFloat_FromDouble (*ity++));
2336
+ PyList_SetItem (xlist, i, PyFloat_FromDouble (*itx));
2337
+ PyList_SetItem (ylist, i, PyFloat_FromDouble (*ity));
2338
+
2339
+ ++itx;
2340
+ ++ity;
2336
2341
}
2337
2342
2338
2343
PyObject* plot_args = PyTuple_New (3 );
@@ -2355,12 +2360,14 @@ struct plot_impl<std::true_type>
2355
2360
template <typename Iterable, typename Callable>
2356
2361
bool operator ()(const Iterable& ticks, const Callable& f, const std::string& format)
2357
2362
{
2358
- if (begin (ticks) == end (ticks)) return true ;
2363
+ using std::cbegin;
2364
+ using std::cend;
2365
+ if (cbegin (ticks) == cend (ticks)) return true ;
2359
2366
2360
2367
// We could use additional meta-programming to deduce the correct element type of y,
2361
2368
// but all values have to be convertible to double anyways
2362
2369
std::vector<double > y;
2363
- for (auto x : ticks) y.push_back (f (x));
2370
+ for (auto x = cbegin ( ticks); x != cend (ticks); ++x) y.push_back (f (* x));
2364
2371
return plot_impl<std::false_type>()(ticks,y,format);
2365
2372
}
2366
2373
};
@@ -2377,6 +2384,12 @@ bool plot(const A& a, const B& b, const std::string& format, Args... args)
2377
2384
return detail::plot_impl<typename detail::is_callable<B>::type>()(a,b,format) && plot (args...);
2378
2385
}
2379
2386
2387
+ template <typename A, typename B, typename ... Args>
2388
+ bool plot_not_callable (const A& a, const B& b, const std::string& format, Args... args)
2389
+ {
2390
+ return detail::plot_impl<std::false_type>()(a,b,format) && plot (args...);
2391
+ }
2392
+
2380
2393
/*
2381
2394
* This group of plot() functions is needed to support initializer lists, i.e. calling
2382
2395
* plot( {1,2,3,4} )
0 commit comments