hhltools 1.2.7__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- HHLtools/ADT.py +279 -0
- HHLtools/Herror.py +23 -0
- HHLtools/Hmath.py +132 -0
- HHLtools/RPN.py +0 -0
- HHLtools/__init__.py +18 -0
- HHLtools/lang.py +34 -0
- HHLtools/prints.py +43 -0
- hhltools-1.2.7.dist-info/METADATA +68 -0
- hhltools-1.2.7.dist-info/RECORD +11 -0
- hhltools-1.2.7.dist-info/WHEEL +6 -0
- hhltools-1.2.7.dist-info/top_level.txt +1 -0
HHLtools/ADT.py
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
from collections.abc import Iterable
|
|
2
|
+
from HHLtools.Herror import *
|
|
3
|
+
class Queue:
|
|
4
|
+
def __init__(self,size:int = -1):
|
|
5
|
+
"""
|
|
6
|
+
:param size: the fixed size of the queue, if not set, infinite length
|
|
7
|
+
"""
|
|
8
|
+
if size > 0:
|
|
9
|
+
self.__size = size
|
|
10
|
+
self.__queue = [None] * size
|
|
11
|
+
self.__head = 0
|
|
12
|
+
self.__tail = 0
|
|
13
|
+
self.__count = 0
|
|
14
|
+
else:
|
|
15
|
+
self.__size = -1
|
|
16
|
+
self.__queue = []
|
|
17
|
+
|
|
18
|
+
def __repr__(self):
|
|
19
|
+
if self.__size != -1:
|
|
20
|
+
return f'Queue({str(self.__queue)}, ' \
|
|
21
|
+
f'headPointer = {self.__head if self.__size != -1 else len(self.__queue) - 1}, ' \
|
|
22
|
+
f'tailPointer = {self.__tail if self.__size != -1 else 0}, Fixedlength = True)'
|
|
23
|
+
else:
|
|
24
|
+
return f'Queue({str(self.__queue)})'
|
|
25
|
+
|
|
26
|
+
def __len__(self):
|
|
27
|
+
return self.__count if self.__size != -1 else len(self.__queue)
|
|
28
|
+
|
|
29
|
+
def __iter__(self):
|
|
30
|
+
return iter(self.getlist())
|
|
31
|
+
|
|
32
|
+
def __contains__(self, item):
|
|
33
|
+
return item in self.getlist()
|
|
34
|
+
|
|
35
|
+
def __getitem__(self, item):
|
|
36
|
+
return self.getlist()[int(item)]
|
|
37
|
+
|
|
38
|
+
def __eq__(self, other):
|
|
39
|
+
return self.getlist() == other.getlist()
|
|
40
|
+
|
|
41
|
+
def getlist(self):
|
|
42
|
+
contents = []
|
|
43
|
+
if self.__size == -1:
|
|
44
|
+
contents = self.__queue[:]
|
|
45
|
+
else:
|
|
46
|
+
head = self.__head
|
|
47
|
+
while 1:
|
|
48
|
+
contents.append(self.__queue[head])
|
|
49
|
+
head += 1
|
|
50
|
+
head = head % self.__size
|
|
51
|
+
if head == self.__tail:
|
|
52
|
+
break
|
|
53
|
+
return contents
|
|
54
|
+
|
|
55
|
+
def show(self):
|
|
56
|
+
contents = self.__queue
|
|
57
|
+
maxlen = 0
|
|
58
|
+
for c in contents:
|
|
59
|
+
if len(str(c)) > maxlen:
|
|
60
|
+
maxlen = len(str(c))
|
|
61
|
+
print('='*(15+maxlen+15))
|
|
62
|
+
for c in range(len(contents)):
|
|
63
|
+
front = ' '*15
|
|
64
|
+
end = ' '
|
|
65
|
+
if c == self.__head:
|
|
66
|
+
front = 'headPointer '
|
|
67
|
+
if c == self.__tail:
|
|
68
|
+
end = (maxlen+4)*' ' +'tailPointer'
|
|
69
|
+
print(front+str(contents[c])+' '*(maxlen-len(str(contents[c])))+end)
|
|
70
|
+
print('=' * (15 + maxlen + 15))
|
|
71
|
+
|
|
72
|
+
def push(self, content):
|
|
73
|
+
# if type(content) not in (int, str, float):
|
|
74
|
+
# error(TypeError, f"push() argument must be an integer, a string, or a real number, not {str(type(content))[7:-1]}")
|
|
75
|
+
if self.__size > 0:
|
|
76
|
+
if self.__count == self.__size:
|
|
77
|
+
error(IndexOutOfBoundError, 'the queue is full, try pop()')
|
|
78
|
+
return
|
|
79
|
+
self.__queue[self.__tail] = content
|
|
80
|
+
self.__tail = (self.__tail+1)%self.__size
|
|
81
|
+
self.__count += 1
|
|
82
|
+
else:
|
|
83
|
+
self.__queue.append(content)
|
|
84
|
+
|
|
85
|
+
def pop(self):
|
|
86
|
+
if self.__size > 0:
|
|
87
|
+
if self.__count == 0:
|
|
88
|
+
return None
|
|
89
|
+
tmp = self.__head
|
|
90
|
+
self.__head = (self.__head + 1)%self.__size
|
|
91
|
+
self.__count -= 1
|
|
92
|
+
return self.__queue[tmp]
|
|
93
|
+
else:
|
|
94
|
+
try:
|
|
95
|
+
res = self.__queue[0]
|
|
96
|
+
del self.__queue[0]
|
|
97
|
+
return res
|
|
98
|
+
except IndexError:
|
|
99
|
+
return None
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class Stack:
|
|
103
|
+
def __init__(self,size:int=-1):
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
:param size: the fixed size of the stack, if not set, infinite length
|
|
107
|
+
"""
|
|
108
|
+
self.a = 0
|
|
109
|
+
if size > 0:
|
|
110
|
+
self.__stack = [None]*size
|
|
111
|
+
self.__size = size
|
|
112
|
+
else:
|
|
113
|
+
self.__stack = []
|
|
114
|
+
self.__size = -1
|
|
115
|
+
self.__top = -1
|
|
116
|
+
|
|
117
|
+
def __repr__(self):
|
|
118
|
+
if self.__size != -1:
|
|
119
|
+
return f'Stack({str(self.__stack)}, topPointer = {self.__top})'
|
|
120
|
+
else:
|
|
121
|
+
return f'Stack({str(self.__stack)})'
|
|
122
|
+
|
|
123
|
+
def __len__(self):
|
|
124
|
+
return self.__top if self.__size != -1 else len(self.__stack)
|
|
125
|
+
|
|
126
|
+
def __iter__(self):
|
|
127
|
+
return iter(self.getlist())
|
|
128
|
+
|
|
129
|
+
def __contains__(self, item):
|
|
130
|
+
return item in self.getlist()
|
|
131
|
+
|
|
132
|
+
def __getitem__(self, item):
|
|
133
|
+
return self.getlist()[int(item)]
|
|
134
|
+
|
|
135
|
+
def __eq__(self, other):
|
|
136
|
+
return self.getlist() == other.getlist()
|
|
137
|
+
|
|
138
|
+
def getlist(self):
|
|
139
|
+
contents = []
|
|
140
|
+
if self.__size == -1:
|
|
141
|
+
contents = self.__stack[:]
|
|
142
|
+
else:
|
|
143
|
+
for i in range(0, self.__top):
|
|
144
|
+
contents.append(self.__stack[i])
|
|
145
|
+
return contents
|
|
146
|
+
|
|
147
|
+
def push(self, content):
|
|
148
|
+
# if type(content) not in (int, str, float):
|
|
149
|
+
# error(TypeError, f"push() argument must be an integer, a string, or a real number, not {str(type(content))[7:-1]}")
|
|
150
|
+
if self.__size > 0:
|
|
151
|
+
if self.__top < self.__size - 1:
|
|
152
|
+
self.__top += 1
|
|
153
|
+
self.__stack[self.__top] = content
|
|
154
|
+
else:
|
|
155
|
+
error(IndexOutOfBoundError, 'the stack is full, try pop()')
|
|
156
|
+
else:
|
|
157
|
+
self.__stack.insert(0,content)
|
|
158
|
+
|
|
159
|
+
def pop(self):
|
|
160
|
+
if self.__size > 0:
|
|
161
|
+
if self.__top > -1:
|
|
162
|
+
self.__top -= 1
|
|
163
|
+
return self.__stack[self.__top + 1]
|
|
164
|
+
else:
|
|
165
|
+
return None
|
|
166
|
+
else:
|
|
167
|
+
try:
|
|
168
|
+
res = self.__stack[0]
|
|
169
|
+
del self.__stack[0]
|
|
170
|
+
return res
|
|
171
|
+
except IndexError:
|
|
172
|
+
return None
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class LinkedListNode:
|
|
177
|
+
def __init__(self, val):
|
|
178
|
+
# if type(val) not in (int, str, float):
|
|
179
|
+
# error(TypeError, f"an element in linked list must be an integer, a string, or a real number, not {str(type(val))[7:-1]}")
|
|
180
|
+
self.val = val
|
|
181
|
+
self.next = None
|
|
182
|
+
|
|
183
|
+
def __repr__(self):
|
|
184
|
+
content = []
|
|
185
|
+
temp = self
|
|
186
|
+
while temp.next is not None:
|
|
187
|
+
content.append(temp.val)
|
|
188
|
+
temp = temp.next
|
|
189
|
+
content.append(temp.val)
|
|
190
|
+
return f'LinkedList({content})'
|
|
191
|
+
|
|
192
|
+
def __iter__(self):
|
|
193
|
+
return iter(self.getlist())
|
|
194
|
+
|
|
195
|
+
def __contains__(self, item):
|
|
196
|
+
return item in self.getlist()
|
|
197
|
+
|
|
198
|
+
def __getitem__(self, item):
|
|
199
|
+
return self.getlist()[int(item)]
|
|
200
|
+
|
|
201
|
+
def __eq__(self, other):
|
|
202
|
+
return self.getlist() == other.getlist()
|
|
203
|
+
|
|
204
|
+
def __add__(self, other):
|
|
205
|
+
if type(other) != LinkedListNode:
|
|
206
|
+
error(TypeError, f"unsupported operand type(s) for +: 'LinkedListNode' and {str(type(other))[7:-1]}")
|
|
207
|
+
temp = self
|
|
208
|
+
while temp.next is not None:
|
|
209
|
+
temp = temp.next
|
|
210
|
+
temp.next = other
|
|
211
|
+
return self
|
|
212
|
+
|
|
213
|
+
def getlist(self):
|
|
214
|
+
content = []
|
|
215
|
+
temp = self
|
|
216
|
+
while temp is not None:
|
|
217
|
+
content.append(temp.val)
|
|
218
|
+
temp = temp.next
|
|
219
|
+
return content
|
|
220
|
+
|
|
221
|
+
def create_linkedlist_from_list(lst:list):
|
|
222
|
+
if not isinstance(lst, Iterable):
|
|
223
|
+
error(TypeError, f"'{type(lst)}' object is not iterable")
|
|
224
|
+
if len(lst) == 0:
|
|
225
|
+
return LinkedListNode(None)
|
|
226
|
+
node = LinkedListNode(lst[0])
|
|
227
|
+
temp = node
|
|
228
|
+
for i in lst[1:]:
|
|
229
|
+
temp.next = LinkedListNode(i)
|
|
230
|
+
temp = temp.next
|
|
231
|
+
return node
|
|
232
|
+
|
|
233
|
+
def create_stack_from_list(lst:list, Fixedlength:bool = True):
|
|
234
|
+
if not isinstance(lst, Iterable):
|
|
235
|
+
error(TypeError, f"'{type(lst)}' object is not iterable")
|
|
236
|
+
|
|
237
|
+
if Fixedlength:
|
|
238
|
+
stack = Stack(len(lst))
|
|
239
|
+
else:
|
|
240
|
+
stack = Stack()
|
|
241
|
+
for i in lst:
|
|
242
|
+
stack.push(i)
|
|
243
|
+
return stack
|
|
244
|
+
|
|
245
|
+
def create_queue_from_list(lst:list, Fixedlength:bool = True):
|
|
246
|
+
if not isinstance(lst, Iterable):
|
|
247
|
+
error(TypeError, f"'{type(lst)}' object is not iterable")
|
|
248
|
+
|
|
249
|
+
if Fixedlength:
|
|
250
|
+
queue = Queue(len(lst))
|
|
251
|
+
else:
|
|
252
|
+
queue = Queue()
|
|
253
|
+
for i in lst:
|
|
254
|
+
queue.push(i)
|
|
255
|
+
return queue
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def BinarySearch(iterable, target):
|
|
260
|
+
if not isinstance(iterable, Iterable):
|
|
261
|
+
error(TypeError, f"'{type(iterable)}' object is not iterable")
|
|
262
|
+
found = False
|
|
263
|
+
highIndex = len(iterable)-1
|
|
264
|
+
lowIndex = 0
|
|
265
|
+
while not found and lowIndex <= highIndex:
|
|
266
|
+
mid = (highIndex + lowIndex) // 2
|
|
267
|
+
if iterable[mid] == target:
|
|
268
|
+
found = True
|
|
269
|
+
print(mid)
|
|
270
|
+
elif iterable[mid] > target:
|
|
271
|
+
highIndex = mid - 1
|
|
272
|
+
else:
|
|
273
|
+
lowIndex = mid + 1
|
|
274
|
+
|
|
275
|
+
if not found:
|
|
276
|
+
print("not found")
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
HHLtools/Herror.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import sys, types, traceback
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def error(err, info):
|
|
5
|
+
try:
|
|
6
|
+
raise err(info)
|
|
7
|
+
except:
|
|
8
|
+
ei = sys.exc_info()
|
|
9
|
+
back_frame = ei[2].tb_frame.f_back
|
|
10
|
+
back_tb = types.TracebackType(tb_next=None,
|
|
11
|
+
tb_frame=back_frame,
|
|
12
|
+
tb_lasti=back_frame.f_lasti,
|
|
13
|
+
tb_lineno=back_frame.f_lineno)
|
|
14
|
+
traceback.print_exception(ei[0], ei[1], tb=back_tb)
|
|
15
|
+
sys.exit(1)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class DimensionError(Exception):
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class IndexOutOfBoundError(Exception):
|
|
23
|
+
pass
|
HHLtools/Hmath.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
from HHLtools.Herror import *
|
|
2
|
+
|
|
3
|
+
class Function:
|
|
4
|
+
def __init__(self, expression: str, variable: str):
|
|
5
|
+
if type(expression) != str:
|
|
6
|
+
error(TypeError, f"the expression must be a string, not '{str(type(expression))[7:-1]}'")
|
|
7
|
+
if type(variable) != str:
|
|
8
|
+
error(TypeError, f"the variable must be a string, not '{str(type(variable))[7:-1]}'")
|
|
9
|
+
self.__expression = expression
|
|
10
|
+
self.__var = variable
|
|
11
|
+
|
|
12
|
+
def evaluate(self, value: int | float):
|
|
13
|
+
if type(value) not in (int, float):
|
|
14
|
+
error(TypeError, f"the value must be an integer, or a real number, not '{str(type(value))[7:-1]}'")
|
|
15
|
+
expression = self.__expression.replace(self.__var, str(value))
|
|
16
|
+
return eval(expression)
|
|
17
|
+
|
|
18
|
+
def gradient(self, accuracy: float, value: int | float):
|
|
19
|
+
if type(value) not in (int, float):
|
|
20
|
+
error(TypeError, f"the value must be an integer, or a real number, not '{str(type(value))[7:-1]}'")
|
|
21
|
+
if type(accuracy) != float:
|
|
22
|
+
error(TypeError, f"the acuuracy must be a real number, not '{str(type(value))[7:-1]}'")
|
|
23
|
+
x1 = value
|
|
24
|
+
x2 = value + 10 ** -accuracy
|
|
25
|
+
y1 = self.evaluate(x1)
|
|
26
|
+
y2 = self.evaluate(x2)
|
|
27
|
+
res = (y2 - y1) / (x2 - x1)
|
|
28
|
+
return round(res, 1) if res - int(res) > 0.999 or res - int(res) < 0.001 else round(res, 3)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Vector:
|
|
33
|
+
def __init__(self, dimensions:list):
|
|
34
|
+
"""
|
|
35
|
+
only support two-dimensional and three-dimensional vectors
|
|
36
|
+
:param dimensions: the components of the vector in i, j(, k) directions
|
|
37
|
+
"""
|
|
38
|
+
if len(dimensions) != 2 and len(dimensions) != 3:
|
|
39
|
+
error(DimensionError, f'expected 2 or 3 dimensions, got {len(dimensions)}')
|
|
40
|
+
self.dimensions = dimensions
|
|
41
|
+
|
|
42
|
+
def __repr__(self):
|
|
43
|
+
return f'Vector({self.dimensions})'
|
|
44
|
+
|
|
45
|
+
def __len__(self):
|
|
46
|
+
return len(self.dimensions)
|
|
47
|
+
|
|
48
|
+
def __eq__(self, other):
|
|
49
|
+
return self.dimensions == other.dimensions
|
|
50
|
+
|
|
51
|
+
def __add__(self, other):
|
|
52
|
+
if type(other) != Vector:
|
|
53
|
+
error(TypeError, f"unsupported operand type(s) for +: 'Vector' and {str(type(other))[7:-1]}")
|
|
54
|
+
if len(self) != len(other):
|
|
55
|
+
error(DimensionError, f'unsupported operand dimension(s) for +: Vectors of different dimensions')
|
|
56
|
+
res = [self.dimensions[i] + other.dimensions[i] for i in range(len(self))]
|
|
57
|
+
return Vector(res)
|
|
58
|
+
|
|
59
|
+
def __sub__(self, other):
|
|
60
|
+
if type(other) != Vector:
|
|
61
|
+
error(TypeError, f"unsupported operand type(s) for -: 'Vector' and {str(type(other))[7:-1]}")
|
|
62
|
+
if len(self) != len(other):
|
|
63
|
+
error(DimensionError, f"unsupported operand dimension(s) for -: Vectors of different dimensions")
|
|
64
|
+
res = [self.dimensions[i] - other.dimensions[i] for i in range(len(self))]
|
|
65
|
+
return Vector(res)
|
|
66
|
+
|
|
67
|
+
def __mul__(self, other):
|
|
68
|
+
if type(other) == int:
|
|
69
|
+
return Vector([other * i for i in self.dimensions])
|
|
70
|
+
elif type(other) == Vector:
|
|
71
|
+
if len(self) != len(other):
|
|
72
|
+
error(DimensionError, f"unsupported operand dimension(s) for *: Vectors of different dimensions")
|
|
73
|
+
return sum([self.dimensions[i] * other.dimensions[i] for i in range(len(self))])
|
|
74
|
+
else:
|
|
75
|
+
error(TypeError, f"unsupported operand type(s) for *: 'Vector' and {str(type(other))[7:-1]}")
|
|
76
|
+
|
|
77
|
+
def __rmul__(self, other):
|
|
78
|
+
if type(other) == int:
|
|
79
|
+
return Vector([other * i for i in self.dimensions])
|
|
80
|
+
elif type(other) == Vector:
|
|
81
|
+
if len(self) != len(other):
|
|
82
|
+
error(DimensionError, f"unsupported operand dimension(s) for *: Vectors of different dimensions")
|
|
83
|
+
return sum([self.dimensions[i] * other.dimensions[i] for i in range(len(self))])
|
|
84
|
+
else:
|
|
85
|
+
error(TypeError, f"unsupported operand type(s) for *: {str(type(other))[7:-1]} and 'Vector'")
|
|
86
|
+
|
|
87
|
+
def __abs__(self):
|
|
88
|
+
return sum([i**2 for i in self.dimensions])**(1/2)
|
|
89
|
+
|
|
90
|
+
def __matmul__(self, other):
|
|
91
|
+
if type(other) != Vector:
|
|
92
|
+
error(TypeError, f"unsupported operand type(s) for @: 'Vector' and {str(type(other))[7:-1]}")
|
|
93
|
+
if len(self.dimensions) != 3 or len(other.dimensions) != 3:
|
|
94
|
+
error(DimensionError, f"unsupported operand dimension(s) for @: Not 3 dimension Vector(s)")
|
|
95
|
+
x = self.dimensions[1] * other.dimensions[2] - self.dimensions[2] * other.dimensions[1]
|
|
96
|
+
y = self.dimensions[2] * other.dimensions[0] - self.dimensions[0] * other.dimensions[2]
|
|
97
|
+
z = self.dimensions[0] * other.dimensions[1] - self.dimensions[1] * other.dimensions[0]
|
|
98
|
+
return Vector([x,y,z])
|
|
99
|
+
|
|
100
|
+
class Line:
|
|
101
|
+
_chars = []
|
|
102
|
+
def __init__(self, position:Vector, direction:Vector, scalar:str):
|
|
103
|
+
if len(position) != 3:
|
|
104
|
+
error(DimensionError, f'expected 3 dimensions, got {len(position)}')
|
|
105
|
+
if len(direction) != 3:
|
|
106
|
+
error(DimensionError, f'expected 3 dimensions, got {len(direction)}')
|
|
107
|
+
chars = self.__class__._chars
|
|
108
|
+
if scalar in chars:
|
|
109
|
+
error(NameError, f"duplicated scalar symbol {scalar}")
|
|
110
|
+
chars.append(scalar)
|
|
111
|
+
self.position = position
|
|
112
|
+
self.direction = direction
|
|
113
|
+
self.scalar = scalar
|
|
114
|
+
|
|
115
|
+
def __repr__(self):
|
|
116
|
+
pos = self.position.dimensions
|
|
117
|
+
di = self.direction.dimensions
|
|
118
|
+
return f'({pos[0] if pos[0] != 1 else ""}i+' \
|
|
119
|
+
f'{pos[1] if pos[1] != 1 else ""}j+' \
|
|
120
|
+
f'{pos[2] if pos[2] != 1 else ""}k) + ' \
|
|
121
|
+
f'{self.scalar}' \
|
|
122
|
+
f'({di[0] if di[0] != 1 else ""}i+' \
|
|
123
|
+
f'{di[1] if di[1] != 1 else ""}j+' \
|
|
124
|
+
f'{di[2] if di[2] != 1 else ""}k)'
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
p = Vector([1,2,3])
|
|
128
|
+
d = Vector([1,2,3])
|
|
129
|
+
l1 = Line(p, d, 'r')
|
|
130
|
+
|
|
131
|
+
print(l1)
|
|
132
|
+
|
HHLtools/RPN.py
ADDED
|
File without changes
|
HHLtools/__init__.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""
|
|
2
|
+
HHLtools
|
|
3
|
+
|
|
4
|
+
DESCRIPTION
|
|
5
|
+
===================================================
|
|
6
|
+
Noting here, but you can import my sub-packages
|
|
7
|
+
|
|
8
|
+
ADT: support some abstract data types
|
|
9
|
+
CN: support some Chinese keywords
|
|
10
|
+
Herror: some of my custom errors
|
|
11
|
+
Hmath: some math functions
|
|
12
|
+
prints: support print with different styles
|
|
13
|
+
===================================================
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
HHLtools/lang.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
真 = True
|
|
2
|
+
假 = False
|
|
3
|
+
输出 = print
|
|
4
|
+
输入 = input
|
|
5
|
+
范围 = range
|
|
6
|
+
整型 = int
|
|
7
|
+
浮点型 = float
|
|
8
|
+
字符串 = str
|
|
9
|
+
长度 = len
|
|
10
|
+
解析 = eval
|
|
11
|
+
最大值 = max
|
|
12
|
+
最小值 = min
|
|
13
|
+
打开 = open
|
|
14
|
+
绝对值 = abs
|
|
15
|
+
字符 = chr
|
|
16
|
+
执行 = exec
|
|
17
|
+
是否属于 = isinstance
|
|
18
|
+
编号 = ord
|
|
19
|
+
保留小数 = round
|
|
20
|
+
求和 = sum
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class IO:
|
|
25
|
+
def __init__(self):
|
|
26
|
+
pass
|
|
27
|
+
def __lshift__(self, other):
|
|
28
|
+
print(other)
|
|
29
|
+
|
|
30
|
+
cout = IO()
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
HHLtools/prints.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from HHLtools.Herror import *
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class FontStyle:
|
|
5
|
+
DEFAULT = 0
|
|
6
|
+
BOLD = 1
|
|
7
|
+
UNDERLINE = 4
|
|
8
|
+
BLINK = 5
|
|
9
|
+
REVERSE = 7
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class FontColor:
|
|
13
|
+
BLACK = 30
|
|
14
|
+
RED = 31
|
|
15
|
+
GREEN = 32
|
|
16
|
+
YELLOW = 33
|
|
17
|
+
BLUE = 34
|
|
18
|
+
PURPLE = 35
|
|
19
|
+
CYAN = 36
|
|
20
|
+
WHITE = 37
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class BackgroundColor:
|
|
24
|
+
DEFAULT = 0
|
|
25
|
+
BLACK = 40
|
|
26
|
+
RED = 41
|
|
27
|
+
GREEN = 42
|
|
28
|
+
YELLOW = 43
|
|
29
|
+
BLUE = 44
|
|
30
|
+
PURPLE = 45
|
|
31
|
+
CYAN = 46
|
|
32
|
+
WHITE = 47
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def prints(content, fontStyle=None, fontColor=None, backgroundColor=None):
|
|
36
|
+
codes = []
|
|
37
|
+
if fontStyle is not None and fontStyle != 0:
|
|
38
|
+
codes.append(str(fontStyle))
|
|
39
|
+
if fontColor is not None:
|
|
40
|
+
codes.append(str(fontColor))
|
|
41
|
+
if backgroundColor is not None:
|
|
42
|
+
codes.append(str(backgroundColor))
|
|
43
|
+
print(f"\033[{';'.join(codes)}m{content}\033[0m")
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: hhltools
|
|
3
|
+
Version: 1.2.7
|
|
4
|
+
Summary: A tool for CAIE 9618 learner, and some math function
|
|
5
|
+
Author: hhaolin
|
|
6
|
+
Author-email: 2813579566@qq.com
|
|
7
|
+
License: MIT
|
|
8
|
+
Keywords: HHLtools
|
|
9
|
+
Platform: all
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Natural Language :: Chinese (Simplified)
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.5
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
25
|
+
|
|
26
|
+
HHLTools
|
|
27
|
+
--------------------------
|
|
28
|
+
2022/8/7:
|
|
29
|
+
| 1.0.0 The FIRST version!
|
|
30
|
+
| 1.0.1 fix bugs
|
|
31
|
+
| 1.0.2 add fibonacci
|
|
32
|
+
| 1.0.3 fix bugs
|
|
33
|
+
|
|
34
|
+
2022/9/17:
|
|
35
|
+
| 1.0.4 add stack and queue
|
|
36
|
+
|
|
37
|
+
2022/9/28
|
|
38
|
+
| 1.0.5 fix bugs
|
|
39
|
+
|
|
40
|
+
2022/10/2
|
|
41
|
+
| 1.0.6 add Hmath
|
|
42
|
+
|
|
43
|
+
2022/10/28
|
|
44
|
+
| 1.0.7 add prints,python 3.11 available
|
|
45
|
+
|
|
46
|
+
2022/11/4
|
|
47
|
+
| 1.0.8 Chinese extension
|
|
48
|
+
| 1.0.8.1 fix bugs
|
|
49
|
+
|
|
50
|
+
2023/4/21
|
|
51
|
+
| 1.1.0 add linked list, and some useful modifications to previous function
|
|
52
|
+
|
|
53
|
+
2023/4/22
|
|
54
|
+
| 1.2.0 fix bugs, modify the error display, add Vector (only 2 or 3 dimensions)
|
|
55
|
+
| 1.2.1 fix bugs, remove fibonacci
|
|
56
|
+
|
|
57
|
+
2023/12/20
|
|
58
|
+
| 1.2.2 fix bugs
|
|
59
|
+
| 1.2.3 fix bugs
|
|
60
|
+
| 1.2.4 fix bugs
|
|
61
|
+
|
|
62
|
+
2026/2/12
|
|
63
|
+
| 1.2.6 fix prints bugs
|
|
64
|
+
|
|
65
|
+
2026/9/3
|
|
66
|
+
| 1.2.7 fix bugs
|
|
67
|
+
|
|
68
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
HHLtools/ADT.py,sha256=SJLqUdqFf7r3C_qyue_RaM4BNhbd2vUyNxXBeTMP6H8,8172
|
|
2
|
+
HHLtools/Herror.py,sha256=XRCgJorxrf9GnX_YpBlUj2VAMqQzvtjlKp2R5w7Sahk,590
|
|
3
|
+
HHLtools/Hmath.py,sha256=dnBSXLRUu42pzvwkuTSfz81QVjvUbmkzXIlV6L9ZT40,5755
|
|
4
|
+
HHLtools/RPN.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
HHLtools/__init__.py,sha256=UeFqPVt9a9xE5ODubTwIPnEJQGKkr1gwtpMokoN0Fe8,381
|
|
6
|
+
HHLtools/lang.py,sha256=naTpcOymuBqTrV5P8sMAJkUB5uQqev_qsJ_uEMZt9CY,425
|
|
7
|
+
HHLtools/prints.py,sha256=GaxZYuIDf83iS4IGd_2j1OdW5wEFa7mGcZUU5gmxF6g,799
|
|
8
|
+
hhltools-1.2.7.dist-info/METADATA,sha256=9VTXFIWNZ6uKa373NqF2H1IWXKdSRKmqEwL6o--qt-4,1708
|
|
9
|
+
hhltools-1.2.7.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
|
|
10
|
+
hhltools-1.2.7.dist-info/top_level.txt,sha256=iWPR0VidexazFhZwXCYAmN4VW8BPH7H6s7y1PC-UvXE,9
|
|
11
|
+
hhltools-1.2.7.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
HHLtools
|