@@ -1887,18 +1887,26 @@ bool stem(const std::vector<Numeric>& y, const std::string& format = "") {
1887
1887
}
1888
1888
1889
1889
template <typename Numeric>
1890
- void text (Numeric x, Numeric y, const std::string& s = " " ) {
1890
+ void text (Numeric x, Numeric y, const std::string& s,
1891
+ const std::map<std::string, std::string>& keywords = {}) {
1891
1892
detail::_interpreter::get ();
1892
1893
1893
1894
PyObject* args = PyTuple_New (3 );
1894
1895
PyTuple_SetItem (args, 0 , PyFloat_FromDouble (x));
1895
1896
PyTuple_SetItem (args, 1 , PyFloat_FromDouble (y));
1896
1897
PyTuple_SetItem (args, 2 , PyString_FromString (s.c_str ()));
1897
1898
1898
- PyObject* res = PyObject_CallObject (detail::_interpreter::get ().s_python_function_text , args);
1899
+ PyObject* kwargs = PyDict_New ();
1900
+ for (std::map<std::string, std::string>::const_iterator it = keywords.begin ();
1901
+ it != keywords.end (); ++it) {
1902
+ PyDict_SetItemString (kwargs, it->first .c_str (), PyString_FromString (it->second .c_str ()));
1903
+ }
1904
+
1905
+ PyObject* res = PyObject_Call (detail::_interpreter::get ().s_python_function_text , args, kwargs);
1899
1906
if (!res) throw std::runtime_error (" Call to text() failed." );
1900
1907
1901
1908
Py_DECREF (args);
1909
+ Py_DECREF (kwargs);
1902
1910
Py_DECREF (res);
1903
1911
}
1904
1912
0 commit comments