source: orange/Orange/doc/reference/values.py @ 9671:a7b056375472

Revision 9671:a7b056375472, 1.5 KB checked in by anze <anze.staric@…>, 2 years ago (diff)

Moved orange to Orange (part 2)

Line 
1# Description: Shows how to construct and use orange.Value
2# Category:    basic classes
3# Classes:     Value
4# Uses:       
5# Referenced:  Value.htm
6
7import orange
8
9def err():
10    raise Exception("Error")
11
12fruit = orange.EnumVariable("fruit", values = ["plum", "apple", "lemon"])
13iq = orange.FloatVariable("iq")
14lm = orange.Value(fruit, "lemon")
15ap = orange.Value(fruit, 1)
16un = orange.Value(fruit)
17
18Mary = orange.Value(iq, "105")
19Harry = orange.Value(iq, 80)
20Dick = orange.Value(iq)
21
22sf = orange.Value(2)
23Sally = orange.Value(118.0)
24
25sf.variable = fruit
26
27
28city = orange.Value(orange.StringValue("Cicely"))
29
30
31
32if (lm!="lemon"): raise error
33if (lm<"apple"): raise error
34if (orange.Value(1)>lm): raise error
35
36
37deg3 = orange.EnumVariable(values=["little", "medium", "big"])
38deg4 = orange.EnumVariable(values=["tiny", "little", "big", "huge"])
39
40val3 = orange.Value(deg3)
41val4 = orange.Value(deg4)
42
43val3.value = "medium"
44val4.value = "little"
45print val3<val4, val3<=val4, val3==val4, val3>=val4, val3>val4, val3!=val4
46print val4<val3, val4<=val3, val4==val3, val4>=val3, val4>val3, val4!=val3
47
48val3.value = "medium"
49val4.value = "huge"
50#print val3<val4
51
52degb = orange.EnumVariable(values=["black", "gray", "white"])
53degd = orange.EnumVariable(values=["white", "gray", "black"])
54print orange.Value(degb, "black") == orange.Value(degd, "black")
55try:
56    print orange.Value(degb, "black") < orange.Value(degd, "white")
57except:
58    print """'orange.Value(degb, "black") < orange.Value(degd, "white")' failed (as it should)"""
59
60print 
Note: See TracBrowser for help on using the repository browser.