Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2@file
3@brief defines custom types
4"""
7class long:
9 """
10 Defines the long type as int.
11 """
13 def __init__(self, v):
14 self._v = int(v)
16 def __mul__(self, y):
17 return long(self._v * y._v)
19 def __add__(self, y):
20 return long(self._v + y._v)
22 def __sub__(self, y):
23 return long(self._v - y._v)
25 def __div__(self, y):
26 return long(self._v / y._v)
28 def __str__(self):
29 return "%d" % self._v
31 def __int__(self):
32 return self._v
34 def __float__(self):
35 return float(self._v)
38class NA:
40 """
41 Defines the missing type.
42 """
44 def __init__(self):
45 pass
47 def __mul__(self, y):
48 return NA()
50 def __add__(self, y):
51 return NA()
53 def __sub__(self, y):
54 return NA()
56 def __div__(self, y):
57 return NA()
60class EmptyGroup:
62 """
63 defines an empty group
64 """
66 def __init__(self):
67 pass
70class NoSortClass:
72 """
73 Container which overloads the sort operator to return 0 all the times.
74 """
76 def __init__(self, value):
77 """
78 any value
79 """
80 self.value = value
82 def __lt__(self, o):
83 """
84 operator __lt__
85 """
86 return -1
88 def __str__(self):
89 """
90 usual
91 """
92 return "NSC:{0}".format(str(self.value))
95class GroupByContainer (list):
97 """
98 to differiate between a list and a list introduced by a groupby
99 """
100 pass