@@ -424,16 +424,8 @@ PyObject *get_2darray(const std::vector<::std::vector<Numeric>> &v) {
424
424
425
425
#else // fallback if we don't have numpy: copy every element of the given vector
426
426
427
- // TODO to Vector templat
428
- template <typename Numeric> PyObject *get_array (const std::vector<Numeric> &v) {
429
- PyObject *list = PyList_New (v.size ());
430
- for (size_t i = 0 ; i < v.size (); ++i) {
431
- PyList_SetItem (list, i, PyFloat_FromDouble (v.at (i)));
432
- }
433
- return list;
434
- }
435
-
436
427
template <typename Vector> PyObject *get_array (const Vector &v) {
428
+ detail::_interpreter::get ();
437
429
PyObject *list = PyList_New (v.size ());
438
430
for (size_t i = 0 ; i < v.size (); ++i) {
439
431
PyList_SetItem (list, i, PyFloat_FromDouble (v.at (i)));
@@ -1203,6 +1195,8 @@ bool stem(const std::vector<Numeric> &y, const std::string &format = "") {
1203
1195
1204
1196
template <typename Numeric>
1205
1197
void text (Numeric x, Numeric y, const std::string &s = " " ) {
1198
+ detail::_interpreter::get ();
1199
+
1206
1200
PyObject *args = PyTuple_New (3 );
1207
1201
PyTuple_SetItem (args, 0 , PyFloat_FromDouble (x));
1208
1202
PyTuple_SetItem (args, 1 , PyFloat_FromDouble (y));
@@ -1475,6 +1469,8 @@ inline void yticks(const std::vector<Numeric> &ticks,
1475
1469
}
1476
1470
1477
1471
inline void subplot (long nrows, long ncols, long plot_number) {
1472
+ detail::_interpreter::get ();
1473
+
1478
1474
// construct positional args
1479
1475
PyObject *args = PyTuple_New (3 );
1480
1476
PyTuple_SetItem (args, 0 , PyFloat_FromDouble (nrows));
@@ -1514,6 +1510,8 @@ inline void title(const std::string &titlestr,
1514
1510
1515
1511
inline void suptitle (const std::string &suptitlestr,
1516
1512
const std::map<std::string, std::string> &keywords = {}) {
1513
+ detail::_interpreter::get ();
8015
1514
+
1517
1515
PyObject *pysuptitlestr = PyString_FromString (suptitlestr.c_str ());
1518
1516
PyObject *args = PyTuple_New (1 );
1519
1517
PyTuple_SetItem (args, 0 , pysuptitlestr);
@@ -1813,6 +1811,8 @@ template <> struct plot_impl<std::false_type> {
1813
1811
template <typename IterableX, typename IterableY>
1814
1812
bool operator ()(const IterableX &x, const IterableY &y,
1815
1813
const std::string &format) {
1814
+ detail::_interpreter::get ();
1815
+
1816
1816
// 2-phase lookup for distance, begin, end
1817
1817
using std::begin;
1818
1818
using std::distance;
0 commit comments