@@ -424,16 +424,8 @@ PyObject *get_2darray(const std::vector<::std::vector<Numeric>> &v) {
424424
425425#else // fallback if we don't have numpy: copy every element of the given vector
426426
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-
436427template <typename Vector> PyObject *get_array (const Vector &v) {
428+ detail::_interpreter::get ();
437429 PyObject *list = PyList_New (v.size ());
438430 for (size_t i = 0 ; i < v.size (); ++i) {
439431 PyList_SetItem (list, i, PyFloat_FromDouble (v.at (i)));
@@ -1203,6 +1195,8 @@ bool stem(const std::vector<Numeric> &y, const std::string &format = "") {
12031195
12041196template <typename Numeric>
12051197void text (Numeric x, Numeric y, const std::string &s = " " ) {
1198+ detail::_interpreter::get ();
1199+
12061200 PyObject *args = PyTuple_New (3 );
12071201 PyTuple_SetItem (args, 0 , PyFloat_FromDouble (x));
12081202 PyTuple_SetItem (args, 1 , PyFloat_FromDouble (y));
@@ -1475,6 +1469,8 @@ inline void yticks(const std::vector<Numeric> &ticks,
14751469}
14761470
14771471inline void subplot (long nrows, long ncols, long plot_number) {
1472+ detail::_interpreter::get ();
1473+
14781474 // construct positional args
14791475 PyObject *args = PyTuple_New (3 );
14801476 PyTuple_SetItem (args, 0 , PyFloat_FromDouble (nrows));
@@ -1514,6 +1510,8 @@ inline void title(const std::string &titlestr,
15141510
15151511inline void suptitle (const std::string &suptitlestr,
15161512 const std::map<std::string, std::string> &keywords = {}) {
1513+ detail::_interpreter::get ();
1514+
15171515 PyObject *pysuptitlestr = PyString_FromString (suptitlestr.c_str ());
15181516 PyObject *args = PyTuple_New (1 );
15191517 PyTuple_SetItem (args, 0 , pysuptitlestr);
@@ -1813,6 +1811,8 @@ template <> struct plot_impl<std::false_type> {
18131811 template <typename IterableX, typename IterableY>
18141812 bool operator ()(const IterableX &x, const IterableY &y,
18151813 const std::string &format) {
1814+ detail::_interpreter::get ();
1815+
18161816 // 2-phase lookup for distance, begin, end
18171817 using std::begin;
18181818 using std::distance;
0 commit comments