Aleš Erjavec avatar Aleš Erjavec committed 8c7bac6

Added a __new__ constructor for CostWrapperClassifier.

It was not possible to construct an instance of CostWrapperClassifier through
the default constructor..

Comments (0)

Files changed (3)

source/orange/costwrapper.cpp

 
 
 TCostWrapperClassifier::TCostWrapperClassifier(PCostMatrix cm, PClassifier bc)
-: TClassifier(bc->classVar, false),
+: TClassifier((bc? bc->classVar: PVariable()), false),
   classifier(bc),
   costMatrix(cm)
 {}

source/orange/costwrapper.hpp

 public:
   __REGISTER_CLASS
 
-  PLearner basicLearner; //P basic learner
+  PLearner basicLearner; //P(+base_learner) basic learner
   PCostMatrix costMatrix; //P cost matrix
 
   TCostWrapperLearner(PCostMatrix =PCostMatrix(), PLearner = PLearner());

source/orange/lib_learner.cpp

 
 
 #include "costwrapper.hpp"
-C_CALL(CostWrapperLearner - Orange.wrappers.CostWrapperLearner, Learner, "([examples] [, weight=, costs=]) -/-> Classifier")
-C_NAMED(CostWrapperClassifier - Orange.wrappers.CostWrapperClassifier, Classifier, "([classifier=, costs=])")
-
+C_CALL(CostWrapperLearner - Orange.wrappers.CostWrapperLearner, Learner, "([examples] [, weight=, cost_matrix=]) -/-> Classifier")
+C_NAMED(CostWrapperClassifier - Orange.wrappers.CostWrapperClassifier, Classifier, "(classifier, cost_matrix)")
+
+
+PyObject *CostWrapperClassifier_new(PyTypeObject *type, PyObject *args)
+{
+  PyTRY
+    PClassifier classifier;
+    PCostMatrix costMatrix;
+    if (!PyArg_ParseTuple(args, "O&O&:CostWrapperClassifier.__new__", cc_Classifier, &classifier, cc_CostMatrix, &costMatrix)) {
+        raiseError("A Classifier and CostMatrix expected.");
+    }
+    return WrapNewOrange(mlnew TCostWrapperClassifier(costMatrix, classifier), type);
+  PyCATCH
+}
 
 /************* ASSOCIATION RULES ************/
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.