source: orange/Orange/__init__.py @ 10224:c7b1721e5a2e

Revision 10224:c7b1721e5a2e, 3.0 KB checked in by Janez Demšar <janez.demsar@…>, 2 years ago (diff)

Nicer warning messages in Orange.init

Line 
1import orange
2
3# Definitely ugly, but I see no other workaround.
4# When, e.g. data.io executes "from orange import ExampleTable"
5# orange gets imported again since it is not in sys.modules
6# before this entire file is executed
7import sys
8sys.modules["orange"] = orange
9
10import warnings
11
12alreadyWarned = False
13disabledMsg = "Some features will be disabled due to failing modules\n"
14def _import(name):
15    global alreadyWarned
16    try:
17        __import__(name, globals(), locals(), [], -1)
18    except Exception as err:
19        warnings.warn("%sImporting '%s' failed: %s" % 
20            (disabledMsg if not alreadyWarned else "", name, err),
21            UserWarning, 2)
22        alreadyWarned = True
23
24_import("misc")
25_import("data")
26_import("data.io")
27_import("data.sample")
28_import("data.outliers")
29_import("data.utils")
30_import("data.discretization")
31_import("data.continuization")
32_import("data.filter")
33_import("data.imputation")
34
35_import("feature")
36_import("feature.construction")
37_import("feature.construction.functionDecomposition")
38_import("feature.construction.univariate")
39_import("feature.discretization")
40_import("feature.imputation")
41_import("feature.scoring")
42_import("feature.selection")
43
44_import("network")
45
46_import("stat")
47
48_import("statistics")
49_import("statistics.estimate")
50_import("statistics.contingency")
51_import("statistics.distribution")
52_import("statistics.basic")
53_import("statistics.evd")
54
55_import("classification")
56_import("classification.tree")
57
58_import("classification.rules")
59
60_import("classification.lookup")
61_import("classification.bayes")
62_import("classification.svm")
63_import("classification.logreg")
64_import("classification.knn")
65_import("classification.majority")
66
67_import("optimization")
68
69_import("projection")
70_import("projection.linear")
71_import("projection.mds")
72_import("projection.som")
73_import("projection.pca")
74
75_import("ensemble")
76_import("ensemble.bagging")
77_import("ensemble.boosting")
78_import("ensemble.forest")
79
80_import("regression")
81_import("regression.base")
82_import("regression.earth")
83_import("regression.lasso")
84_import("regression.linear")
85_import("regression.mean")
86_import("regression.pls")
87_import("regression.tree")
88
89_import("multitarget")
90_import("multitarget.tree")
91
92_import("multilabel")
93_import("multilabel.multibase")
94_import("multilabel.br")
95_import("multilabel.lp")
96_import("multilabel.mlknn")
97_import("multilabel.brknn")
98_import("multilabel.mulan")
99
100_import("associate")
101
102_import("preprocess")
103_import("preprocess.scaling")
104
105_import("distance")
106
107_import("wrappers")
108
109_import("featureConstruction")
110_import("featureConstruction.univariate")
111_import("featureConstruction.functionDecomposition")
112
113_import("evaluation")
114_import("evaluation.scoring")
115_import("evaluation.testing")
116_import("evaluation.reliability")
117
118_import("clustering")
119_import("clustering.kmeans")
120_import("clustering.hierarchical")
121_import("clustering.consensus")
122
123_import("misc")
124_import("misc.environ")
125_import("misc.counters")
126_import("misc.addons")
127_import("misc.render")
128_import("misc.selection")
129_import("misc.serverfiles")
130#_import("misc.r")
Note: See TracBrowser for help on using the repository browser.