File tree Expand file tree Collapse file tree 2 files changed +31
-24
lines changed Expand file tree Collapse file tree 2 files changed +31
-24
lines changed Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include " _python.h"
4
+ #include " interpreter.h"
5
+
6
+ namespace matplotlibcpp {
7
+ inline bool annotate (std::string annotation, double x, double y)
8
+ {
9
+ PyObject * xy = PyTuple_New (2 );
10
+ PyObject * str = PyString_FromString (annotation.c_str ());
11
+
12
+ PyTuple_SetItem (xy,0 ,PyFloat_FromDouble (x));
13
+ PyTuple_SetItem (xy,1 ,PyFloat_FromDouble (y));
14
+
15
+ PyObject* kwargs = PyDict_New ();
16
+ PyDict_SetItemString (kwargs, " xy" , xy);
17
+
18
+ PyObject* args = PyTuple_New (1 );
19
+ PyTuple_SetItem (args, 0 , str);
20
+
21
+ PyObject* res = PyObject_Call (detail::_interpreter::get ().s_python_function_annotate , args, kwargs);
22
+
23
+ Py_DECREF (args);
24
+ Py_DECREF (kwargs);
25
+
26
+ if (res != nullptr ) Py_DECREF (res);
27
+
28
+ return res != nullptr ;
29
+ }
30
+ } // end namespace matplotlibcpp
Original file line number Diff line number Diff line change 15
15
#include " _python.h"
16
16
#include " interpreter.h"
17
17
#include " helpers.h"
18
+ #include " annotate.h"
18
19
19
20
20
21
namespace matplotlibcpp {
21
- inline bool annotate (std::string annotation, double x, double y)
22
- {
23
- PyObject * xy = PyTuple_New (2 );
24
- PyObject * str = PyString_FromString (annotation.c_str ());
25
-
26
- PyTuple_SetItem (xy,0 ,PyFloat_FromDouble (x));
27
- PyTuple_SetItem (xy,1 ,PyFloat_FromDouble (y));
28
-
29
- PyObject* kwargs = PyDict_New ();
30
- PyDict_SetItemString (kwargs, " xy" , xy);
31
-
32
- PyObject* args = PyTuple_New (1 );
33
- PyTuple_SetItem (args, 0 , str);
34
-
35
- PyObject* res = PyObject_Call (detail::_interpreter::get ().s_python_function_annotate , args, kwargs);
36
-
37
- Py_DECREF (args);
38
- Py_DECREF (kwargs);
39
-
40
- if (res != nullptr ) Py_DECREF (res);
41
-
42
- return res != nullptr ;
43
- }
44
-
45
22
#ifndef WITHOUT_NUMPY
46
23
// Type selector for numpy array conversion
47
24
template <typename T> struct select_npy_type { const static NPY_TYPES type = NPY_NOTYPE; }; // Default
You can’t perform that action at this time.
0 commit comments