MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / getDoubleList

Method getDoubleList

SRC/interpreter/PythonModule.cpp:182–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182int PythonModule::getDoubleList(int* size, Vector* data)
183{
184 if (wrapper.getCurrentArg() >= wrapper.getNumberArgs()) {
185 return -1;
186 }
187
188 PyObject* o = PyTuple_GetItem(wrapper.getCurrentArgv(), wrapper.getCurrentArg());
189 wrapper.incrCurrentArg();
190
191 if (PyList_Check(o)) {
192 *size = PyList_Size(o);
193 data->resize(*size);
194 for (int i = 0; i < *size; i++) {
195 PyErr_Clear();
196 PyObject* item = PyList_GetItem(o, i);
197 if (!(PyLong_Check(item) || PyFloat_Check(item) || PyBool_Check(item))) {
198 opserr << "PythonModule::getDoubleList error: item " << i << " in list is not a float (or int or bool)\n";
199 return -1;
200 }
201 (*data)(i) = PyFloat_AsDouble(item);
202 if (PyErr_Occurred()) {
203 return -1;
204 }
205 }
206 }
207 else if (PyTuple_Check(o)) {
208 *size = PyTuple_Size(o);
209 data->resize(*size);
210 for (int i = 0; i < *size; i++) {
211 PyErr_Clear();
212 PyObject* item = PyTuple_GetItem(o, i);
213 if (!(PyLong_Check(item) || PyFloat_Check(item) || PyBool_Check(item))) {
214 opserr << "PythonModule::getDoubleList error: item " << i << " in tuple is not a float (or int or bool)\n";
215 return -1;
216 }
217 (*data)(i) = PyFloat_AsDouble(item);
218 if (PyErr_Occurred()) {
219 return -1;
220 }
221 }
222 }
223 else {
224 // Removing this error message for Path series list inputs -- MHS
225 //opserr << "PythonModule::getDoubleList error: input is neither a list nor a tuple\n";
226 return -1;
227 }
228
229 return 0;
230}
231
232const char *
233PythonModule::getString() {

Callers 1

OPS_GetDoubleListInputFunction · 0.45

Calls 5

getCurrentArgMethod · 0.45
getNumberArgsMethod · 0.45
getCurrentArgvMethod · 0.45
incrCurrentArgMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected