本文整理汇总了Python中Orange.data.Variable._clear_all_caches方法的典型用法代码示例。如果您正苦于以下问题:Python Variable._clear_all_caches方法的具体用法?Python Variable._clear_all_caches怎么用?Python Variable._clear_all_caches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.data.Variable
的用法示例。
在下文中一共展示了Variable._clear_all_caches方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_all_models_work_after_unpickling
# 需要导入模块: from Orange.data import Variable [as 别名]
# 或者: from Orange.data.Variable import _clear_all_caches [as 别名]
def test_all_models_work_after_unpickling(self):
Variable._clear_all_caches()
datasets = [Table('iris'), Table('titanic')]
for learner in list(self.all_learners()):
try:
learner = learner()
except Exception:
print('%s cannot be used with default parameters' % learner.__name__)
traceback.print_exc()
continue
# Skip slow tests
if isinstance(learner, _RuleLearner):
continue
for ds in datasets:
model = learner(ds)
s = pickle.dumps(model, 0)
model2 = pickle.loads(s)
np.testing.assert_almost_equal(
Table(model.domain, ds).X, Table(model2.domain, ds).X)
np.testing.assert_almost_equal(
model(ds), model2(ds),
err_msg='%s does not return same values when unpickled %s'
% (learner.__class__.__name__, ds.name))
示例2: setUp
# 需要导入模块: from Orange.data import Variable [as 别名]
# 或者: from Orange.data.Variable import _clear_all_caches [as 别名]
def setUp(self):
""" Override __eq__ for Orange objects that do not implement it"""
self.add_comparator(Domain,
compare_members=("attributes", "class_vars",
"class_var", "variables",
"metas", "anonymous"))
Variable._clear_all_caches()
示例3: create_domain
# 需要导入模块: from Orange.data import Variable [as 别名]
# 或者: from Orange.data.Variable import _clear_all_caches [as 别名]
def create_domain(*ss):
Variable._clear_all_caches()
vars=dict(
age=ContinuousVariable(name="AGE"),
gender=DiscreteVariable(name="Gender", values=["M", "F"]),
incomeA=ContinuousVariable(name="incomeA"),
income=ContinuousVariable(name="income"),
education=DiscreteVariable(name="education", values=["GS", "HS", "C"]),
ssn=StringVariable(name="SSN"),
race=DiscreteVariable(name="race",
values=["White", "Hypsanic", "African", "Other"]))
def map_vars(s):
return [vars[x] for x in s]
return Domain(*[map_vars(s) for s in ss])
示例4: setUpClass
# 需要导入模块: from Orange.data import Variable [as 别名]
# 或者: from Orange.data.Variable import _clear_all_caches [as 别名]
def setUpClass(cls):
"""Prepare environment for test execution
Construct a dummy signal manager and monkey patch
OWReport.get_instance to return a manually created instance.
"""
super().setUpClass()
cls.widgets = []
cls.signal_manager = DummySignalManager()
report = OWReport()
cls.widgets.append(report)
OWReport.get_instance = lambda: report
Variable._clear_all_caches()
示例5: test_bad_data
# 需要导入模块: from Orange.data import Variable [as 别名]
# 或者: from Orange.data.Variable import _clear_all_caches [as 别名]
def test_bad_data(self):
"""
Firstly it creates predictions with TreeLearner. Then sends predictions and
different data with different domain to Predictions widget. Those different
data and domain are similar to original data and domain but they have three
different target values instead of two.
GH-2129
"""
Variable._clear_all_caches()
filestr1 = """\
age\tsex\tsurvived
d\td\td
\t\tclass
adult\tmale\tyes
adult\tfemale\tno
child\tmale\tyes
child\tfemale\tyes
"""
file1 = io.StringIO(filestr1)
table = TabReader(file1).read()
learner = TreeLearner()
tree = learner(table)
filestr2 = """\
age\tsex\tsurvived
d\td\td
\t\tclass
adult\tmale\tyes
adult\tfemale\tno
child\tmale\tyes
child\tfemale\tunknown
"""
file2 = io.StringIO(filestr2)
bad_table = TabReader(file2).read()
self.send_signal(self.widget.Inputs.predictors, tree, 1)
with excepthook_catch():
self.send_signal(self.widget.Inputs.data, bad_table)
Variable._clear_all_caches() # so that test excepting standard titanic work
示例6: test_datasets_info_features
# 需要导入模块: from Orange.data import Variable [as 别名]
# 或者: from Orange.data.Variable import _clear_all_caches [as 别名]
def test_datasets_info_features(self):
print(datasets.items())
for dataset, info in datasets.items():
Variable._clear_all_caches()
if info['location'].startswith('http'): continue # Tested elsewhere
table = Table(dataset)
domain = table.domain
# Test features
self.assertEqual(table.X.shape[0], info['rows'], dataset)
self.assertEqual(table.has_missing(), info['missing'], dataset)
self.assertEqual(len(domain.metas), info['features']['meta'], dataset)
self.assertEqual(sum(i.is_discrete for i in domain.attributes),
info['features']['discrete'],
dataset)
self.assertEqual(sum(i.is_continuous for i in domain.attributes),
info['features']['continuous'],
dataset)
# Test class vars
if len(domain.class_vars) > 1:
self.assertEqual(['discrete' if i.is_discrete else 'continuous'
for i in domain.class_vars],
info['target']['type'],
dataset)
elif len(domain.class_vars) == 1:
cls = domain.class_var
self.assertEqual('discrete' if cls.is_discrete else 'continuous',
info['target']['type'],
dataset)
if cls.is_discrete:
self.assertEqual(len(cls.values), info['target']['values'], dataset)
else:
self.assertEqual(False, info['target']['type'], dataset)
示例7: test_unpickling_recreates_known_domains
# 需要导入模块: from Orange.data import Variable [as 别名]
# 或者: from Orange.data.Variable import _clear_all_caches [as 别名]
def test_unpickling_recreates_known_domains(self):
Variable._clear_all_caches()
domain = Domain([])
unpickled_domain = pickle.loads(pickle.dumps(domain))
self.assertTrue(hasattr(unpickled_domain, '_known_domains'))
示例8: setUp
# 需要导入模块: from Orange.data import Variable [as 别名]
# 或者: from Orange.data.Variable import _clear_all_caches [as 别名]
def setUp(self):
Variable._clear_all_caches()
dataset_dirs.append("Orange/tests")
示例9: init
# 需要导入模块: from Orange.data import Variable [as 别名]
# 或者: from Orange.data.Variable import _clear_all_caches [as 别名]
def init(self):
Variable._clear_all_caches()
self.data = Table("iris")
self.same_input_output_domain = True
示例10: setUp
# 需要导入模块: from Orange.data import Variable [as 别名]
# 或者: from Orange.data.Variable import _clear_all_caches [as 别名]
def setUp(self):
Variable._clear_all_caches()
# Convergence warnings are irrelevant for these tests
warnings.filterwarnings("ignore", ".*", ConvergenceWarning)
示例11: setUp
# 需要导入模块: from Orange.data import Variable [as 别名]
# 或者: from Orange.data.Variable import _clear_all_caches [as 别名]
def setUp(self):
Variable._clear_all_caches()
self.data = Table("test4")
示例12: init
# 需要导入模块: from Orange.data import Variable [as 别名]
# 或者: from Orange.data.Variable import _clear_all_caches [as 别名]
def init(self):
Variable._clear_all_caches()
self.data = Table("iris")
示例13: setUp
# 需要导入模块: from Orange.data import Variable [as 别名]
# 或者: from Orange.data.Variable import _clear_all_caches [as 别名]
def setUp(self):
Variable._clear_all_caches()
random.seed(42)
self.zoo = Table("zoo")
示例14: setUp
# 需要导入模块: from Orange.data import Variable [as 别名]
# 或者: from Orange.data.Variable import _clear_all_caches [as 别名]
def setUp(self):
Variable._clear_all_caches() # pylint: disable=protected-access
random.seed(42)
self.zoo = Table("zoo")
示例15: tearDown
# 需要导入模块: from Orange.data import Variable [as 别名]
# 或者: from Orange.data.Variable import _clear_all_caches [as 别名]
def tearDown(self):
Variable._clear_all_caches()