source: orange/orange/doc/reference/variableReuse.py @ 4092:a7ec563d7adf

Revision 4092:a7ec563d7adf, 1.6 KB checked in by janezd <janez.demsar@…>, 7 years ago (diff)

* empty log message *

Line 
1import orange
2
3# Creates a new variable
4v1, s = orange.Variable.make("a", orange.VarTypes.Discrete, ["a", "b"])
5print s
6print v1.values
7print
8
9# Reuses v1
10v2, s = orange.Variable.make("a", orange.VarTypes.Discrete, ["a"], ["c"])
11print s
12print "v1.values: ", v1.values
13print "v2 is v1: ", v2 is v1
14print
15
16# Reuses v1
17v3, s = orange.Variable.make("a", orange.VarTypes.Discrete, ["a", "b", "c", "d"])
18print s
19print "v1.values: ", v1.values
20print "v3 is v1: ", v3 is v1
21print
22
23# Creates a new one due to incompatibility
24v4, s = orange.Variable.make("a", orange.VarTypes.Discrete, ["b"])
25print s
26print "v1.values: ", v1.values
27print "v4.values: ", v4.values
28print "v4 is v1: ", v4 is v1
29print
30
31# Can reuse - the order is not prescribed
32v5, s = orange.Variable.make("a", orange.VarTypes.Discrete, None, ["c", "a"])
33print s
34print "v1.values: ", v1.values
35print "v5.values: ", v5.values
36print "v5 is v1: ", v5 is v1
37print
38
39# Can reuse despite missing and unrecognized values - the order is not prescribed
40v6, s = orange.Variable.make("a", orange.VarTypes.Discrete, None, ["e"])
41print s
42print "v1.values: ", v1.values
43print "v6.values: ", v6.values
44print "v6 is v1: ", v6 is v1
45print
46
47# Can't reuse due to unrecognized values
48v7, s = orange.Variable.make("a", orange.VarTypes.Discrete, None, ["f"], orange.Variable.MakeStatus.NoRecognizedValues)
49print s
50print "v1.values: ", v1.values
51print "v7.values: ", v7.values
52print "v7 is v1: ", v7 is v1
53print
54
55# No reuse
56v8, s = orange.Variable.make("a", orange.VarTypes.Discrete, ["a", "b", "c", "d", "e"], None, orange.Variable.MakeStatus.OK)
57print s
58print "v1.values: ", v1.values
59print "v8.values: ", v8.values
60print "v8 is v1: ", v8 is v1
61
Note: See TracBrowser for help on using the repository browser.