source: orange/Orange/testing/regression/tests_20/reference_pythonvariable2a.py @ 9952:986e9cd806f4

Revision 9952:986e9cd806f4, 834 bytes checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Tests moved and renamed from orange 20.

Line 
1import orange, time
2
3class DateVariable(orange.PythonVariable):
4    def str2val(self, str):
5        return time.strptime(str, "%b %d %Y")
6
7    def val2str(self, val):
8        return time.strftime("%b %d %Y (%a)", val)
9
10
11birth = DateVariable("birth")
12val = birth("Aug 19 2003")
13print val
14
15data = orange.ExampleTable("lenses")
16
17newdomain = orange.Domain(data.domain.attributes + [birth], data.domain.classVar)
18newdata = orange.ExampleTable(newdomain, data)
19
20newdata[0]["birth"] = "Aug 19 2003"
21print newdata[0]
22
23orange.saveTabDelimited("del2", newdata)
24
25print newdata[0]
26
27orange.saveTabDelimited("del2", newdata)
28
29newdata[0]["birth"] = "Aug 19 2003"
30newdata[1]["birth"] = "Jan 12 1998"
31newdata[2]["birth"] = "Sep 1 1995"
32newdata[3]["birth"] = "May 25 2001"
33newdata.sort("birth")
34print "\nSorted data"
35for i in newdata:
36    print i
37
38   
Note: See TracBrowser for help on using the repository browser.