kevin-toolbox-dev 1.3.6__py3-none-any.whl → 1.3.8__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.
- kevin_toolbox/__init__.py +2 -2
- kevin_toolbox/computer_science/algorithm/registration/registry.py +10 -2
- kevin_toolbox/nested_dict_list/serializer/write.py +1 -0
- kevin_toolbox/patches/for_matplotlib/__init__.py +1 -1
- kevin_toolbox/patches/for_matplotlib/clear_border_of_axes.py +34 -0
- kevin_toolbox/patches/for_matplotlib/color/__init__.py +4 -0
- kevin_toolbox/patches/for_matplotlib/color/color_format.py +7 -0
- kevin_toolbox/patches/for_matplotlib/color/convert_format.py +108 -0
- kevin_toolbox/patches/for_matplotlib/color/generate_color_list.py +50 -0
- kevin_toolbox/patches/for_matplotlib/color/get_format.py +12 -0
- kevin_toolbox/patches/for_matplotlib/common_charts/plot_lines.py +1 -1
- kevin_toolbox/patches/for_matplotlib/common_charts/plot_scatters.py +1 -1
- kevin_toolbox/patches/for_matplotlib/common_charts/plot_scatters_matrix.py +1 -1
- kevin_toolbox/patches/for_optuna/build_study.py +1 -1
- kevin_toolbox_dev-1.3.8.dist-info/METADATA +58 -0
- {kevin_toolbox_dev-1.3.6.dist-info → kevin_toolbox_dev-1.3.8.dist-info}/RECORD +18 -13
- kevin_toolbox/patches/for_matplotlib/generate_color_list.py +0 -33
- kevin_toolbox_dev-1.3.6.dist-info/METADATA +0 -95
- {kevin_toolbox_dev-1.3.6.dist-info → kevin_toolbox_dev-1.3.8.dist-info}/WHEEL +0 -0
- {kevin_toolbox_dev-1.3.6.dist-info → kevin_toolbox_dev-1.3.8.dist-info}/top_level.txt +0 -0
kevin_toolbox/__init__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
__version__ = "1.3.
|
1
|
+
__version__ = "1.3.8"
|
2
2
|
|
3
3
|
|
4
4
|
import os
|
@@ -12,5 +12,5 @@ os.system(
|
|
12
12
|
os.system(
|
13
13
|
f'python {os.path.split(__file__)[0]}/env_info/check_validity_and_uninstall.py '
|
14
14
|
f'--package_name kevin-toolbox-dev '
|
15
|
-
f'--expiration_timestamp
|
15
|
+
f'--expiration_timestamp 1739089473 --verbose 0'
|
16
16
|
)
|
@@ -283,17 +283,25 @@ class Registry:
|
|
283
283
|
# (快速判断)判断该模块所在目录是否在 path_set 中
|
284
284
|
if loader.path not in path_set:
|
285
285
|
continue
|
286
|
+
|
287
|
+
# 使用 find_spec 代替 find_module
|
288
|
+
module_spec = loader.find_spec(module_name)
|
289
|
+
if module_spec is None:
|
290
|
+
continue
|
291
|
+
path = module_spec.origin # 获取模块的路径
|
292
|
+
|
286
293
|
# is_pkg:
|
287
294
|
# - 为 True 时表示当前遍历到的模块是一个包(即一个包含其他模块或子包的目录)
|
288
295
|
# - 为 False 时表示当前模块是一个普通的 Python 模块(文件),不包含其他模块或子包。
|
289
296
|
if is_pkg:
|
290
297
|
# 若是目录形式的 package,判断是否满足 Path_Ignorer 中的 dirs 对应的规则
|
291
|
-
path = os.path.dirname(loader.find_module(module_name).path)
|
298
|
+
# path = os.path.dirname(loader.find_module(module_name).path)
|
299
|
+
path = os.path.dirname(path)
|
292
300
|
if path_ignorer(Ignore_Scope.DIRS, True, os.path.islink(path), path):
|
293
301
|
continue
|
294
302
|
else:
|
295
303
|
# 若该模块是 module,判断该模块的文件路径是否满足 Path_Ignorer 中的 files 对应的规则
|
296
|
-
path = loader.find_module(module_name).path
|
304
|
+
# path = loader.find_module(module_name).path
|
297
305
|
if path_ignorer(Ignore_Scope.FILES, False, os.path.islink(path), path):
|
298
306
|
continue
|
299
307
|
# 若该模块与调用的文件相同,则报错。
|
@@ -211,6 +211,7 @@ def write(var, output_dir, settings=None, traversal_mode=Traversal_Mode.BFS, b_p
|
|
211
211
|
file_path=os.path.join(temp_output_dir, "record.json"), b_use_suggested_converter=True)
|
212
212
|
|
213
213
|
# 打包成 .tar 文件
|
214
|
+
for_os.remove(path=tgt_path, ignore_errors=True)
|
214
215
|
if b_pack_into_tar:
|
215
216
|
for_os.pack(source=temp_output_dir)
|
216
217
|
os.rename(temp_output_dir + ".tar", output_dir + ".tar")
|
@@ -0,0 +1,34 @@
|
|
1
|
+
def clear_border_of_axes(ax):
|
2
|
+
"""
|
3
|
+
用于清除 ax 中的坐标轴和 ticks
|
4
|
+
"""
|
5
|
+
ax.set_xticks([])
|
6
|
+
ax.set_yticks([])
|
7
|
+
ax.spines['left'].set_color('none')
|
8
|
+
ax.spines['right'].set_color('none')
|
9
|
+
ax.spines['bottom'].set_color('none')
|
10
|
+
ax.spines['top'].set_color('none')
|
11
|
+
return ax
|
12
|
+
|
13
|
+
|
14
|
+
if __name__ == '__main__':
|
15
|
+
import matplotlib.pyplot as plt
|
16
|
+
|
17
|
+
#
|
18
|
+
fig, ax = plt.subplots()
|
19
|
+
|
20
|
+
x = [1, 4]
|
21
|
+
y = [1, 10]
|
22
|
+
ax.plot(x, y)
|
23
|
+
|
24
|
+
# 设置坐标轴的范围,以便更好地展示直线
|
25
|
+
ax.set_xlim([0, 5])
|
26
|
+
ax.set_ylim([0, 15])
|
27
|
+
|
28
|
+
# 添加标题和坐标轴标签
|
29
|
+
ax.set_xlabel('X')
|
30
|
+
ax.set_ylabel('Y')
|
31
|
+
clear_border_of_axes(ax)
|
32
|
+
|
33
|
+
# 显示图形
|
34
|
+
plt.show()
|
@@ -0,0 +1,108 @@
|
|
1
|
+
from kevin_toolbox.patches.for_matplotlib.color import Color_Format, get_format
|
2
|
+
|
3
|
+
|
4
|
+
def hex_to_rgba(hex_color):
|
5
|
+
hex_color = hex_color.lstrip('#')
|
6
|
+
assert len(hex_color) in (6, 8), \
|
7
|
+
f'hex_color should be 6 or 8 characters long (not including #). but got {len(hex_color)}'
|
8
|
+
res = list(int(hex_color[i * 2:i * 2 + 2], 16) for i in range(len(hex_color) // 2))
|
9
|
+
if len(res) not in (3, 4):
|
10
|
+
breakpoint()
|
11
|
+
if len(res) == 4:
|
12
|
+
res[3] /= 255
|
13
|
+
return tuple(res)
|
14
|
+
|
15
|
+
|
16
|
+
def rgba_to_hex(rgba):
|
17
|
+
assert len(rgba) in (3, 4), \
|
18
|
+
f'rgba should be 3 or 4 elements long. but got {len(rgba)}'
|
19
|
+
if len(rgba) == 4:
|
20
|
+
rgba = list(rgba)
|
21
|
+
rgba[3] = max(0, min(255, int(255 * rgba[3])))
|
22
|
+
res = "#"
|
23
|
+
for i in rgba:
|
24
|
+
res += f'{i:02X}'
|
25
|
+
return res
|
26
|
+
|
27
|
+
|
28
|
+
NAME_TO_HEX = {
|
29
|
+
'blue': '#0000FF',
|
30
|
+
'red': '#FF0000',
|
31
|
+
'green': '#008000',
|
32
|
+
'orange': '#FFA500',
|
33
|
+
'purple': '#800080',
|
34
|
+
'yellow': '#FFFF00',
|
35
|
+
'brown': '#A52A2A',
|
36
|
+
'pink': '#FFC0CB',
|
37
|
+
'gray': '#808080',
|
38
|
+
'olive': '#808000',
|
39
|
+
'cyan': '#00FFFF'
|
40
|
+
}
|
41
|
+
HEX_TO_NAME = {v: k for k, v in NAME_TO_HEX.items()}
|
42
|
+
|
43
|
+
|
44
|
+
def natural_name_to_hex(name):
|
45
|
+
global NAME_TO_HEX
|
46
|
+
name = name.lower()
|
47
|
+
assert name in NAME_TO_HEX, \
|
48
|
+
f'{name} is not a valid color name.'
|
49
|
+
return NAME_TO_HEX[name]
|
50
|
+
|
51
|
+
|
52
|
+
def hex_to_natural_name(hex_color):
|
53
|
+
global HEX_TO_NAME
|
54
|
+
hex_color = hex_color.upper()[:7]
|
55
|
+
assert hex_color in HEX_TO_NAME, \
|
56
|
+
f'{hex_color} does not has corresponding color name.'
|
57
|
+
return HEX_TO_NAME[hex_color]
|
58
|
+
|
59
|
+
|
60
|
+
CONVERT_PROCESS_S = {
|
61
|
+
(Color_Format.HEX_STR, Color_Format.NATURAL_NAME): hex_to_natural_name, # (from, to): process
|
62
|
+
(Color_Format.HEX_STR, Color_Format.RGBA_ARRAY): hex_to_rgba,
|
63
|
+
(Color_Format.NATURAL_NAME, Color_Format.HEX_STR): natural_name_to_hex,
|
64
|
+
(Color_Format.NATURAL_NAME, Color_Format.RGBA_ARRAY): lambda x: hex_to_rgba(natural_name_to_hex(x)),
|
65
|
+
(Color_Format.RGBA_ARRAY, Color_Format.HEX_STR): rgba_to_hex,
|
66
|
+
(Color_Format.RGBA_ARRAY, Color_Format.NATURAL_NAME): lambda x: hex_to_natural_name(rgba_to_hex(x))
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
def convert_format(var, output_format, input_format=None):
|
71
|
+
"""
|
72
|
+
在各种颜色格式之间进行转换
|
73
|
+
|
74
|
+
参数:
|
75
|
+
var:
|
76
|
+
input_format: <str> 描述输入的格式。
|
77
|
+
支持 HEX_STR、NATURAL_NAME、RGBA_ARRAY 等格式,
|
78
|
+
默认为 None,此时将根据输入推断格式
|
79
|
+
output_format: <str/list of str> 输出的目标格式。
|
80
|
+
当输入是一个 tuple/list 时,将输出其中任一格式,具体规则为:
|
81
|
+
- 当 input_format 不在可选的输出格式中时,优先按照第一个输出格式进行转换。
|
82
|
+
若转换失败,则按照第二个输出格式进行转换。依次类推。
|
83
|
+
- 当 input_format 在可选的输出格式中时,不进行转换。
|
84
|
+
"""
|
85
|
+
global CONVERT_PROCESS_S
|
86
|
+
if input_format is None:
|
87
|
+
input_format = get_format(var=var)
|
88
|
+
input_format = Color_Format(input_format)
|
89
|
+
if not isinstance(output_format, (list, tuple,)):
|
90
|
+
output_format = [output_format]
|
91
|
+
output_format = [Color_Format(i) for i in output_format]
|
92
|
+
|
93
|
+
if input_format in output_format:
|
94
|
+
return var
|
95
|
+
else:
|
96
|
+
for output_format_i in output_format:
|
97
|
+
try:
|
98
|
+
return CONVERT_PROCESS_S[(input_format, output_format_i)](var)
|
99
|
+
except Exception as e:
|
100
|
+
raise Exception(f'fail to convert {var} from {input_format} to {output_format}, beacause: {e}')
|
101
|
+
|
102
|
+
|
103
|
+
if __name__ == '__main__':
|
104
|
+
print(hex_to_rgba('#FF57337F'))
|
105
|
+
print(rgba_to_hex((255, 87, 51, 0.5)))
|
106
|
+
print(natural_name_to_hex('pink'))
|
107
|
+
print(convert_format(var='#FF57337F', input_format='hex_str', output_format='rgba_array'))
|
108
|
+
print(convert_format(var="#0000FF", output_format="rgba_array"))
|
@@ -0,0 +1,50 @@
|
|
1
|
+
from kevin_toolbox.patches.for_matplotlib.color import Color_Format, convert_format
|
2
|
+
from kevin_toolbox.patches.for_numpy import random
|
3
|
+
|
4
|
+
PREDEFINED = ['blue', 'red', 'green', 'orange', 'purple', 'yellow', "brown", "pink", "gray", "olive", "cyan"]
|
5
|
+
PREDEFINED = [convert_format(var=i, output_format=Color_Format.HEX_STR) for i in PREDEFINED]
|
6
|
+
|
7
|
+
population = tuple('0123456789ABCDEF')
|
8
|
+
|
9
|
+
|
10
|
+
def generate_color_list(nums, seed=None, rng=None, exclude_ls=None, output_format=Color_Format.HEX_STR):
|
11
|
+
"""
|
12
|
+
生成颜色列表
|
13
|
+
|
14
|
+
参数:
|
15
|
+
nums: <int> 生成颜色的数量
|
16
|
+
seed,rng: 随机种子或随机生成器,二选一
|
17
|
+
exclude: <list of str> 需要排除的颜色
|
18
|
+
output_format: <Color_Format/str> 输出格式
|
19
|
+
支持 HEX_STR、RGBA_ARRAY 两种格式
|
20
|
+
返回:
|
21
|
+
不包含 alpha 透明度值的颜色列表
|
22
|
+
"""
|
23
|
+
global PREDEFINED, population
|
24
|
+
assert output_format in [Color_Format.HEX_STR, Color_Format.RGBA_ARRAY]
|
25
|
+
output_format = Color_Format(output_format)
|
26
|
+
if exclude_ls is None:
|
27
|
+
exclude_ls = []
|
28
|
+
assert isinstance(exclude_ls, (list, tuple))
|
29
|
+
exclude_ls = set(convert_format(var=i, output_format=Color_Format.HEX_STR) for i in exclude_ls)
|
30
|
+
rng = random.get_rng(seed=seed, rng=rng)
|
31
|
+
|
32
|
+
colors = [i for i in PREDEFINED if i not in exclude_ls][:nums] # 优先输出预定义的颜色
|
33
|
+
|
34
|
+
# 随机生成剩余数量的颜色
|
35
|
+
while len(colors) < nums:
|
36
|
+
c = "#" + ''.join(
|
37
|
+
rng.choice(population, size=6, replace=True))
|
38
|
+
if c not in colors and c not in exclude_ls:
|
39
|
+
colors.append(c)
|
40
|
+
colors = [convert_format(c, output_format=output_format) for c in colors]
|
41
|
+
|
42
|
+
return colors
|
43
|
+
|
44
|
+
|
45
|
+
if __name__ == '__main__':
|
46
|
+
color_list = generate_color_list(1, exclude_ls=['blue'])
|
47
|
+
print(color_list)
|
48
|
+
|
49
|
+
color_list = generate_color_list(nums=1, seed=114, exclude_ls=['#0000FF'])
|
50
|
+
print(color_list)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
from kevin_toolbox.patches.for_matplotlib.color import Color_Format
|
2
|
+
|
3
|
+
|
4
|
+
def get_format(var):
|
5
|
+
if isinstance(var, str):
|
6
|
+
if var.startswith("#"):
|
7
|
+
res = Color_Format.HEX_STR
|
8
|
+
else:
|
9
|
+
res = Color_Format.NATURAL_NAME
|
10
|
+
else:
|
11
|
+
res = Color_Format.RGBA_ARRAY
|
12
|
+
return res
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import os
|
2
2
|
import matplotlib.pyplot as plt
|
3
3
|
from kevin_toolbox.patches.for_os.path import replace_illegal_chars
|
4
|
-
from kevin_toolbox.patches.for_matplotlib import generate_color_list
|
4
|
+
from kevin_toolbox.patches.for_matplotlib.color import generate_color_list
|
5
5
|
|
6
6
|
|
7
7
|
def plot_lines(data_s, title, x_name, output_dir=None, **kwargs):
|
@@ -2,7 +2,7 @@ import os
|
|
2
2
|
import pandas as pd
|
3
3
|
import seaborn as sns
|
4
4
|
import matplotlib.pyplot as plt
|
5
|
-
from kevin_toolbox.patches.for_matplotlib import generate_color_list
|
5
|
+
from kevin_toolbox.patches.for_matplotlib.color import generate_color_list
|
6
6
|
from kevin_toolbox.patches.for_os.path import replace_illegal_chars
|
7
7
|
|
8
8
|
|
@@ -24,7 +24,7 @@ def build_study(output_dir=None, feasible_domain_path=None, **kwargs):
|
|
24
24
|
if "storage" in kwargs:
|
25
25
|
if isinstance(kwargs["storage"], (str,)) and kwargs["storage"].startswith("mysql:"):
|
26
26
|
temp_ls = list(kwargs["storage"].split(":", 1))
|
27
|
-
|
27
|
+
temp_ls[0] = "mysql+pymysql"
|
28
28
|
kwargs["storage"] = ":".join(temp_ls)
|
29
29
|
elif isinstance(kwargs["storage"], (dict,)):
|
30
30
|
kwargs["storage"] = build_storage(output_dir=output_dir, **kwargs["storage"]).url
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: kevin-toolbox-dev
|
3
|
+
Version: 1.3.8
|
4
|
+
Summary: 一个常用的工具代码包集合
|
5
|
+
Home-page: https://github.com/cantbeblank96/kevin_toolbox
|
6
|
+
Download-URL: https://github.com/username/your-package/archive/refs/tags/v1.0.0.tar.gz
|
7
|
+
Author: kevin hsu
|
8
|
+
Author-email: xukaiming1996@163.com
|
9
|
+
License: MIT
|
10
|
+
Keywords: mathematics,pytorch,numpy,machine-learning,algorithm
|
11
|
+
Platform: UNKNOWN
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
13
|
+
Classifier: Programming Language :: Python
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
15
|
+
Requires-Python: >=3.6
|
16
|
+
Description-Content-Type: text/markdown
|
17
|
+
Requires-Dist: torch (>=1.2.0)
|
18
|
+
Requires-Dist: numpy (>=1.19.0)
|
19
|
+
Provides-Extra: plot
|
20
|
+
Requires-Dist: matplotlib (>=3.0) ; extra == 'plot'
|
21
|
+
Provides-Extra: rest
|
22
|
+
Requires-Dist: pytest (>=6.2.5) ; extra == 'rest'
|
23
|
+
Requires-Dist: line-profiler (>=3.5) ; extra == 'rest'
|
24
|
+
|
25
|
+
# kevin_toolbox
|
26
|
+
|
27
|
+
一个通用的工具代码包集合
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
环境要求
|
32
|
+
|
33
|
+
```shell
|
34
|
+
numpy>=1.19
|
35
|
+
pytorch>=1.2
|
36
|
+
```
|
37
|
+
|
38
|
+
安装方法:
|
39
|
+
|
40
|
+
```shell
|
41
|
+
pip install kevin-toolbox --no-dependencies
|
42
|
+
```
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
[项目地址 Repo](https://github.com/cantbeblank96/kevin_toolbox)
|
47
|
+
|
48
|
+
[使用指南 User_Guide](./notes/User_Guide.md)
|
49
|
+
|
50
|
+
[免责声明 Disclaimer](./notes/Disclaimer.md)
|
51
|
+
|
52
|
+
[版本更新记录](./notes/Release_Record.md):
|
53
|
+
|
54
|
+
- v 1.3.8 (2024-08-13)【bug fix】【temporary version】
|
55
|
+
- computer_science.algorithm.registration
|
56
|
+
- modify Registry.collect_from_paths() for python>=3.12,在更高版本的python的importlib中 find_module() 方法已被废弃和移除,因此需要替换为 find_spec() 方法。
|
57
|
+
|
58
|
+
|
@@ -1,4 +1,4 @@
|
|
1
|
-
kevin_toolbox/__init__.py,sha256=
|
1
|
+
kevin_toolbox/__init__.py,sha256=JvwRDuUZBeSChmbw5mWQZfrgV96Q990PrPXKOsPg9nk,410
|
2
2
|
kevin_toolbox/computer_science/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
kevin_toolbox/computer_science/algorithm/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
4
4
|
kevin_toolbox/computer_science/algorithm/cache_manager/__init__.py,sha256=p2hddkZ1HfYF9-m2Hx-o9IotwQHd4QwDCePy2ADpTDA,41
|
@@ -42,7 +42,7 @@ kevin_toolbox/computer_science/algorithm/pareto_front/__init__.py,sha256=F1uD0ZT
|
|
42
42
|
kevin_toolbox/computer_science/algorithm/pareto_front/get_pareto_points_idx.py,sha256=WR-_9BruqAWH0QECa40b1Iz1_k6uesBrUYrn2s9ALBM,3008
|
43
43
|
kevin_toolbox/computer_science/algorithm/pareto_front/optimum_picker.py,sha256=wnYN2s9r2g1z5wF0FvFLawRYITUJbMXbBs4TPsdvhlE,9923
|
44
44
|
kevin_toolbox/computer_science/algorithm/registration/__init__.py,sha256=teEd9HkrB6baLpwNwae5c4wn0QRwV3KtBv-2V9-Z7cc,49
|
45
|
-
kevin_toolbox/computer_science/algorithm/registration/registry.py,sha256=
|
45
|
+
kevin_toolbox/computer_science/algorithm/registration/registry.py,sha256=YNYKSPV2AIUVTup-YheJcT1Pu21llgDtyCWxpsSCaZo,17666
|
46
46
|
kevin_toolbox/computer_science/algorithm/scheduler/__init__.py,sha256=ENzZsNaMu6ISilTxeE3_EP_L0dNi8SI7IYdTdxic2nw,76
|
47
47
|
kevin_toolbox/computer_science/algorithm/scheduler/strategy_manager.py,sha256=yLh2GBEsedJhqvB90zEmAOdZ8IF7nn1r9lSE95BbnEQ,12194
|
48
48
|
kevin_toolbox/computer_science/algorithm/scheduler/trigger.py,sha256=YlqTX2TE44BwcQI0jfvcBCJhouhdAYuhwu2QJhuBWP0,4470
|
@@ -239,7 +239,7 @@ kevin_toolbox/nested_dict_list/serializer/enum_variable.py,sha256=RWPydtXI4adOJY
|
|
239
239
|
kevin_toolbox/nested_dict_list/serializer/read.py,sha256=BjsEWYoyvEHgRKKVKw0suf1ukug2tAFLMCAmEnndqgg,2945
|
240
240
|
kevin_toolbox/nested_dict_list/serializer/saved_node_name_builder.py,sha256=qsD-rmDmVaKZP4owN3Wm3QY2Ksi71XlYETqw4VmIsSU,1011
|
241
241
|
kevin_toolbox/nested_dict_list/serializer/variable.py,sha256=ZywG6obipRBCGY1cY42gdvsuWk8GLZXr6eCYcW7ZJ9c,392
|
242
|
-
kevin_toolbox/nested_dict_list/serializer/write.py,sha256=
|
242
|
+
kevin_toolbox/nested_dict_list/serializer/write.py,sha256=HDmwEQHTnhFYITItFxM5Zw7sl7F4a50_MN59mR-pU3g,21898
|
243
243
|
kevin_toolbox/nested_dict_list/serializer/backends/__init__.py,sha256=8g7y-L3cmctxao616dVkGiot00FJzKNmNl_69V2bSmE,39
|
244
244
|
kevin_toolbox/nested_dict_list/serializer/backends/_json_.py,sha256=oJXIc28yjxsD9ZJuw120pVHTVsTzCdaXEhVUSQeydq4,2145
|
245
245
|
kevin_toolbox/nested_dict_list/serializer/backends/_ndl.py,sha256=3YkAq_Bqzehnw0kGxqxwtF6uUz0EV37tLI-1ROHjixY,1794
|
@@ -260,18 +260,23 @@ kevin_toolbox/nested_dict_list/value_parser/replace_identical_with_reference.py,
|
|
260
260
|
kevin_toolbox/patches/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
261
261
|
kevin_toolbox/patches/for_logging/__init__.py,sha256=xymF6mjwY4Cin7CoEwanFY5ZVk8oY0pDLqjZAGa7_Rg,39
|
262
262
|
kevin_toolbox/patches/for_logging/build_logger.py,sha256=0UoRMKaERd8wlHGTiNR3dbLQRAtXcb0QZuGkX2oFgGo,3071
|
263
|
-
kevin_toolbox/patches/for_matplotlib/__init__.py,sha256=
|
263
|
+
kevin_toolbox/patches/for_matplotlib/__init__.py,sha256=Pr9jXGomD3wBvtKE8p9V7rKDY4YBLAP5ayWEuBbDdk4,182
|
264
264
|
kevin_toolbox/patches/for_matplotlib/add_trajectory_2d.py,sha256=mKXRUNJiEZBcff3pAkwL_gcKGn55CLRhYCTSd3fj1Go,1837
|
265
265
|
kevin_toolbox/patches/for_matplotlib/add_trajectory_3d.py,sha256=VGlZfVY0xhUBOUzWJVPxZZNHHRvWLR0HZzhADA_cbsU,1696
|
266
266
|
kevin_toolbox/patches/for_matplotlib/arrow3d.py,sha256=JSnNMr1hU2N4FUX526I4MDr04mksDgu4VuegYFDxk1Q,1361
|
267
|
-
kevin_toolbox/patches/for_matplotlib/
|
267
|
+
kevin_toolbox/patches/for_matplotlib/clear_border_of_axes.py,sha256=aQtzrw4W-DUffvwTqsA9Ez7b_vj-C58ROE_UcCKIawQ,725
|
268
|
+
kevin_toolbox/patches/for_matplotlib/color/__init__.py,sha256=5VGALqLCFsGqBWrOnFouVxkpp_DfqMIcKDLzYPdOTy8,170
|
269
|
+
kevin_toolbox/patches/for_matplotlib/color/color_format.py,sha256=ADwKfPmryxOuN691ol_2djOIkGQGJcnUAcqE3pbxGJs,205
|
270
|
+
kevin_toolbox/patches/for_matplotlib/color/convert_format.py,sha256=fmFwirEqF2OXuH3qiQD_vCTUBqsqDIDR6F62mIX5XmU,4040
|
271
|
+
kevin_toolbox/patches/for_matplotlib/color/generate_color_list.py,sha256=TZm-TkOuJbFzJ0_RklliQ9SHjMUhJvjbu7DUJGtgvw0,1993
|
272
|
+
kevin_toolbox/patches/for_matplotlib/color/get_format.py,sha256=l_vX8DUsWHNzLwveuF60TLcbQ_P7PvVt1yH_7FjElDs,312
|
268
273
|
kevin_toolbox/patches/for_matplotlib/common_charts/__init__.py,sha256=etey2r0LO4PTLnH3VzcRKFe7IHP9I5TMW3DEz3sQx2c,270
|
269
274
|
kevin_toolbox/patches/for_matplotlib/common_charts/plot_bars.py,sha256=crS1h79Dz6gGOnqhjuuN2o5pl8CekhCenx9lRz5KPiI,1887
|
270
275
|
kevin_toolbox/patches/for_matplotlib/common_charts/plot_confusion_matrix.py,sha256=dxkgiXeoIdtXzcg_HoUnRGqhJk91iNoB5VbLuoG7o_M,2191
|
271
276
|
kevin_toolbox/patches/for_matplotlib/common_charts/plot_distribution.py,sha256=stuyaULWM_vVW3r9WrpzGqA8rohQrdNKT3Agsbobqck,2396
|
272
|
-
kevin_toolbox/patches/for_matplotlib/common_charts/plot_lines.py,sha256=
|
273
|
-
kevin_toolbox/patches/for_matplotlib/common_charts/plot_scatters.py,sha256=
|
274
|
-
kevin_toolbox/patches/for_matplotlib/common_charts/plot_scatters_matrix.py,sha256
|
277
|
+
kevin_toolbox/patches/for_matplotlib/common_charts/plot_lines.py,sha256=rb95pupvaiEiGi3o0CP2v-qcOkl1nYF_kgxCTSLGPjI,1991
|
278
|
+
kevin_toolbox/patches/for_matplotlib/common_charts/plot_scatters.py,sha256=whO36bmixjwtsjCS6Ah6zEGJAlJyGcD-wmV3dA6u7mk,1658
|
279
|
+
kevin_toolbox/patches/for_matplotlib/common_charts/plot_scatters_matrix.py,sha256=bf2EfGlPW9dtDfRse1gk8RVxvC8CJ0NeMdrpSw43wFg,1989
|
275
280
|
kevin_toolbox/patches/for_numpy/__init__.py,sha256=SNjZGxTRBn-uzkyZi6Jcz-9juhhZKT8TI70qH-fhGGc,21
|
276
281
|
kevin_toolbox/patches/for_numpy/linalg/__init__.py,sha256=TH-M0Orrakyf9S9A8FiDf3zLHY24gP2SGGTuNmLhDP4,128
|
277
282
|
kevin_toolbox/patches/for_numpy/linalg/cos_similar.py,sha256=bFkfDwrW3maXq5i9ZABidKfg8ZdEdXfFgNzW_uygrM4,423
|
@@ -286,7 +291,7 @@ kevin_toolbox/patches/for_numpy/random/variable.py,sha256=Sam-QZgkx9_IvHzZhpUrXl
|
|
286
291
|
kevin_toolbox/patches/for_optuna/__init__.py,sha256=5ZVEXbL6zp6a0rqH2LPsiErZrgpcILWUEtTyK31gzSY,249
|
287
292
|
kevin_toolbox/patches/for_optuna/build_sampler.py,sha256=0gRv2vPLyr71mlnTi2cJ4_SxO8WAyQOGL8DXiY7o2Es,1705
|
288
293
|
kevin_toolbox/patches/for_optuna/build_storage.py,sha256=kGY7fsWroFJ4TQUGy5j_qG5xDuapdB0H5dy2IKSJoYw,3327
|
289
|
-
kevin_toolbox/patches/for_optuna/build_study.py,sha256=
|
294
|
+
kevin_toolbox/patches/for_optuna/build_study.py,sha256=nDyG8ifHVmMVc0KylD1lU-iO_BlJ49UZwIRdWVUGp-s,2256
|
290
295
|
kevin_toolbox/patches/for_optuna/copy_study.py,sha256=neBGpGuNhVQB5R5wtHem48A2hqBYOXFU1LxxQDUQQw0,2743
|
291
296
|
kevin_toolbox/patches/for_optuna/sample_from_feasible_domain.py,sha256=-Ckwo2N4vhWr08F7ROLfwLWIx4ERwdwn4Q5Ft2JRm7g,7071
|
292
297
|
kevin_toolbox/patches/for_optuna/serialize/__init__.py,sha256=7WTrwFsW1xnW85zECUQtPTRqVUdPU9V1L8UWrFZyyms,35
|
@@ -323,7 +328,7 @@ kevin_toolbox/patches/for_torch/math/get_y_at_x.py,sha256=bfoVcasZ_tMdhR_1Me0Jli
|
|
323
328
|
kevin_toolbox/patches/for_torch/math/my_around.py,sha256=ptpU3ids50gwf663EpHbw7raj9tNrDGBFZ5t_uMNH14,1378
|
324
329
|
kevin_toolbox/patches/for_torch/nn/__init__.py,sha256=aJs3RMqRzQmd8KKDmQW9FxwCqS5yfPqEdg-m0PwlQro,39
|
325
330
|
kevin_toolbox/patches/for_torch/nn/lambda_layer.py,sha256=KUuLiX_Dr4bvRmpAaCW5QTDWDcnMPRnw0jg4NNXTFhM,223
|
326
|
-
kevin_toolbox_dev-1.3.
|
327
|
-
kevin_toolbox_dev-1.3.
|
328
|
-
kevin_toolbox_dev-1.3.
|
329
|
-
kevin_toolbox_dev-1.3.
|
331
|
+
kevin_toolbox_dev-1.3.8.dist-info/METADATA,sha256=_-T8ozrnXN_PHq8oDPy6Eo4PFojwebPLCnGUsaBsFtI,1576
|
332
|
+
kevin_toolbox_dev-1.3.8.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
333
|
+
kevin_toolbox_dev-1.3.8.dist-info/top_level.txt,sha256=S5TeRGF-PwlhsaUEPTI-f2vWrpLmh3axpyI6v-Fi75o,14
|
334
|
+
kevin_toolbox_dev-1.3.8.dist-info/RECORD,,
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import random
|
2
|
-
|
3
|
-
PREDEFINED = ['blue', 'red', 'green', 'orange', 'purple', 'yellow', "brown", "pink", "gray", "olive", "cyan"]
|
4
|
-
|
5
|
-
|
6
|
-
def generate_color_list(nums, seed=None, exclude_ls=None):
|
7
|
-
"""
|
8
|
-
参数:
|
9
|
-
nums: <int> 生成颜色的数量
|
10
|
-
seed: 随机种子
|
11
|
-
exclude: <list of str> 需要排除的颜色
|
12
|
-
"""
|
13
|
-
global PREDEFINED
|
14
|
-
if exclude_ls is None:
|
15
|
-
exclude_ls = []
|
16
|
-
assert isinstance(exclude_ls, (list, tuple))
|
17
|
-
|
18
|
-
colors = [i for i in PREDEFINED if i not in exclude_ls][:nums] # 优先输出预定义的颜色
|
19
|
-
|
20
|
-
# 随机生成剩余数量的颜色
|
21
|
-
if seed is not None:
|
22
|
-
random.seed(seed)
|
23
|
-
while len(colors) < nums:
|
24
|
-
c = "#" + ''.join(random.choices('0123456789ABCDEF', k=6))
|
25
|
-
if c not in colors and c not in exclude_ls:
|
26
|
-
colors.append(c)
|
27
|
-
|
28
|
-
return colors
|
29
|
-
|
30
|
-
|
31
|
-
if __name__ == '__main__':
|
32
|
-
color_list = generate_color_list(20)
|
33
|
-
print(color_list)
|
@@ -1,95 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: kevin-toolbox-dev
|
3
|
-
Version: 1.3.6
|
4
|
-
Summary: 一个常用的工具代码包集合
|
5
|
-
Home-page: https://github.com/cantbeblank96/kevin_toolbox
|
6
|
-
Download-URL: https://github.com/username/your-package/archive/refs/tags/v1.0.0.tar.gz
|
7
|
-
Author: kevin hsu
|
8
|
-
Author-email: xukaiming1996@163.com
|
9
|
-
License: MIT
|
10
|
-
Keywords: mathematics,pytorch,numpy,machine-learning,algorithm
|
11
|
-
Platform: UNKNOWN
|
12
|
-
Classifier: License :: OSI Approved :: MIT License
|
13
|
-
Classifier: Programming Language :: Python
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
15
|
-
Requires-Python: >=3.6
|
16
|
-
Description-Content-Type: text/markdown
|
17
|
-
Requires-Dist: torch (>=1.2.0)
|
18
|
-
Requires-Dist: numpy (>=1.19.0)
|
19
|
-
Provides-Extra: plot
|
20
|
-
Requires-Dist: matplotlib (>=3.0) ; extra == 'plot'
|
21
|
-
Provides-Extra: rest
|
22
|
-
Requires-Dist: pytest (>=6.2.5) ; extra == 'rest'
|
23
|
-
Requires-Dist: line-profiler (>=3.5) ; extra == 'rest'
|
24
|
-
|
25
|
-
# kevin_toolbox
|
26
|
-
|
27
|
-
一个通用的工具代码包集合
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
环境要求
|
32
|
-
|
33
|
-
```shell
|
34
|
-
numpy>=1.19
|
35
|
-
pytorch>=1.2
|
36
|
-
```
|
37
|
-
|
38
|
-
安装方法:
|
39
|
-
|
40
|
-
```shell
|
41
|
-
pip install kevin-toolbox --no-dependencies
|
42
|
-
```
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
[项目地址 Repo](https://github.com/cantbeblank96/kevin_toolbox)
|
47
|
-
|
48
|
-
[使用指南 User_Guide](./notes/User_Guide.md)
|
49
|
-
|
50
|
-
[免责声明 Disclaimer](./notes/Disclaimer.md)
|
51
|
-
|
52
|
-
[版本更新记录](./notes/Release_Record.md):
|
53
|
-
|
54
|
-
- v 1.3.6 (2024-07-03)【new feature】
|
55
|
-
- patches
|
56
|
-
- for_os
|
57
|
-
- 【new feature】add find_files_in_dir(),找出目录下带有给定后缀的所有文件的生成器。
|
58
|
-
- for_os.path
|
59
|
-
- 【new feature】add find_illegal_chars(),找出给定的文件名/路径中出现了哪些非法符号。
|
60
|
-
- 【new feature】add replace_illegal_chars(),将给定的文件名/路径中的非法符号替换为合法形式。
|
61
|
-
- for_matplotlib
|
62
|
-
- 【new feature】add module common_charts,新增模块——常用图表,该模块下包含以下函数:
|
63
|
-
- plot_bars(),绘制柱状图
|
64
|
-
- plot_scatters(),绘制散点图
|
65
|
-
- plot_lines(),绘制折线图
|
66
|
-
- plot_distribution(),绘制分布图
|
67
|
-
- plot_scatters_matrix(),绘制散点图矩阵(常用于多变量关系分析)
|
68
|
-
- plot_confusion_matrix(),绘制混淆矩阵(常用于混淆矩阵、相关性矩阵、特征图可视化)
|
69
|
-
- 添加了测试用例。
|
70
|
-
- data_flow.file
|
71
|
-
- markdown
|
72
|
-
- 【new feature】add save_images_in_ndl(),将ndl结构叶节点下的图片对象保存到 plot_dir 中,并替换为该图片的markdown链接。
|
73
|
-
- 便于对表格中的图片或者列表中的图片进行保存和替换。
|
74
|
-
- 【new feature】add find_tables(),用于从文本中找出markdown格式的表格,并以二维数组的列表形式返回。
|
75
|
-
- 【new feature】add parse_table(),将二维数组形式的表格(比如find_tables()的返回列表的元素),解析成指定的格式。
|
76
|
-
- kevin_notation
|
77
|
-
- 【bug fix】fix bug in Kevin_Notation_Writer,增加检验写入的列的元素数量是否一致,不一致时进行报错。
|
78
|
-
- 【bug fix】fix bug in write(),避免对输入参数 metadata 中的内容进行意料之外的改动。
|
79
|
-
- nested_dict_list
|
80
|
-
- add para b_allow_override to serializer.write to allow overwriting,增加参数用于允许强制覆盖已有文件。
|
81
|
-
- computer_science.algorithm
|
82
|
-
- pareto_front
|
83
|
-
- 【new feature】add Optimum_Picker,帕累托最优值选取器。
|
84
|
-
- 记录并更新帕累托最优值
|
85
|
-
- 同时支持监控以下行为,并触发设定的执行器,详见参数 trigger_for_new 和 trigger_for_out。
|
86
|
-
- 新加值是一个新的帕累托最优值
|
87
|
-
- 抛弃一个不再是最优的旧的最优值
|
88
|
-
- statistician
|
89
|
-
- 【new feature】add Accumulator_for_Ndl,适用于 ndl 结构的统计器。
|
90
|
-
- 【bug fix】fix bug in Accumulator_Base._init_var()
|
91
|
-
- 【new feature】modify Average_Accumulator,在 add() 中新增了 weight 参数用于计算带权重的平均值
|
92
|
-
- modify Exponential_Moving_Average,add_sequence() 不再支持 weight_ls 参数,让该接口与其他类更加一致。
|
93
|
-
- 添加了测试用例。
|
94
|
-
|
95
|
-
|
File without changes
|
File without changes
|