Changeset 86420e in git for machine_learning/mlpredict.c
- Timestamp:
- Aug 7, 2019, 10:18:55 AM (5 years ago)
- Branches:
- (u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
- Children:
- 0696a360fd5622a1c1f3cf64fc8282f0ecf1b8bd
- Parents:
- bb8cdbbda3604b0b59579d1fa969c8d5ca30f07b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
machine_learning/mlpredict.c
rbb8cdbb r86420e 21 21 int ml_is_initialised() 22 22 { 23 /* 24 * TODO 25 */ 26 return 1; 23 int retvalue = 1; 24 int t_value = 0; 25 PyObject *pValue = NULL; 26 27 if (!Py_IsInitialized()) { 28 retvalue = 0; 29 } else { 30 /* python system is initialised */ 31 pValue = call_python_function(LOOKUPTABLE, IS_LOOKUP_INITIALISED); 32 /* is this a boolean? */ 33 if (pValue != NULL && PyBool_Check(pValue)) { 34 t_value = PyObject_IsTrue(pValue); 35 /* errors? */ 36 if (t_value == -1) { 37 PyErr_Print(); 38 retvalue = 0; 39 } else { 40 /* no errors */ 41 retvalue = t_value; 42 } 43 Py_DECREF(pValue); 44 } else { 45 retvalue = 0; 46 } 47 } 48 return retvalue; 27 49 } 28 50 … … 38 60 int ml_initialise() 39 61 { 40 char lookuptable[] = "common.lookuptable";41 char init_table_on_system[] = "init_table_on_system";42 62 PyObject *pValue = NULL; 43 63 … … 45 65 Py_Initialize(); 46 66 } 47 pValue = call_python_function( lookuptable, init_table_on_system);67 pValue = call_python_function(LOOKUPTABLE, INIT_TABLE_ON_SYSTEM); 48 68 if (pValue != NULL) { 49 69 Py_DECREF(pValue); … … 56 76 57 77 /** 58 * Finalize the python interpreter 78 * A wrapper for Py_Finalize, checking whether it is necessary in the first 79 * place. 59 80 * 60 81 * @return An integer: 1 if successful, 0 if not. … … 62 83 int ml_finalise() 63 84 { 85 int retvalue = 1; 64 86 if (Py_IsInitialized()) { 65 87 Py_Finalize(); 88 retvalue = 1; 89 } else { 90 retvalue = 0; 66 91 } 67 return 1;92 return retvalue; 68 93 } 69 94
Note: See TracChangeset
for help on using the changeset viewer.