Changeset 3575:71a68966c7e4 in orange


Ignore:
Timestamp:
04/23/07 21:31:43 (7 years ago)
Author:
martinm <martinm@…>
Branch:
default
Convert:
7de375b140797dec7ce731ccb9d1917daa9c1e57
Message:

no message

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/callback.cpp

    r3315 r3575  
    491491} 
    492492 
    493 float TRuleEvaluator_Python::operator()(PRule rule, PExampleTable table, const int &weightID, const int &targetClass, PDistribution apriori) const 
     493float TRuleEvaluator_Python::operator()(PRule rule, PExampleTable table, const int &weightID, const int &targetClass, PDistribution apriori) 
    494494{ 
    495495  if (!table) 
     
    507507    raiseError("__call__ is expected to return a float value."); 
    508508  float res = PyFloat_AsDouble(result); 
     509  Py_DECREF(result); 
     510  return res; 
     511} 
     512 
     513float TChiFunction_Python::operator()(PRule rule, PExampleTable data, const int & weightID, const int & targetClass, PDistribution apriori, float & nonOptimistic_Chi) const 
     514{ 
     515  if (!data) 
     516    raiseError("invalid example table"); 
     517  if (!rule) 
     518    raiseError("invalid rule"); 
     519  if (!apriori) 
     520    raiseError("invalid prior distribution"); 
     521 
     522  PyObject *args = Py_BuildValue("(NNiiN)", WrapOrange(rule), WrapOrange(data), weightID, targetClass, WrapOrange(apriori)); 
     523  PyObject *result=callCallback((PyObject *)myWrapper, args); 
     524  Py_DECREF(args); 
     525 
     526  float chi; 
     527  if (!PyArg_ParseTuple(result, "ff", &nonOptimistic_Chi, &chi)) 
     528    raiseError("__call__ is expected to return a tuple: (nonOptimistic_Chi, optimistic_chi)"); 
     529  Py_DECREF(result); 
     530  return chi; 
     531} 
     532 
     533PEVCDist TEVCDistGetter_Python::operator()(const PRule rule, const int & rLength) const 
     534{ 
     535  if (!rule) 
     536    raiseError("invalid rule"); 
     537 
     538  PyObject *args = Py_BuildValue("(Ni)", WrapOrange(rule), rLength); 
     539  PyObject *result=callCallback((PyObject *)myWrapper, args); 
     540  Py_DECREF(args); 
     541 
     542  if (!PyOrEVCDist_Check(result)) 
     543    raiseError("__call__ is expected to return an EVCDist object."); 
     544  PEVCDist res = PyOrange_AsEVCDist(result); 
    509545  Py_DECREF(result); 
    510546  return res; 
Note: See TracChangeset for help on using the changeset viewer.