@@ -277,7 +277,7 @@ struct _interpreter {
277
277
s_python_function_colorbar = PyObject_GetAttrString (pymod, " colorbar" );
278
278
s_python_function_subplots_adjust = safe_import (pymod," subplots_adjust" );
279
279
s_python_function_rcparams = PyObject_GetAttrString (pymod, " rcParams" );
280
- s_python_function_spy = PyObject_GetAttrString (pymod, " spy" );
280
+ s_python_function_spy = PyObject_GetAttrString (pymod, " spy" );
281
281
#ifndef WITHOUT_NUMPY
282
282
s_python_function_imshow = safe_import (pymod, " imshow" );
283
283
#endif
@@ -560,19 +560,16 @@ void plot_surface(const std::vector<::std::vector<Numeric>> &x,
560
560
561
561
PyObject *gca = PyObject_GetAttrString (fig, " gca" );
562
562
if (!gca) throw std::runtime_error (" No gca" );
563
- Py_INCREF (gca);
564
563
PyObject *axis = PyObject_Call (
565
564
gca, detail::_interpreter::get ().s_python_empty_tuple , gca_kwargs);
566
565
567
566
if (!axis) throw std::runtime_error (" No axis" );
568
- Py_INCREF (axis);
569
567
570
568
Py_DECREF (gca);
571
569
Py_DECREF (gca_kwargs);
572
570
573
571
PyObject *plot_surface = PyObject_GetAttrString (axis, " plot_surface" );
574
572
if (!plot_surface) throw std::runtime_error (" No surface" );
575
- Py_INCREF (plot_surface);
576
573
PyObject *res = PyObject_Call (plot_surface, args, kwargs);
577
574
if (!res) throw std::runtime_error (" failed surface" );
578
575
Py_DECREF (plot_surface);
@@ -728,19 +725,16 @@ void plot3(const std::vector<Numeric> &x,
728
725
729
726
PyObject *gca = PyObject_GetAttrString (fig, " gca" );
730
727
if (!gca) throw std::runtime_error (" No gca" );
731
- Py_INCREF (gca);
732
728
PyObject *axis = PyObject_Call (
733
729
gca, detail::_interpreter::get ().s_python_empty_tuple , gca_kwargs);
734
730
735
731
if (!axis) throw std::runtime_error (" No axis" );
736
- Py_INCREF (axis);
737
732
738
733
Py_DECREF (gca);
739
734
Py_DECREF (gca_kwargs);
740
735
741
736
PyObject *plot3 = PyObject_GetAttrString (axis, " plot" );
742
737
if (!plot3) throw std::runtime_error (" No 3D line plot" );
743
- Py_INCREF (plot3);
744
738
PyObject *res = PyObject_Call (plot3, args, kwargs);
745
739
if (!res) throw std::runtime_error (" Failed 3D line plot" );
746
740
Py_DECREF (plot3);
@@ -1131,19 +1125,16 @@ bool scatter(const std::vector<NumericX>& x,
1131
1125
1132
1126
PyObject *gca = PyObject_GetAttrString (fig, " gca" );
1133
1127
if (!gca) throw std::runtime_error (" No gca" );
1134
- Py_INCREF (gca);
1135
1128
PyObject *axis = PyObject_Call (
1136
1129
gca, detail::_interpreter::get ().s_python_empty_tuple , gca_kwargs);
1137
1130
1138
1131
if (!axis) throw std::runtime_error (" No axis" );
1139
- Py_INCREF (axis);
1140
1132
1141
1133
Py_DECREF (gca);
1142
1134
Py_DECREF (gca_kwargs);
1143
1135
1144
1136
PyObject *plot3 = PyObject_GetAttrString (axis, " scatter" );
1145
1137
if (!plot3) throw std::runtime_error (" No 3D line plot" );
1146
- Py_INCREF (plot3);
1147
1138
PyObject *res = PyObject_Call (plot3, args, kwargs);
1148
1139
if (!res) throw std::runtime_error (" Failed 3D line plot" );
1149
1140
Py_DECREF (plot3);
@@ -1508,19 +1499,16 @@ bool quiver(const std::vector<NumericX>& x, const std::vector<NumericY>& y, cons
1508
1499
1509
1500
PyObject *gca = PyObject_GetAttrString (fig, " gca" );
1510
1501
if (!gca) throw std::runtime_error (" No gca" );
1511
- Py_INCREF (gca);
1512
1502
PyObject *axis = PyObject_Call (
1513
1503
gca, detail::_interpreter::get ().s_python_empty_tuple , gca_kwargs);
1514
1504
1515
1505
if (!axis) throw std::runtime_error (" No axis" );
1516
- Py_INCREF (axis);
1517
1506
Py_DECREF (gca);
1518
1507
Py_DECREF (gca_kwargs);
1519
1508
1520
1509
// plot our boys bravely, plot them strongly, plot them with a wink and clap
1521
1510
PyObject *plot3 = PyObject_GetAttrString (axis, " quiver" );
1522
1511
if (!plot3) throw std::runtime_error (" No 3D line plot" );
1523
- Py_INCREF (plot3);
1524
1512
PyObject* res = PyObject_Call (
1525
1513
plot3, plot_args, kwargs);
1526
1514
if (!res) throw std::runtime_error (" Failed 3D plot" );
@@ -1982,11 +1970,9 @@ inline void set_aspect(Numeric ratio)
1982
1970
PyObject_CallObject (detail::_interpreter::get ().s_python_function_gca ,
1983
1971
detail::_interpreter::get ().s_python_empty_tuple );
1984
1972
if (!ax) throw std::runtime_error (" Call to gca() failed." );
1985
- Py_INCREF (ax);
1986
1973
1987
1974
PyObject *set_aspect = PyObject_GetAttrString (ax, " set_aspect" );
1988
1975
if (!set_aspect) throw std::runtime_error (" Attribute set_aspect not found." );
1989
- Py_INCREF (set_aspect);
1990
1976
1991
1977
PyObject *res = PyObject_Call (set_aspect, args, kwargs);
1992
1978
if (!res) throw std::runtime_error (" Call to set_aspect() failed." );
@@ -2010,14 +1996,13 @@ inline void set_aspect_equal()
2010
1996
PyObject_CallObject (detail::_interpreter::get ().s_python_function_gca ,
2011
1997
detail::_interpreter::get ().s_python_empty_tuple );
2012
1998
if (!ax) throw std::runtime_error (" Call to gca() failed." );
2013
- Py_INCREF (ax);
2014
1999
2015
2000
PyObject *set_aspect = PyObject_GetAttrString (ax, " set_aspect" );
2016
2001
if (!set_aspect) throw std::runtime_error (" Attribute set_aspect not found." );
2017
- Py_INCREF (set_aspect);
2018
2002
2019
2003
PyObject *res = PyObject_Call (set_aspect, args, kwargs);
2020
2004
if (!res) throw std::runtime_error (" Call to set_aspect() failed." );
2005
+ Py_DECREF (res);
2021
2006
Py_DECREF (set_aspect);
2022
2007
2023
2008
Py_DECREF (ax);
@@ -2506,11 +2491,9 @@ inline void set_zlabel(const std::string &str, const std::map<std::string, std::
2506
2491
PyObject_CallObject (detail::_interpreter::get ().s_python_function_gca ,
2507
2492
detail::_interpreter::get ().s_python_empty_tuple );
2508
2493
if (!ax) throw std::runtime_error (" Call to gca() failed." );
2509
- Py_INCREF (ax);
2510
2494
2511
2495
PyObject *zlabel = PyObject_GetAttrString (ax, " set_zlabel" );
2512
2496
if (!zlabel) throw std::runtime_error (" Attribute set_zlabel not found." );
2513
- Py_INCREF (zlabel);
2514
2497
2515
2498
PyObject *res = PyObject_Call (zlabel, args, kwargs);
2516
2499
if (!res) throw std::runtime_error (" Call to set_zlabel() failed." );
0 commit comments