source: orange/orange/fixes/fix_changed_names.py @ 7740:77eb0ab3a879

Revision 7740:77eb0ab3a879, 35.5 KB checked in by lanz <lan.zagar@…>, 3 years ago (diff)

Changed function names to lower_case_with_underscores.

Line 
1""" This fixer changes all occurrences of the form 'module.member' from the
2global dictionary MAPPING's keys and replaces them with the corresponding
3value. It adds the proper imports to make it available in the script
4
5For example this code::
6    import orange
7    import orngSVM
8    data = orange.ExampleTable("iris")
9    learner = orngSVM.SVMLearner(name='svm')
10   
11will be replaced with::
12    import Orange.data
13    import Orange.classification.svm
14    data =Orange.data.Table('iris')
15    learner =Orange.classification.svm.SVMLearner(name='svm')
16   
17Try to add as much name mappings as possible (This fixer is prefered
18(and will run before) the fix_orange_imports 
19   
20"""
21from lib2to3 import fixer_base
22from lib2to3 import fixer_util
23from lib2to3 import pytree
24from lib2to3.fixer_util import Name, Dot, Node, attr_chain, touch_import
25
26# keys must be in the form of 'orange.name' not name or orange.bla.name
27MAPPING = {"orange.ExampleTable": "Orange.data.Table",
28           "orange.Example": "Orange.data.Instance",
29           "orange.Domain": "Orange.data.Domain",
30           "orange.Value": "Orange.data.Value",
31           "orange.VarTypes": "Orange.data.Type",
32           "orange.Variable": "Orange.data.variable.Variable",
33           "orange.EnumVariable": "Orange.data.variable.Discrete",
34           "orange.FloatVariable": "Orange.data.variable.Continuous",
35           "orange.StringVariable": "Orange.data.variable.String",
36           "orange.PythonVariable": "Orange.data.variable.Python",
37           "orange.VarList": "Orange.data.variable.Variables",
38           
39           "orange.Distribution": "Orange.statistics.distribution.Distribution",
40           "orange.DiscDistribution": "Orange.statistics.distribution.Discrete",
41           "orange.ContDistribution": "Orange.statistics.distribution.Continuous",
42           "orange.GaussianDistribution": "Orange.statistics.distribution.Gaussian",
43           "orange.DomainDistributions": "Orange.statistics.distribution.Domain",
44           
45           "orange.BasicAttrStat": "Orange.statistics.basic.Variable",
46           "orange.DomainBasicAttrStat": "Orange.statistics.basic.Domain",
47           
48           "orange.ContingencyAttrAttr": "Orange.statistics.contingency.VarVar",
49           "orange.ContingencyClass": "Orange.statistics.contingency.Class",
50           "orange.ContingencyAttrClass": "Orange.statistics.contingency.VarClass",
51           "orange.ContingencyClassAttr": "Orange.statistics.contingency.ClassVar",
52           "orange.DomainContingency": "Orange.statistics.contingency.Domain",
53         
54           "orange.MeasureAttribute": "Orange.feature.scoring.Measure", 
55           "orange.MeasureAttribute_gainRatio": "Orange.feature.scoring.GainRatio",
56           "orange.MeasureAttribute_relief": "Orange.feature.scoring.Relief",
57           "orange.MeasureAttribute_info": "Orange.feature.scoring.InfoGain",
58           "orange.MeasureAttribute_gini": "Orange.feature.scoring.Gini",
59
60           "orange.MeasureAttribute_relevance": "Orange.feature.scoring.Relevance",
61           "orange.MeasureAttribute_cost": "Orange.feature.scoring.Cost",
62           "orange.MeasureAttribute_MSE": "Orange.feature.scoring.MSE",
63
64           "orngFSS.attMeasure": "Orange.feature.scoring.attMeasure",
65           "orngFSS.bestNAtts": "Orange.feature.selection.bestNAtts",
66           "orngFSS.attsAbovethreshold": "Orange.feature.selection.attsAbovethreshold",
67           "orngFSS.selectBestNAtts": "Orange.feature.selection.selectBestNAtts",
68           "orngFSS.selectAttsAboveThresh": "Orange.feature.selection.selectAttsAboveThresh",
69           "orngFSS.filterRelieff": "Orange.feature.selection.filterRelieff",
70           "orngFSS.FilterAttsAboveThresh": "Orange.feature.selection.FilterAttsAboveThresh",
71           "orngFSS.FilterAttsAboveThresh_Class": "Orange.feature.selection.FilterAttsAboveThresh_Class",
72           "orngFSS.FilterBestNAtts": "Orange.feature.selection.FilterBestNAtts",
73           "orngFSS.FilterBestNAtts_Class": "Orange.feature.selection.FilterBestNAtts_Class",
74           "orngFSS.FilterRelief": "Orange.feature.selection.FilterRelief",
75           "orngFSS.FilterRelief_Class": "Orange.feature.selection.FilterRelief_Class",
76           "orngFSS.FilteredLearner": "Orange.feature.selection.FilteredLearner",
77           "orngFSS.FilteredLearner_Class": "Orange.feature.selection.FilteredLearner_Class",
78           "orngFSS.FilteredClassifier": "Orange.feature.selection.FilteredClassifier",
79           "orngFSS.StepwiseLearner_Class": "Orange.classification.wrappers.StepwiseLearner",
80           "orngFSS.StepwiseLearner": "Orange.classification.wrappers.StepwiseLearner",
81           
82           "orange.ImputerConstructor_model": "Orange.feature.imputation.ImputerConstructor_model",
83           "orange.Imputer_model": "Orange.feature.imputation.Imputer_model",
84           "orange.Imputer_defaults": "Orange.feature.imputation.Imputer_defaults",
85           "orange.ImputerConstructor_asValue": "Orange.feature.imputation.ImputerConstructor_asValue",
86           "orange.ImputerConstructor_minimal": "Orange.feature.imputation.ImputerConstructor_minimal", 
87           "orange.ImputerConstructor_maximal": "Orange.feature.imputation.ImputerConstructor_maximal",
88           "orange.ImputerConstructor_average": "Orange.feature.imputation.ImputerConstructor_average",
89 
90           "orange.ExamplesDistance_Normalized": "Orange.distances.ExamplesDistance_Normalized",
91           "orange.ExamplesDistanceConstructor": "Orange.distances.ExamplesDistanceConstructor",
92           "orange.ExamplesDistance_Hamming": "Orange.distances.Hamming",
93           "orange.ExamplesDistance_DTW": "Orange.distances.DTW", 
94           "orange.ExamplesDistance_Euclidean": "Orange.distances.Euclidean", 
95           "orange.ExamplesDistance_Manhattan": "Orange.distances.Manhattan", 
96           "orange.ExamplesDistance_Maximal": "Orange.distances.Maximal", 
97           "orange.ExamplesDistance_Relief": "Orange.distances.Relief", 
98           
99           "orange.ExamplesDistanceConstructor_DTW": "Orange.distances.DTWConstructor", 
100           "orange.ExamplesDistanceConstructor_Euclidean": "Orange.distances.EuclideanConstructor", 
101           "orange.ExamplesDistanceConstructor_Hamming": "Orange.distances.HammingConstructor",
102           "orange.ExamplesDistanceConstructor_Manhattan": "Orange.distances.ManhattanConstructor",
103           "orange.ExamplesDistanceConstructor_Maximal": "Orange.distances.MaximalConstructor",
104           "orange.ExamplesDistanceConstructor_Relief": "Orange.distances.ReliefConstructor",
105           
106           "orngClustering.ExamplesDistanceConstructor_PearsonR": "Orange.distances.PearsonRConstructor",
107           "orngClustering.ExamplesDistance_PearsonR": "Orange.distances.PearsonR",
108           "orngClustering.ExamplesDistanceConstructor_SpearmanR": "Orange.distances.SpearmanRConstructor",
109           "orngClustering.ExamplesDistance_SpearmanR": "Orange.distances.SpearmanR",
110           
111           "orngClustering.KMeans": "Orange.clustering.kmeans.Clustering",
112           "orngClustering.kmeans_init_random": "Orange.clustering.kmeans.init_random",
113           "orngClustering.kmeans_init_diversity": "Orange.clustering.kmeans.init_diversity",
114           "orngClustering.KMeans_init_hierarchicalClustering": "Orange.clustering.kmeans.init_hclustering",
115           "orngClustering.data_center": "Orange.clustering.kmeans.data_center",
116           "orngClustering.plot_silhouette": "Orange.clustering.kmeans.plot_silhouette",
117           "orngClustering.score_distance_to_centroids": "Orange.clustering.kmeans.score_distance_to_centroids",
118           "orngClustering.score_silhouette": "Orange.clustering.kmeans.score_silhouette",
119           
120           "orange.HierarchicalClustering": "Orange.clustering.hierarchical.HierarchicalClustering",
121           "orngClustering.hierarchicalClustering": "Orange.clustering.hierarchical.clustering",
122           "orngClustering.hierarchicalClustering_attributes": "Orange.clustering.hierarchical.clustering_features",
123           "orngClustering.hierarchicalClustering_clusterList": "Orange.clustering.hierarchical.cluster_to_list",
124           "orngClustering.hierarchicalClustering_topClusters": "Orange.clustering.hierarchical.top_clusters",
125           "orngClustering.hierarhicalClustering_topClustersMembership": "Orange.clustering.hierarchical.top_cluster_membership",
126           "orngClustering.orderLeaves": "Orange.clustering.hierarchical.order_leaves",
127           
128           "orngSVM.RBFKernelWrapper": "Orange.classification.svm.kernels.RBFKernelWrapper",
129           "orngSVM.CompositeKernelWrapper": "Orange.classification.svm.kernels.CompositeKernelWrapper",
130           "orngSVM.KernelWrapper": "Orange.classification.svm.kernels.KernelWrapper",
131           "orngSVM.DualKernelWrapper": "Orange.classification.svm.kernels.DualKernelWrapper",
132           "orngSVM.PolyKernelWrapper": "Orange.classification.svm.kernels.PolyKernelWrapper",
133           "orngSVM.AdditionKernelWrapper": "Orange.classification.svm.kernels.AdditionKernelWrapper",
134           "orngSVM.MultiplicationKernelWrapper": "Orange.classification.svm.kernels.MultiplicationKernelWrapper",
135           "orngSVM.SparseLinKernel": "Orange.classification.svm.kernels.SparseLinKernel",
136           "orngSVM.BagOfWords": "Orange.classification.svm.kernels.BagOfWords",
137           
138           "orange.kNNLearner":"Orange.classification.knn.kNNLearner",
139           "orange.kNNClassifier":"Orange.classification.knn.kNNClassifier",
140           "orange.FindNearest_BruteForce":"Orange.classification.knn.FindNearest",
141           "orange.FindNearestConstructor_BruteForce":"Orange.classification.knn.FindNearestConstructor",
142           "orange.P2NN":"Orange.classification.knn.P2NN",
143           
144           "orange.BayesLearner":"Orange.classification.bayes.NaiveLearner",
145           "orange.BayesClassifier":"Orange.classification.bayes.NaiveClassifier",
146           "orngBayes.BayesLearner":"Orange.classification.bayes.NaiveLearner",
147           "orngBayes.BayesClassifier":"Orange.classification.bayes.NaiveClassifier",
148           "orngBayes.printModel": "Orange.classification.bayes.printModel",
149           
150           "orngNetwork.MdsTypeClass":"Orange.network.MdsTypeClass",
151           "orngNetwork.Network":"Orange.network.Network",
152           "orngNetwork.NetworkOptimization":"Orange.network.NetworkOptimization",
153           "orngNetwork.NetworkClustering":"Orange.network.NetworkClustering",
154           "orange.Graph":"Orange.network.Graph",
155           "orange.GraphAsList":"Orange.network.GraphAsList",
156           "orange.GraphAsMatrix":"Orange.network.GraphAsMatrix",
157           "orange.GraphAsTree":"Orange.network.GraphAsTree",
158           
159           "orngEnsemble.MeasureAttribute_randomForests":"Orange.ensemble.forest.ScoreFeature",
160           
161           "orange.TreeLearner": "Orange.classification.tree.TreeLearner",
162           "orange.TreeClassifier": "Orange.classification.tree.TreeClassifier",
163           "orange.C45Learner": "Orange.classification.tree.C45Learner",
164           "orange.C45Classifier": "Orange.classification.tree.C45Classifier",
165           "orange.C45TreeNode": "Orange.classification.tree.C45Node",
166           "orange.C45TreeNodeList": "C45NodeList",
167           "orange.TreeDescender": "Orange.classification.tree.Descender",
168           "orange.TreeDescender_UnknownMergeAsBranchSizes": "Orange.classification.tree.Descender_UnknownMergeAsBranchSizes",
169           "orange.TreeDescender_UnknownMergeAsSelector": "Orange.classification.tree.Descender_UnknownMergeAsSelector",
170           "orange.TreeDescender_UnknownToBranch": "Orange.classification.tree.Descender_UnknownToBranch",
171           "orange.TreeDescender_UnknownToCommonBranch": "Orange.classification.tree.Descender_UnknownToCommonBranch",
172           "orange.TreeDescender_UnknownToCommonSelector":"Orange.classification.tree.Descender_UnknownToCommonSelector",
173           "orange.TreeExampleSplitter":"Orange.classification.tree.Splitter",
174           "orange.TreeExampleSplitter_IgnoreUnknowns":"Orange.classification.tree.Splitter_IgnoreUnknowns",
175           "orange.TreeExampleSplitter_UnknownsAsBranchSizes":"Orange.classification.tree.Splitter_UnknownsAsBranchSizes",
176           "orange.TreeExampleSplitter_UnknownsAsSelecto":"Orange.classification.tree.Splitter_UnknownsAsSelector",
177           "orange.TreeExampleSplitter_UnknownsToAll":"Orange.classification.tree.Splitter_UnknownsToAll",
178           "orange.TreeExampleSplitter_UnknownsToBranch":"Orange.classification.tree.Splitter_UnknownsToBranch",
179           "orange.TreeExampleSplitter_UnknownsToCommon":"Orange.classification.tree.Splitter_UnknownsToCommon",
180           "orange.TreeExampleSplitter_UnknownsToRandom":"Orange.classification.tree.Splitter_UnknownsToRandom",
181           "orange.TreeNode":"Orange.classification.tree.Node",
182           "orange.TreeNodeList":"Orange.classification.tree.NodeList",
183           "orange.TreePruner":"Orange.classification.tree.Pruner",
184           "orange.TreePruner_SameMajority":"Orange.classification.tree.Pruner_SameMajority",
185           "orange.TreePruner_m":"Orange.classification.tree.Pruner_m",
186           "orange.TreeSplitConstructor":"Orange.classification.tree.SplitConstructor",
187           "orange.TreeSplitConstructor_Combined":"Orange.classification.tree.SplitConstructor_Combined",
188           "orange.TreeSplitConstructor_Measure":"Orange.classification.tree.SplitConstructor_Measure",
189           "orange.TreeSplitConstructor_Attribute":"Orange.classification.tree.SplitConstructor_Feature",
190           "orange.TreeSplitConstructor_ExhaustiveBinary":"Orange.classification.tree.SplitConstructor_ExhaustiveBinary",
191           "orange.TreeSplitConstructor_OneAgainstOthers":"Orange.classification.tree.SplitConstructor_OneAgainstOthers",
192           "orange.TreeSplitConstructor_Threshold":"Orange.classification.tree.SplitConstructor_Threshold",
193           "orange.TreeStopCriteria":"Orange.classification.tree.StopCriteria",
194           "orange.TreeStopCriteria_Python":"Orange.classification.tree.StopCriteria_Python",
195           "orange.TreeStopCriteria_common":"Orange.classification.tree.StopCriteria_common",
196           
197           "orange.MajorityLearner":"Orange.classification.majority.MajorityLearner",
198           "orange.DefaultClassifier":"Orange.classification.ConstantClassifier",
199           
200           "orange.LookupLearner":"Orange.classification.lookup.LookupLearner",
201           "orange.ClassifierByLookupTable":"Orange.classification.lookup.ClassifierByLookupTable",
202           "orange.ClassifierByLookupTable1":"Orange.classification.lookup.ClassifierByLookupTable1",
203           "orange.ClassifierByLookupTable2":"Orange.classification.lookup.ClassifierByLookupTable2",
204           "orange.ClassifierByLookupTable3":"Orange.classification.lookup.ClassifierByLookupTable3",
205           "orange.ClassifierByExampleTable":"Orange.classification.lookup.ClassifierByDataTable",
206
207           "orngLookup.lookupFromBound":"Orange.classification.lookup.lookup_from_bound",
208           "orngLookup.lookupFromExamples":"Orange.classification.lookup.lookup_from_data",
209           "orngLookup.lookupFromFunction":"Orange.classification.lookup.lookup_from_function",
210           "orngLookup.printLookupFunction":"Orange.classification.lookup.dump_lookup_function",
211           
212           "orange.AssociationRule" : "Orange.associate.AssociationRule",
213           "orange.AssociationRules" : "Orange.associate.AssociationRules",
214           "orange.AssociationRulesInducer" : "Orange.associate.AssociationRulesInducer",
215           "orange.AssociationRulesSparseInducer" : "Orange.associate.AssociationRulesSparseInducer",
216           "orange.ItemsetNodeProxy" : "Orange.associate.ItemsetNodeProxy",
217           "orange.ItemsetsSparseInducer" : "Orange.associate.ItemsetsSparseInducer",
218
219           "orngCN2.ruleToString": "Orange.classification.rules.ruleToString",
220           "orngCN2.LaplaceEvaluator": "Orange.classification.rules.LaplaceEvaluator",
221           "orngCN2.WRACCEvaluator": "Orange.classification.rules.WRACCEvaluator",
222           "orngCN2.mEstimate": "Orange.classification.rules.MEstimateEvaluator",
223           "orngCN2.RuleStopping_apriori": "Orange.classification.rules.RuleStopping_Apriori",
224           "orngCN2.LengthValidator": "Orange.classification.rules.LengthValidator",
225           "orngCN2.supervisedClassCheck": "Orange.classification.rules.supervisedClassCheck",
226           "orngCN2.CN2Learner": "Orange.classification.rules.CN2Learner",
227           "orngCN2.CN2Classifier": "Orange.classification.rules.CN2Classifier",
228           "orngCN2.CN2UnorderedLearner": "Orange.classification.rules.CN2UnorderedLearner",
229           "orngCN2.CN2UnorderedClassifier": "Orange.classification.rules.CN2UnorderedClassifier",
230           "orngCN2.RuleClassifier_bestRule": "Orange.classification.rules.RuleClassifier_BestRule",
231           "orngCN2.CovererAndRemover_multWeights": "Orange.classification.rules.CovererAndRemover_MultWeights",
232           "orngCN2.CovererAndRemover_addWeights": "Orange.classification.rules.CovererAndRemover_AddWeights",
233           "orngCN2.rule_in_set": "Orange.classification.rules.rule_in_set",
234           "orngCN2.rules_equal": "Orange.classification.rules.rules_equal",
235           "orngCN2.noDuplicates_validator": "Orange.classification.rules.NoDuplicatesValidator",
236           "orngCN2.ruleSt_setRules": "Orange.classification.rules.RuleStopping_SetRules",
237           "orngCN2.CN2SDUnorderedLearner": "Orange.classification.rules.CN2SDUnorderedLearner",
238#           "orngCN2.avg": "Orange.classification.rules.avg",
239#           "orngCN2.var": "Orange.classification.rules.var",
240#           "orngCN2.median": "Orange.classification.rules.median",
241#           "orngCN2.perc": "Orange.classification.rules.perc",
242           "orngCN2.createRandomDataSet": "Orange.classification.rules.createRandomDataSet",
243           "orngCN2.compParameters": "Orange.classification.rules.compParameters",
244           "orngCN2.computeDists": "Orange.classification.rules.computeDists",
245           "orngCN2.createEVDistList": "Orange.classification.rules.createEVDistList",
246           "orngCN2.CovererAndRemover_Prob": "Orange.classification.rules.CovererAndRemover_Prob",
247           "orngCN2.add_sub_rules": "Orange.classification.rules.add_sub_rules",
248           "orngCN2.CN2EVCUnorderedLearner": "Orange.classification.rules.CN2EVCUnorderedLearner",
249           
250           "orngMDS.KruskalStress": "Orange.projection.mds.KruskalStress",
251           "orngMDS.SammonStress": "Orange.projection.mds.SammonStress",
252           "orngMDS.SgnSammonStress": "Orange.projection.mds.SgnSammonStress",
253           "orngMDS.SgnRelStress": "Orange.projection.mds.SgnRelStress",
254           "orngMDS.PointList": "Orange.projection.mds.PointList",
255           "orngMDS.FloatListList": "Orange.projection.mds.FloatListList",
256           "orngMDS.PivotMDS": "Orange.projection.mds.PivotMDS",
257           "orngMDS.MDS": "Orange.projection.mds.MDS",
258           
259           "orngStat.AP" : "Orange.evaluation.scoring.AP",
260           "orngStat.AROC" : "Orange.evaluation.scoring.AROC",
261           "orngStat.AROCFromCDT" : "Orange.evaluation.scoring.AROCFromCDT",
262           "orngStat.AUC" : "Orange.evaluation.scoring.AUC",
263           "orngStat.AUCWilcoxon" : "Orange.evaluation.scoring.AUCWilcoxon",
264           "orngStat.AUC_binary" : "Orange.evaluation.scoring.AUC_binary",
265           "orngStat.AUC_i" : "Orange.evaluation.scoring.AUC_i",
266           "orngStat.AUC_ij" : "Orange.evaluation.scoring.AUC_ij",
267           "orngStat.AUC_iterations" : "Orange.evaluation.scoring.AUC_iterations",
268           "orngStat.AUC_matrix" : "Orange.evaluation.scoring.AUC_matrix",
269           "orngStat.AUC_multi" : "Orange.evaluation.scoring.AUC_multi",
270           "orngStat.AUC_pair" : "Orange.evaluation.scoring.AUC_pair",
271           "orngStat.AUC_single" : "Orange.evaluation.scoring.AUC_single",
272           "orngStat.AUC_x" : "Orange.evaluation.scoring.AUC_x",
273           "orngStat.BSS" : "Orange.evaluation.scoring.BSS",
274           "orngStat.BrierScore" : "Orange.evaluation.scoring.BrierScore",
275           "orngStat.CA" : "Orange.evaluation.scoring.CA",
276           "orngStat.CA_se" : "Orange.evaluation.scoring.CA_se",
277           "orngStat.CDT" : "Orange.evaluation.scoring.CDT",
278           "orngStat.ConfusionMatrix" : "Orange.evaluation.scoring.ConfusionMatrix",
279           "orngStat.F1" : "Orange.evaluation.scoring.F1",
280           "orngStat.Falpha" : "Orange.evaluation.scoring.Falpha",
281           "orngStat.Friedman" : "Orange.evaluation.scoring.Friedman",
282           "orngStat.IS" : "Orange.evaluation.scoring.IS",
283           "orngStat.IS_ex" : "Orange.evaluation.scoring.IS_ex",
284           "orngStat.MAE" : "Orange.evaluation.scoring.MAE",
285           "orngStat.MCC" : "Orange.evaluation.scoring.MCC",
286           "orngStat.ME" : "Orange.evaluation.scoring.ME",
287           "orngStat.MSE" : "Orange.evaluation.scoring.MSE",
288           "orngStat.MSE_old" : "Orange.evaluation.scoring.MSE_old",
289           "orngStat.McNemar" : "Orange.evaluation.scoring.McNemar",
290           "orngStat.McNemarOfTwo" : "Orange.evaluation.scoring.McNemarOfTwo",
291           "orngStat.NPV" : "Orange.evaluation.scoring.NPV",
292           "orngStat.PPV" : "Orange.evaluation.scoring.PPV",
293           "orngStat.R2" : "Orange.evaluation.scoring.R2",
294           "orngStat.RAE" : "Orange.evaluation.scoring.RAE",
295           "orngStat.RMSE" : "Orange.evaluation.scoring.RMSE",
296           "orngStat.RMSE_old" : "Orange.evaluation.scoring.RMSE_old",
297           "orngStat.ROCaddPoint" : "Orange.evaluation.scoring.ROCaddPoint",
298           "orngStat.ROCsFromCDT" : "Orange.evaluation.scoring.ROCsFromCDT",
299           "orngStat.ROCslope" : "Orange.evaluation.scoring.ROCslope",
300           "orngStat.RRSE" : "Orange.evaluation.scoring.RRSE",
301           "orngStat.RSE" : "Orange.evaluation.scoring.RSE",
302           "orngStat.TCbestThresholdsOnROCcurve" : "Orange.evaluation.scoring.TCbestThresholdsOnROCcurve",
303           "orngStat.TCcomputeROC" : "Orange.evaluation.scoring.TCcomputeROC",
304           "orngStat.TCthresholdlAverageROC" : "Orange.evaluation.scoring.TCthresholdlAverageROC",
305           "orngStat.TCverticalAverageROC" : "Orange.evaluation.scoring.TCverticalAverageROC",
306           "orngStat.Wilcoxon" : "Orange.evaluation.scoring.Wilcoxon",
307           "orngStat.WilcoxonPairs" : "Orange.evaluation.scoring.WilcoxonPairs",
308#           "orngStat.add" : "Orange.evaluation.scoring.add",
309#           "orngStat.checkArgkw" : "Orange.evaluation.scoring.checkArgkw",
310#           "orngStat.checkNonZero" : "Orange.evaluation.scoring.checkNonZero",
311           "orngStat.classProbabilitiesFromRes" : "Orange.evaluation.scoring.classProbabilitiesFromRes",
312           "orngStat.compare2AROCs" : "Orange.evaluation.scoring.compare2AROCs",
313           "orngStat.compare2AUCs" : "Orange.evaluation.scoring.compare2AUCs",
314           "orngStat.computeCDT" : "Orange.evaluation.scoring.computeCDT",
315           "orngStat.computeCalibrationCurve" : "Orange.evaluation.scoring.computeCalibrationCurve",
316           "orngStat.computeConfusionMatrices" : "Orange.evaluation.scoring.computeConfusionMatrices",
317           "orngStat.computeLiftCurve" : "Orange.evaluation.scoring.computeLiftCurve",
318           "orngStat.computeROC" : "Orange.evaluation.scoring.computeROC",
319           "orngStat.compute_CD" : "Orange.evaluation.scoring.compute_CD",
320           "orngStat.compute_friedman" : "Orange.evaluation.scoring.compute_friedman",
321           "orngStat.confusionChiSquare" : "Orange.evaluation.scoring.confusionChiSquare",
322           "orngStat.confusionMatrices" : "Orange.evaluation.scoring.confusionMatrices",
323           "orngStat.defaultLineTypes" : "Orange.evaluation.scoring.defaultLineTypes",
324           "orngStat.defaultPointTypes" : "Orange.evaluation.scoring.defaultPointTypes",
325#           "orngStat.frange" : "Orange.evaluation.scoring.frange",
326#           "orngStat.gettotsize" : "Orange.evaluation.scoring.gettotsize",
327#           "orngStat.gettotweight" : "Orange.evaluation.scoring.gettotweight",
328           "orngStat.graph_ranks" : "Orange.evaluation.scoring.graph_ranks",
329           "orngStat.isCDTEmpty" : "Orange.evaluation.scoring.isCDTEmpty",
330           "orngStat.learningCurve2PiCTeX" : "Orange.evaluation.scoring.learningCurve2PiCTeX",
331           "orngStat.learningCurveLearners2PiCTeX" : "Orange.evaluation.scoring.learningCurveLearners2PiCTeX",
332           "orngStat.legend2PiCTeX" : "Orange.evaluation.scoring.legend2PiCTeX",
333           "orngStat.legendLearners2PiCTeX" : "Orange.evaluation.scoring.legendLearners2PiCTeX",
334#           "orngStat.log2" : "Orange.evaluation.scoring.log2",
335#           "orngStat.math" : "Orange.evaluation.scoring.math",
336#           "orngStat.numpy" : "Orange.evaluation.scoring.numpy",
337#           "orngStat.operator" : "Orange.evaluation.scoring.operator",
338           "orngStat.plotLearningCurve" : "Orange.evaluation.scoring.plotLearningCurve",
339           "orngStat.plotLearningCurveLearners" : "Orange.evaluation.scoring.plotLearningCurveLearners",
340           "orngStat.plotMcNemarCurve" : "Orange.evaluation.scoring.plotMcNemarCurve",
341           "orngStat.plotMcNemarCurveLearners" : "Orange.evaluation.scoring.plotMcNemarCurveLearners",
342           "orngStat.plotROC" : "Orange.evaluation.scoring.plotROC",
343           "orngStat.plotROCLearners" : "Orange.evaluation.scoring.plotROCLearners",
344           "orngStat.precision" : "Orange.evaluation.scoring.precision",
345           "orngStat.printSingleROCCurveCoordinates" : "Orange.evaluation.scoring.printSingleROCCurveCoordinates",
346           "orngStat.rankDifference" : "Orange.evaluation.scoring.rankDifference",
347           "orngStat.recall" : "Orange.evaluation.scoring.recall",
348           "orngStat.regressionError" : "Orange.evaluation.scoring.regressionError",
349           "orngStat.scottsPi" : "Orange.evaluation.scoring.scottsPi",
350           "orngStat.sens" : "Orange.evaluation.scoring.sens",
351           "orngStat.spec" : "Orange.evaluation.scoring.spec",
352           "orngStat.splitByIterations" : "Orange.evaluation.scoring.splitByIterations",
353#           "orngStat.statc" : "Orange.evaluation.scoring.statc",
354           "orngStat.statisticsByFolds" : "Orange.evaluation.scoring.statisticsByFolds",
355#           "orngStat.x" : "Orange.evaluation.scoring.x",
356           
357           # Now use old orngMisc
358           # Orange.selection
359           #"orngMisc.BestOnTheFly":"Orange.misc.selection.BestOnTheFly",
360           #"orngMisc.selectBest":"Orange.misc.selection.selectBest",
361           #"orngMisc.selectBestIndex":"Orange.misc.selection.selectBestIndex",
362           #"orngMisc.compare2_firstBigger":"Orange.misc.selection.compareFirstBigger",
363           #"orngMisc.compare2_firstBigger":"Orange.misc.selection.compareFirstBigger",
364           #"orngMisc.compare2_firstSmaller":"Orange.misc.selection.compareFirstSmaller",
365           #"orngMisc.compare2_lastBigger":"Orange.misc.selection.compareLastBigger",
366           #"orngMisc.compare2_lastSmaller":"Orange.misc.selection.compareLastSmaller",
367           #"orngMisc.compare2_bigger":"Orange.misc.selection.compareBigger",
368           #"orngMisc.compare2_smaller":"Orange.misc.selection.compareSmaller",
369           
370           "orngEnsemble.BaggedLearner":"Orange.ensemble.bagging.BaggedLearner",
371           "orngEnsemble.BaggedClassifier":"Orange.ensemble.bagging.BaggedClassifier",
372           "orngEnsemble.BoostedLearner":"Orange.boosting.BoostedLearner",
373           "orngEnsemble.BoostedClassifier":"Orange.ensemble.boosting.BoostedClassifier",
374           "orngEnsemble.RandomForestClassifier":"Orange.ensemble.forest.RandomForestClassifier",
375           "orngEnsemble.RandomForestLearner":"Orange.ensemble.forest.RandomForestLearner",
376           "orngEnsemble.MeasureAttribute_randomForests":"Orange.ensemble.forest.ScoreFeature",
377           "orngEnsemble.SplitConstructor_AttributeSubset":"Orange.ensemble.forest.SplitConstructor_AttributeSubset",
378
379           "orngTest.proportionTest":"Orange.evaluation.testing.proportionTest",
380           "orngTest.leaveOneOut":"Orange.evaluation.testing.leaveOneOut",
381           "orngTest.crossValidation":"Orange.evaluation.testing.crossValidation",
382           "orngTest.testWithIndices":"Orange.evaluation.testing.testWithIndices",
383           "orngTest.learningCurve":"Orange.evaluation.testing.learningCurve",
384           "orngTest.learningCurveN":"Orange.evaluation.testing.learningCurveN",
385           "orngTest.learningCurveWithTestData":"Orange.evaluation.testing.learningCurveWithTestData",
386           "orngTest.learnAndTestOnTestData":"Orange.evaluation.testing.learnAndTestOnTestData",
387           "orngTest.learnAndTestOnLearnData":"Orange.evaluation.testing.learnAndTestOnLearnData",
388           "orngTest.testOnData":"Orange.evaluation.testing.testOnData",
389           "orngTest.TestedExample":"Orange.evaluation.testing.TestedExample",
390           "orngTest.ExperimentResults":"Orange.evaluation.testing.ExperimentResults",
391
392           "orngLR.dump":"Orange.classification.logreg.dump",
393           "orngLR.hasDiscreteValues":"Orange.classification.logreg.hasDiscreteValues",
394           "orngLR.LogRegLearner":"Orange.classification.logreg.LogRegLearner",
395           "orngLR.LogRegLearnerClass":"Orange.classification.logreg.LogRegLearnerClass",
396           "orngLR.Univariate_LogRegLearner":"Orange.classification.logreg.Univariate_LogRegLearner",
397           "orngLR.Univariate_LogRegLearner_Class":"Orange.classification.logreg.Univariate_LogRegLearner_Class",
398           "orngLR.Univariate_LogRegClassifier":"Orange.classification.logreg.Univariate_LogRegClassifier",
399           "orngLR.LogRegLearner_getPriors":"Orange.classification.logreg.LogRegLearner_getPriors",
400           "orngLR.LogRegLearnerClass_getPriors":"Orange.classification.logreg.LogRegLearnerClass_getPriors",
401           "orngLR.LogRegLearnerClass_getPriors_OneTable":"Orange.classification.logreg.LogRegLearnerClass_getPriors_OneTable",
402           "orngLR.Pr":"Orange.classification.logreg.Pr",
403           "orngLR.lh":"Orange.classification.logreg.lh",
404           "orngLR.diag":"Orange.classification.logreg.diag",
405           "orngLR.simpleFitter":"Orange.classification.logreg.simpleFitter",
406           "orngLR.Pr_bx":"Orange.classification.logreg.Pr_bx",
407           "orngLR.bayesianFitter":"Orange.classification.logreg.bayesianFitter",
408           "orngLR.StepWiseFSS":"Orange.classification.logreg.StepWiseFSS",
409           "orngLR.getLikelihood":"Orange.classification.logreg.getLikelihood",
410           "orngLR.StepWiseFSS_class":"Orange.classification.logreg.StepWiseFSS_class",
411           "orngLR.StepWiseFSS_Filter":"Orange.classification.logreg.StepWiseFSS_Filter",
412           "orngLR.StepWiseFSS_Filter_class":"Orange.classification.logreg.StepWiseFSS_Filter_class",
413           "orngLR.lchisqprob":"Orange.classification.logreg.lchisqprob",
414           "orngLR.zprob":"Orange.classification.logreg.zprob",
415           
416           "orange.Preprocessor": "Orange.preprocess.Preprocessor",
417           "orange.Preprocessor_addCensorWeight": "Orange.preprocess.Preprocessor_addCensorWeight",
418           "orange.Preprocessor_addClassNoise": "Orange.preprocess.Preprocessor_addClassNoise",
419           "orange.Preprocessor_addClassWeight": "Orange.preprocess.Preprocessor_addClassWeight",
420           "orange.Preprocessor_addGaussianClassNoise": "Orange.preprocess.Preprocessor_addGaussianClassNoise",
421           "orange.Preprocessor_addGaussianNoise": "Orange.preprocess.Preprocessor_addGaussianNoise",
422           "orange.Preprocessor_addMissing": "Orange.preprocess.Preprocessor_addMissing",
423           "orange.Preprocessor_addMissingClasses": "Orange.preprocess.Preprocessor_addMissingClasses",
424           "orange.Preprocessor_addNoise": "Orange.preprocess.Preprocessor_addNoise",
425           "orange.Preprocessor_discretize": "Orange.preprocess.Preprocessor_discretize",
426           "orange.Preprocessor_drop": "Orange.preprocess.Preprocessor_drop",
427           "orange.Preprocessor_dropMissing": "Orange.preprocess.Preprocessor_dropMissing",
428           "orange.Preprocessor_dropMissingClasses": "Orange.preprocess.Preprocessor_dropMissingClasses",
429           "orange.Preprocessor_filter": "Orange.preprocess.Preprocessor_filter",
430           "orange.Preprocessor_ignore": "Orange.preprocess.Preprocessor_ignore",
431           "orange.Preprocessor_imputeByLearner": "Orange.preprocess.Preprocessor_imputeByLearner",
432           "orange.Preprocessor_removeDuplicates": "Orange.preprocess.Preprocessor_removeDuplicates",
433           "orange.Preprocessor_select": "Orange.preprocess.Preprocessor_select",
434           "orange.Preprocessor_shuffle": "Orange.preprocess.Preprocessor_shuffle",
435           "orange.Preprocessor_take": "Orange.preprocess.Preprocessor_take",
436           "orange.Preprocessor_takeMissing": "Orange.preprocess.Preprocessor_takeMissing",
437           "orange.Preprocessor_takeMissingClasses": "Orange.preprocess.Preprocessor_takeMissingClasses",
438           
439           "orange.Discretizer": "Orange.feature.discretization.Discretizer",
440           "orange.BiModalDiscretizer": "Orange.feature.discretization.BiModalDiscretizer",
441           "orange.EquiDistDiscretizer": "Orange.feature.discretization.EquiDistDiscretizer",
442           "orange.IntervalDiscretizer": "Orange.feature.discretization.IntervalDiscretizer",
443           "orange.ThresholdDiscretizer": "Orange.feature.discretization.ThresholdDiscretizer",
444           "orange.EntropyDiscretization": "Orange.feature.discretization.EntropyDiscretization",
445           "orange.Discrete2Continuous": "Orange.feature.discretization.Discrete2Continuous",
446           
447           "orange.DomainContinuizer": "Orange.feature.continuization.DomainContinuizer",
448           
449           "orange.MakeRandomIndices": "Orange.data.sample.MakeRandomIndices",
450           "orange.MakeRandomIndicesN": "Orange.data.sample.MakeRandomIndicesN",
451           "orange.MakeRandomIndicesCV": "Orange.data.sample.MakeRandomIndicesCV",
452           "orange.MakeRandomIndicesMultiple": "Orange.data.sample.MakeRandomIndicesMultiple",
453           "orange.MakeRandomIndices2": "Orange.data.sample.MakeRandomIndices2",
454           
455           }
456
457   
458def build_pattern(mapping=MAPPING):
459    PATTERN = """
460    power< head=any+
461         trailer< '.' member=(%s) >
462         tail=any*
463    >
464    """ 
465    return PATTERN % "|".join("'%s'" % key.split(".")[-1] for key in mapping.keys())
466   
467class FixChangedNames(fixer_base.BaseFix):
468    mapping = MAPPING
469   
470    run_order = 1
471   
472    def compile_pattern(self):
473        self.PATTERN = build_pattern(self.mapping)
474        self._modules_to_change = [key.split(".", 1)[0] for key in self.mapping.keys()]
475        super(FixChangedNames, self).compile_pattern()
476       
477    def package_tree(self, package):
478        """ Return pytree tree for accessing the package
479       
480        Example:
481            >>> package_tree("Orange.feature.scoring")
482            [Name('Orange'), trailer('.' 'feature'), trailer('.', 'scoring')]
483        """
484        path = package.split('.')
485        nodes = []
486        nodes.append(Name(path[0]))
487        for name in path[1:]:
488            new = pytree.Node(self.syms.trailer, [Dot(), Name(name)])
489            nodes.append(new)
490        return nodes
491       
492       
493    def transform(self, node, results):
494        member = results.get("member")
495        head = results.get("head")
496        tail = results.get("tail")
497        module = head[0].value
498       
499        if member and module in self._modules_to_change:
500            node = member[0]
501            head = head[0]
502           
503            old_name = module + "." + node.value
504            if old_name not in self.mapping:
505                return
506             
507            new_name = unicode(self.mapping[module + "." + node.value])
508           
509            syms = self.syms
510           
511            if tail:
512                tail = [t.clone() for t in  tail]
513            new = self.package_tree(new_name)
514            new = pytree.Node(syms.power, new + tail, prefix=head.prefix)
515           
516            # Make sure the proper package is imported
517            package = new_name.rsplit(".", 1)[0]
518            touch_import(None, package, node)
519            return new   
520   
Note: See TracBrowser for help on using the repository browser.