Orange defines three warning classes: orange.Warning
is the base class, derived from it are orange.KernelWarning
and orange.AttributeWarning
.
You will most often see the latter, which is issued by Orange-Python interface code when you set an attribute that didn't exist before; to it we shall dedicate a special section.
The other warning orange.KernelWarning
is issued by Orange kernel in various situations.
Python has a mechanism of filters that allows you to decide what to do with warnings. Warnings can be either ignored completely, they can be reported the first time they occur, they can be reported always, or even treated as errors. Treatment of a particular warning can be specific for module, warning class and warning description. Read more about it in Python documentation on module warnings
.
Python allows to add attributes to class instances. This is a perfectly legal Python code that adds the attribute test
to an instance of class A
.
Such attributes can be quite useful, so Orange supports them as well (with exception of classes Example
and Value
, which are not derived from Orange
). It is therefore OK to, for instance, store the number of misclassified examples to each leaf of decision tree to a new attribute, or add a comment to naive Bayesian learner:
This is, however, somewhat dangerous. Say that you want to set the method for estimation of conditional probabilities.
It's a long line, so it's no wonder that we mistyped it:
conditionalEstimatorConstructor
misses an "o". But Orange thinks you wanted to assign a new attribute conditionalEstimatrConstructor
to bl
. conditionalEstimatorConstructor
does not change, although the programmer thinks it has!
The solution is to give warnings: you are free to set new attributes, such as comment
(or conditionalEstimatrConstructor
), but you'll get a warning the first time that certain attribute is set at certain place. Exception to this are modules whose name begin with orng
. You can also disable the warnings in your code, if you dare: