-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataManagement.py
More file actions
66 lines (45 loc) · 1.5 KB
/
Copy pathdataManagement.py
File metadata and controls
66 lines (45 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import random
# represents an attribute
class Attribute(object):
def __init__(self, name):
self._values = []
self._name = name
def add(self, *args):
map(self._addSingle, args)
def setName(self, name):
self._name = name
def _addSingle(self, value):
#possible attribute values
self._values.append(value)
def getName(self):
return self._name
def getValues(self):
return self._values
def valueCount(self):
return len(self._values)
def __str__(self):
return self._name
#generates attributes with random number of values, used for testing
class RandomAttributeFactory(object):
def __init__(self, start):
#The first attribute's id will be labeled 'start',
#the second at start + 1, etc.
self._next = start
def getNext(self):
#assign a random attribute name
randomAtt = RandomAttribute('rand' + str(self._next))
self._next = self._next + 1
#assign a random number of values from 2 to 14
str_list = map(str, range(1, random.randint(2, 5)))
map(randomAtt.add, str_list)
return randomAtt
class RandomAttribute(Attribute):
def sample(self):
return self._values[random.randint(0, self.valueCount() - 1)]
def setValues(self, values):
self._values = values
class SampleSet(object):
def __init__(self):
self._values = []
def addDefinition(self, attribute):
pass