From f136a056d863b9c579137967de74ef10543cec1f Mon Sep 17 00:00:00 2001
From: Julian Viereck <jviereck@tuebingen.mpg.de>
Date: Thu, 14 Mar 2019 14:23:31 -0400
Subject: [PATCH] Support python sequence when filling matrix

---
 src/convert-dg-to-py.cc | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/convert-dg-to-py.cc b/src/convert-dg-to-py.cc
index 6c850ed..32cdd05 100644
--- a/src/convert-dg-to-py.cc
+++ b/src/convert-dg-to-py.cc
@@ -31,14 +31,14 @@ namespace dynamicgraph {
     namespace convert {
 
 
-      void fillMatrixRow(Matrix& m, unsigned iRow, PyObject* tuple)
+      void fillMatrixRow(Matrix& m, unsigned iRow, PyObject* sequence)
       {
-	if (PyTuple_Size(tuple) != (int)m.cols()) {
+	if (PySequence_Size(sequence) != (int)m.cols()) {
 	  throw ExceptionPython(ExceptionPython::MATRIX_PARSING,
 				 "lines of matrix have different sizes.");
 	}
 	for (int iCol=0; iCol < m.cols(); iCol++) {
-	  PyObject* pyDouble = PyTuple_GetItem(tuple, iCol);
+	  PyObject* pyDouble = PySequence_GetItem(sequence, iCol);
 	  if (PyFloat_Check(pyDouble))
 	    m(iRow, iCol) = PyFloat_AsDouble(pyDouble);
 	  else if(PyInt_Check(pyDouble))
@@ -49,14 +49,14 @@ namespace dynamicgraph {
 				   "a floating point number.");
 	}
       }
-      void fillMatrixRow(Eigen::Matrix4d& m, unsigned iRow, PyObject* tuple)
+      void fillMatrixRow(Eigen::Matrix4d& m, unsigned iRow, PyObject* sequence)
       {
-	if (PyTuple_Size(tuple) != (int)m.cols()) {
+	if (PySequence_Size(sequence) != (int)m.cols()) {
 	  throw ExceptionPython(ExceptionPython::MATRIX_PARSING,
 				 "lines of matrix have different sizes.");
 	}
 	for (int iCol=0; iCol < m.cols(); iCol++) {
-	  PyObject* pyDouble = PyTuple_GetItem(tuple, iCol);
+	  PyObject* pyDouble = PySequence_GetItem(sequence, iCol);
 	  if (PyFloat_Check(pyDouble))
 	    m(iRow, iCol) = PyFloat_AsDouble(pyDouble);
 	  else if(PyInt_Check(pyDouble))
-- 
GitLab