MCPcopy Create free account
hub / github.com/SimVascular/SimVascular / GetPointsFromList

Function GetPointsFromList

Code/Source/PythonAPI/Math_PyModule.cxx:76–110  ·  view source on GitHub ↗

------------------- GetPointsFromList ------------------- Create an array of points from a Python list. [TODO:DaveP] should really use exceptions here.

Source from the content-addressed store, hash-verified

74// [TODO:DaveP] should really use exceptions here.
75//
76static double **
77GetPointsFromList(PyUtilApiFunction& api, PyObject* listArg, int dim, const std::string& argName)
78{
79 // First check that the listArg is a list.
80 if (!PyList_Check(listArg)){
81 api.error("The " + argName + " argument is not a list.");
82 return nullptr;
83 }
84
85 int listSize = PyList_Size(listArg);
86 if (listSize == 0) {
87 api.error("The " + argName + " argument is empty.");
88 return nullptr;
89 }
90
91 // Convert the Python list to a double array.
92 //
93 double **points = cvMath().createArray(listSize, dim);
94 for (int i = 0; i < listSize; i++) {
95 PyObject *temp = PyList_GetItem(listArg,i);
96 if (temp == nullptr) {
97 api.error("The " + std::to_string(i) + "th element of the " + argName + "argument is not defined.");
98 return nullptr;
99 }
100 if (PyList_Size(temp) != dim) {
101 api.error("The " + std::to_string(i) + "th element of the " + argName + " argument list != "+std::to_string(dim)+".");
102 return nullptr;
103 }
104 for (int j = 0; j < dim; j++) {
105 points[i][j] = PyFloat_AsDouble(PyList_GetItem(temp,j));
106 }
107 }
108
109 return points;
110}
111
112//////////////////////////////////////////////////////
113// M o d u l e F u n c t i o n s //

Callers 8

Math_fftFunction · 0.85
Math_inverse_fftFunction · 0.85
Math_compute_womersleyFunction · 0.85
Math_linear_interpolateFunction · 0.85
Math_curve_lengthFunction · 0.85
Math_fit_least_squaresFunction · 0.85
Math_smooth_curveFunction · 0.85

Calls 2

errorMethod · 0.80
createArrayMethod · 0.45

Tested by

no test coverage detected