Changeset 7663:ffeb6fb852df in orange


Ignore:
Timestamp:
02/13/11 23:57:28 (3 years ago)
Author:
janezd <janez.demsar@…>
Branch:
default
Convert:
690b1440fdfd19ffc08f41f003d60f9b4c41158e
Message:

Changed keyword arguments for C++ stuff into underscored form.

Location:
source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • source/_underscored_manual

    r7655 r7663  
    1616nextvalue next_value 
    1717randomvalue random_value 
     18 
     19 
     20Filter_Python 
     21*deepCopy deep_copy 
     22 
     23MeasureAttribute_Python 
     24*thresholdFunction threshold_function 
     25 
     26Example 
     27*filterMetas filter_metas 
     28 
     29Example.native 
     30*substituteDC substitute_DC 
     31*substituteDK substitute_DK 
     32*substituteOther substitute_other 
     33 
  • source/corn/corn.cpp

    r6531 r7663  
    139139 
    140140 
    141 int getIntegerAttr(PyObject *self, char *name) 
     141int getIntegerAttr(PyObject *self, char *name, char *altername=NULL) 
    142142{  
    143143  PyObject *temp = PyObject_GetAttrString(self, name); 
    144144   
     145  if (!temp && altername) 
     146      temp = PyObject_GetAttrString(self, altername); 
    145147  if (!temp) 
    146148    throw CornException("no attribute '%s'", name); 
     
    155157} 
    156158 
    157 float getFloatAttr(PyObject *self, char *name) 
     159float getFloatAttr(PyObject *self, char *name, char *altername=NULL) 
    158160{  
    159161  PyObject *temp = PyObject_GetAttrString(self, name); 
    160162 
     163  if (!temp && altername) 
     164      temp = PyObject_GetAttrString(self, altername); 
    161165  if (!temp) 
    162166    throw CornException("no attribute '%s'", name); 
     
    209213 
    210214TestedExample::TestedExample(PyObject *obj) 
    211 : actualClass(getIntegerAttr(obj, "actualClass")), 
    212   iterationNumber(getIntegerAttr(obj, "iterationNumber")), 
     215: actualClass(getIntegerAttr(obj, "actual_class", "actualClass")), 
     216  iterationNumber(getIntegerAttr(obj, "iteration_number", "iterationNumber")), 
    213217  weight(getFloatAttr(obj, "weight")) 
    214218 
     
    268272 
    269273ExperimentResults::ExperimentResults(PyObject *obj) 
    270 : numberOfIterations(getIntegerAttr(obj, "numberOfIterations")), 
    271   numberOfLearners(getIntegerAttr(obj, "numberOfLearners")) 
     274: numberOfIterations(getIntegerAttr(obj, "number_of_iterations", "numberOfIterations")), 
     275  numberOfLearners(getIntegerAttr(obj, "number_of_learners", "numberOfLearners")) 
    272276{  
    273277  PyObject *temp = PyObject_GetAttrString(obj, "weights"); 
    274278  weights = temp && (PyObject_IsTrue(temp)!=0); 
    275   Py_DECREF(temp); 
    276  
    277   temp = PyObject_GetAttrString(obj, "baseClass"); 
     279  Py_XDECREF(temp); 
     280 
     281  temp = PyObject_GetAttrString(obj, "base_class"); 
     282  if (!temp) 
     283      temp = PyObject_GetAttrString(obj, "baseClass"); 
    278284  baseClass = temp ? PyInt_AsLong(temp) : -1; 
    279   Py_DECREF(temp); 
    280  
    281   temp = PyObject_GetAttrString(obj, "classValues"); 
     285  Py_XDECREF(temp); 
     286 
     287  temp = PyObject_GetAttrString(obj, "class_values"); 
     288  if (!temp) 
     289      temp = PyObject_GetAttrString(obj, "classValues"); 
    282290  if (!temp) 
    283291    throw CornException("no 'classValues' attribute"); 
  • source/orange/callback.cpp

    r6531 r7663  
    122122 
    123123PFilter TFilter_Python::deepCopy() const 
    124 { 
    125     PyObject *result = PyObject_CallMethod((PyObject *) myWrapper, "deepCopy", 
     124{    
     125    PyObject *result = PyObject_CallMethod((PyObject *) myWrapper, 
     126            PyObject_HasAttrString((PyObject *)myWrapper, "deep_copy") ? "deep_copy" : "deepCopy", 
    126127            NULL); 
    127128    if (!result) 
     
    237238    PyObject *args = Py_BuildValue("NNNi", WrapOrange(var), WrapOrange(gen), 
    238239            WrapOrange(apriorClass), weightID); 
    239     PyObject *pyres = callMethod("thresholdFunction", (PyObject *) myWrapper, 
    240             args); 
     240    PyObject *pyres = callMethod( 
     241        PyObject_HasAttrString((PyObject *)myWrapper, "threshold_function") ? "threshold_function" : "thresholdFunction", 
     242        (PyObject *) myWrapper, 
     243        args); 
    241244    Py_DECREF(args); 
    242245 
  • source/orange/cls_example.cpp

    r7654 r7663  
    194194bool readBoolFlag(PyObject *keywords, char *flag); 
    195195 
    196 CONSTRUCTOR_KEYWORDS(Example, "filterMetas") 
     196CONSTRUCTOR_KEYWORDS(Example, "filterMetas filter_metas") 
    197197 
    198198 
     
    204204    if (PyArg_ParseTuple(args, "O&|O", cc_Domain, &dom, &list)) { 
    205205      if (list && PyOrExample_Check(list)) { 
    206         PExample ex = mlnew TExample(dom, PyExample_AS_Example(list).getReference(), readBoolFlag(keywords, "filterMetas")); 
     206        PExample ex = mlnew TExample(dom, PyExample_AS_Example(list).getReference(), readBoolFlag(keywords, "filterMetas") || readBoolFlag(keywords, "filter_metas")); 
    207207        return Example_FromWrappedExample(ex); 
    208208      } 
     
    801801 
    802802 
    803 PyObject *Example_native(TPyExample *pex, PyObject *args, PyObject *keyws) PYARGS(METH_VARARGS | METH_KEYWORDS, "([nativity, tuple=, substituteDC=, substituteDK=, substituteOther=])  -> list; Converts an example to a list") 
     803PyObject *Example_native(TPyExample *pex, PyObject *args, PyObject *keyws) PYARGS(METH_VARARGS | METH_KEYWORDS, "([nativity, tuple=, substitute_DC=, substitute_DK=, substitute_Other=])  -> list; Converts an example to a list") 
    804804{ PyTRY 
    805805    int natvt=1; 
     
    811811    tuples = pytuples && (PyObject_IsTrue(pytuples) != 0); 
    812812 
    813     PyObject *forDC = keyws ? PyDict_GetItemString(keyws, "substituteDC") : PYNULL; 
    814     PyObject *forDK = keyws ? PyDict_GetItemString(keyws, "substituteDK") : PYNULL; 
    815     PyObject *forSpecial = keyws ? PyDict_GetItemString(keyws, "substituteOther") : PYNULL; 
    816  
     813    PyObject *forDC = NULL, *forDK = NULL, *forSpecial = NULL; 
     814    if (keyws) { 
     815        forDC = PyDict_GetItemString(keyws, "substitute_DC"); 
     816        if (!forDC) { 
     817            forDC = PyDict_GetItemString(keyws, "substituteDC"); 
     818        } 
     819        forDC = PyDict_GetItemString(keyws, "substitute_DK"); 
     820        if (!forDC) { 
     821            forDC = PyDict_GetItemString(keyws, "substituteDK"); 
     822        } 
     823        forDC = PyDict_GetItemString(keyws, "substitute_other"); 
     824        if (!forDC) { 
     825            forDC = PyDict_GetItemString(keyws, "substituteOther"); 
     826        } 
     827    } 
    817828    return convertToPythonNative(PyExample_AS_ExampleReference(pex), natvt, tuples, forDK, forDC, forSpecial); 
    818829  PyCATCH 
  • source/orange/domain.cpp

    r6531 r7663  
    125125void TDomain::afterSet(const char *name) 
    126126{  
    127   if (!strcmp(name, "classVar")) { 
     127  if (!strcmp(name, "class_var")  
     128      || !strcmp(name, "classVar")) { 
    128129    if (attributes->size()==variables->size()) 
    129130      variables->push_back(classVar); 
  • source/orange/domaindepot.cpp

    r6678 r7663  
    355355  if (!PyObject_TypeCheck(var, (PyTypeObject *)&PyOrVariable_Type)) { 
    356356    Py_DECREF(var); 
    357     ::raiseErrorWho("makeVariable", "PythonVariable's constructor is expected to return a 'PythonVariable', not '%s'", var->ob_type->tp_name); 
     357    ::raiseErrorWho("make_variable", "PythonVariable's constructor is expected to return a 'PythonVariable', not '%s'", var->ob_type->tp_name); 
    358358  } 
    359359 
     
    383383 
    384384    if (!var) 
    385       ::raiseErrorWho("makeVariable", "unknown type for attribute '%s'", desc.name.c_str()); 
     385      ::raiseErrorWho("make_variable", "unknown type for attribute '%s'", desc.name.c_str()); 
    386386  } 
    387387   
  • source/orange/lib_components.cpp

    r7654 r7663  
    11681168 
    11691169 
    1170 CONSTRUCTOR_KEYWORDS(DomainContingency, "classIsOuter") 
     1170CONSTRUCTOR_KEYWORDS(DomainContingency, "classIsOuter class_is_outer") 
    11711171 
    11721172PyObject *DomainContingency_new(PyTypeObject *type, PyObject *args, PyObject *keywds) BASED_ON(Orange, "(examples [, weightID] | <list of Contingency>) -> DomainContingency") ALLOWS_EMPTY 
     
    11801180    bool classOuter = false; 
    11811181    if (keywds) { 
    1182         PyObject *couter = PyDict_GetItemString(keywds, "classIsOuter"); 
     1182        PyObject *couter = PyDict_GetItemString(keywds, "class_is_outer"); 
     1183        if (!couter) { 
     1184            couter = PyDict_GetItemString(keywds, "classIsOuter"); 
     1185        } 
    11831186        if (couter) { 
    11841187            classOuter = (PyObject_IsTrue(couter) != 0); 
     
    42604263{ 
    42614264    PyObject *dict = ((TPyOrange *)graph)->orange_dict; 
    4262     PyObject *ooe = dict ? PyDict_GetItemString(dict, "objectsOnEdges") : PYNULL; 
     4265    PyObject *ooe = NULL; 
     4266    if (dict) { 
     4267        ooe = PyDict_GetItemString(dict, "objects_on_edges"); 
     4268        if (!ooe) { 
     4269            ooe = PyDict_GetItemString(dict, "objectsOnEdges"); 
     4270        } 
     4271    } 
    42634272    return ooe && (PyObject_IsTrue(ooe) != 0); 
    42644273} 
     
    42674276{ 
    42684277    PyObject *dict = graph->myWrapper->orange_dict; 
    4269     PyObject *ooe = dict ? PyDict_GetItemString(dict, "objectsOnEdges") : NULL; 
     4278    PyObject *ooe = NULL; 
     4279    if (dict) { 
     4280        ooe = PyDict_GetItemString(dict, "objects_on_edges"); 
     4281        if (!ooe) { 
     4282            ooe = PyDict_GetItemString(dict, "objectsOnEdges"); 
     4283        } 
     4284    } 
    42704285    return ooe && (PyObject_IsTrue(ooe) != 0); 
    42714286} 
     
    42744289{ 
    42754290    PyObject *dict = graph->myWrapper->orange_dict; 
    4276     PyObject *ooe = dict ? PyDict_GetItemString(dict, "objectsOnEdges") : NULL; 
     4291    PyObject *ooe = NULL; 
     4292    if (dict) { 
     4293        ooe = PyDict_GetItemString(dict, "objects_on_edges"); 
     4294        if (!ooe) { 
     4295            ooe = PyDict_GetItemString(dict, "objectsOnEdges"); 
     4296        } 
     4297    } 
    42774298    return ooe && (PyObject_IsTrue(ooe) != 0); 
    42784299} 
     
    43084329 
    43094330ABSTRACT(Graph, Orange) 
    4310 RECOGNIZED_ATTRIBUTES(Graph, "objects forceMapping returnIndices objectsOnEdges") 
     4331RECOGNIZED_ATTRIBUTES(Graph, "objects forceMapping force_mapping returnIndices return_indices objectsOnEdges object_on_edges") 
    43114332 
    43124333int Graph_getindex(TGraph *graph, PyObject *index) 
     
    43154336        if (!graph->myWrapper->orange_dict) 
    43164337            return PyInt_AsLong(index); 
    4317         PyObject *fmap = PyDict_GetItemString(graph->myWrapper->orange_dict, "forceMapping"); 
     4338        PyObject *fmap = PyDict_GetItemString(graph->myWrapper->orange_dict, "force_mapping"); 
     4339        if (!fmap) { 
     4340            fmap = PyDict_GetItemString(graph->myWrapper->orange_dict, "forceMapping"); 
     4341        } 
    43184342        if (!fmap || PyObject_IsTrue(fmap)) 
    43194343            return PyInt_AsLong(index); 
  • source/orange/lib_io.cpp

    r6592 r7663  
    243243 
    244244 
    245 PyObject *saveTabDelimited(PyObject *, PyObject *args, PyObject *keyws) PYARGS(METH_VARARGS | METH_KEYWORDS, "(filename, examples[, listDiscreteValues=1]) -> None") 
     245PyObject *saveTabDelimited(PyObject *, PyObject *args, PyObject *keyws) PYARGS(METH_VARARGS | METH_KEYWORDS, "(filename, examples[, list_discrete_values=1]) -> None") 
    246246{ 
    247247  bool listDiscrete = true; 
    248248 
    249249  if (keyws) { 
    250     PyObject *ldv = PyDict_GetItemString(keyws, "listDiscreteValues"); 
     250    PyObject *ldv = PyDict_GetItemString(keyws, "list_discrete_values"); 
     251    if (!ldv) { 
     252        ldv = PyDict_GetItemString(keyws, "listDiscreteValues"); 
     253    } 
    251254    listDiscrete = !ldv || (PyObject_IsTrue(ldv)!=0); 
    252255  } 
  • source/orange/lib_kernel.cpp

    r7654 r7663  
    19481948      Py_INCREF(pygen); 
    19491949 
    1950       if (PyTuple_Size(res) >= 2) 
     1950      if (PyTuple_Size(res) >= 2) { 
    19511951        Orange_setattrDictionary((TPyOrange *)pygen, "attributeLoadStatus", PyTuple_GET_ITEM(res, 1), false); 
    1952       if (PyTuple_Size(res) >= 3) 
     1952        Orange_setattrDictionary((TPyOrange *)pygen, "attribute_load_status", PyTuple_GET_ITEM(res, 1), false); 
     1953      } 
     1954      if (PyTuple_Size(res) >= 3) { 
    19531955        Orange_setattrDictionary((TPyOrange *)pygen, "metaAttributeLoadStatus", PyTuple_GET_ITEM(res, 2), false); 
     1956        Orange_setattrDictionary((TPyOrange *)pygen, "meta_attribute_load_status", PyTuple_GET_ITEM(res, 2), false); 
     1957      } 
    19541958      return pygen; 
    19551959    } 
     
    22002204      tuples = pytuples && (PyObject_IsTrue(pytuples) != 0); 
    22012205 
    2202       forDC = PyDict_GetItemString(keyws, "substituteDC"); 
    2203       forDK = PyDict_GetItemString(keyws, "substituteDK"); 
    2204       forSpecial = PyDict_GetItemString(keyws, "substituteOther"); 
     2206      forDC = PyDict_GetItemString(keyws, "substitute_DC"); 
     2207      if (!forDC) { 
     2208          forDC = PyDict_GetItemString(keyws, "substituteDC"); 
     2209      } 
     2210      forDC = PyDict_GetItemString(keyws, "substitute_DK"); 
     2211      if (!forDC) { 
     2212          forDC = PyDict_GetItemString(keyws, "substituteDK"); 
     2213      } 
     2214      forDC = PyDict_GetItemString(keyws, "substitute_other"); 
     2215      if (!forDC) { 
     2216          forDC = PyDict_GetItemString(keyws, "substituteOther"); 
     2217      } 
    22052218    } 
    22062219 
     
    28962909 
    28972910 
    2898 CONSTRUCTOR_KEYWORDS(ExampleTable, "domain use useMetas dontCheckStored dontStore filterMetas DC DK NA noClass noCodedDiscrete createNewOn") 
     2911CONSTRUCTOR_KEYWORDS(ExampleTable, "domain use useMetas dontCheckStored dontStore filterMetas filter_metas DC DK NA noClass noCodedDiscrete createNewOn") 
    28992912 
    29002913PyObject *ExampleTable_new(PyTypeObject *type, PyObject *argstuple, PyObject *keywords) BASED_ON(ExampleGenerator, "(filename | domain[, examples] | examples)") 
     
    29492962    PDomain domain; 
    29502963    if (PyArg_ParseTuple(argstuple, "O&O", cc_Domain, &domain, &args)) { 
    2951       bool filterMetas = readBoolFlag(keywords, "filterMetas"); 
     2964      bool filterMetas = readBoolFlag(keywords, "filterMetas") || readBoolFlag(keywords, "filter_metas"); 
    29522965 
    29532966      if (PyOrExampleGenerator_Check(args)) 
  • source/orange/lookup.cpp

    r6531 r7663  
    984984void TClassifierByExampleTable::afterSet(const char *name) 
    985985{ 
    986   if (!strcmp(name, "sortedExamples")) { 
     986  if (   !strcmp(name, "sortedExamples") 
     987      || !strcmp(name, "sorted_examples")) { 
    987988    domain = sortedExamples->domain;  
    988989    classVar = sortedExamples->domain->classVar; 
Note: See TracChangeset for help on using the changeset viewer.