kevin-toolbox-dev 1.4.1__py3-none-any.whl → 1.4.3__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 CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "1.4.1"
1
+ __version__ = "1.4.3"
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 1742651885 --verbose 0'
15
+ f'--expiration_timestamp 1749719201 --verbose 0'
16
16
  )
@@ -21,7 +21,7 @@ class Simple_Node:
21
21
  # - <predecessor_node>: 前继节点名
22
22
  # - <output_name>: 从该前继节点输出的结果中取出对应部分
23
23
  # - <input_name>: 将取出的部分填入到本节点的 self.paras 中对应位置上
24
- # 对于 successor字段,其中保存后继节点的名字
24
+ # 对于 successor 字段,其中保存后继节点的名字
25
25
  self.relation_s = {
26
26
  "predecessor": dict(),
27
27
  "successor": set(),
@@ -210,13 +210,24 @@ def write(var, output_dir, settings=None, traversal_mode=Traversal_Mode.BFS, b_p
210
210
  b_keep_identical_relations=b_keep_identical_relations),
211
211
  file_path=os.path.join(temp_output_dir, "record.json"), b_use_suggested_converter=True)
212
212
 
213
- # 打包成 .tar 文件
213
+ #
214
214
  for_os.remove(path=tgt_path, ignore_errors=True)
215
+ # 打包成 .tar 文件
216
+ src_path = temp_output_dir
215
217
  if b_pack_into_tar:
216
218
  for_os.pack(source=temp_output_dir)
217
- os.rename(temp_output_dir + ".tar", output_dir + ".tar")
218
- else:
219
- os.rename(temp_output_dir, output_dir)
219
+ src_path = temp_output_dir + ".tar"
220
+ # 整理目录结构
221
+ count = 0
222
+ while count < 3:
223
+ try:
224
+ os.rename(src_path, tgt_path)
225
+ break
226
+ except:
227
+ count += 1
228
+ time.sleep(0.5)
229
+ if not os.path.isfile(tgt_path):
230
+ for_os.copy(src=src_path, dst=tgt_path, remove_dst_if_exists=True)
220
231
 
221
232
 
222
233
  def _judge_processed_or_not(processed_s, name):
@@ -1,3 +1,5 @@
1
1
  from .get_rng import get_rng
2
2
  from .truncated_normal import truncated_normal
3
3
  from .truncated_multivariate_normal import truncated_multivariate_normal
4
+ from .set_rng_state import set_rng_state
5
+ from .get_rng_state import get_rng_state
@@ -0,0 +1,5 @@
1
+ def get_rng_state(rng):
2
+ """
3
+ 获取随机生成器的状态
4
+ """
5
+ return rng.bit_generator.state
@@ -0,0 +1,14 @@
1
+ from kevin_toolbox.patches.for_numpy.random import get_rng
2
+
3
+
4
+ def set_rng_state(state, rng=None):
5
+ """
6
+ 加载状态到随机生成器中
7
+
8
+ 参数:
9
+ state:
10
+ rng: 当设置为 None 时,将通过 get_rng() 新建一个 rng,然后加载状态并返回
11
+ """
12
+ rng = rng or get_rng(seed=114514)
13
+ rng.bit_generator.state = state
14
+ return rng
@@ -53,7 +53,7 @@ def show_table(text, doc_dir=None, display_mode_s=None):
53
53
  method(text=part, matrix=table_s["matrix"], doc_dir=doc_dir, table_name=f'Table {idx}')
54
54
  else:
55
55
  # 是表格,且内部无图片,则直接显示
56
- show_image(text=part, doc_dir=None)
56
+ show_image(text=part, doc_dir=doc_dir)
57
57
 
58
58
  # 另一种显示表格的方式是通过 data_editor 来显示,但是对图片的显示效果不好
59
59
  # TODO 可以选择是通过 data_editor 还是 columns,或者原始格式(对本地图片不处理或者使用 base64 代替)来显示表格
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kevin-toolbox-dev
3
- Version: 1.4.1
3
+ Version: 1.4.3
4
4
  Summary: 一个常用的工具代码包集合
5
5
  Home-page: https://github.com/cantbeblank96/kevin_toolbox
6
6
  Download-URL: https://github.com/username/your-package/archive/refs/tags/v1.0.0.tar.gz
@@ -51,17 +51,11 @@ pip install kevin-toolbox --no-dependencies
51
51
 
52
52
  [版本更新记录](./notes/Release_Record.md):
53
53
 
54
- - v 1.4.1 (2024-09-23)【bug fix】【new feature】
55
- - patches
56
- - for_streamlit.markdown
57
- - 【bug fix】fix bug in show_table(),将原来的使用 st.expander 去包裹表格,改为使用 st.tabs 去包裹表格,避免在 streamlit<=1.38.0 下(截止2024-09-23最新版本),因为 st.expander 嵌套使用而造成的报错。具体参看:https://docs.streamlit.io/develop/api-reference/layout/st.expander
58
- - 【bug fix】fix bug in show_table(),修复在 line 56 和 line 25 中对 show_image() 和 st.markdown 的函数参数写错,导致在显示无图表格时反而报错的问题。
59
- - 增加了测试用例。
60
-
61
- - for_matplotlib.common_charts
62
- - 【new feature】 add para replace_zero_division_with to plot_confusion_matrix(),新增参数 replace_zero_division_with 用于指定在normalize时引发除0错误的矩阵元素要使用何种值进行替代。
63
- - 增加了测试用例。
64
-
65
-
54
+ - v 1.4.3 (2024-12-14)【new feature】
55
+ - nested_dict_list.serializer
56
+ - modify write(),使用 while(detect) try it except wait 的结构包裹原来的 os.rename 操作,多次尝试,避免因为突发的文件系统阻塞(OSError: [Errno 5] Input/output error)导致保存失败。
57
+ - patches.for_numpy.random
58
+ - add get/set_rng_state(),用于获取/加载随机生成器的状态。
59
+ - 添加了对应的测试用例
66
60
 
67
61
 
@@ -1,4 +1,4 @@
1
- kevin_toolbox/__init__.py,sha256=7isptekqTWuS1t1NRWNgtllHGRDc1eNX2UVtujkt5NM,410
1
+ kevin_toolbox/__init__.py,sha256=XyLJGqBJkZgDgnrzFo4y-4YiXNVBR7KaaJSMMAkiqtc,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
@@ -26,7 +26,7 @@ kevin_toolbox/computer_science/algorithm/combinatorial_optimization/test/test_ze
26
26
  kevin_toolbox/computer_science/algorithm/execution_graph/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  kevin_toolbox/computer_science/algorithm/execution_graph/jump_node.py,sha256=Bmtc-S154S3gYmbIB98tcwvCc_qBkZoUkE9c3IRJ1dM,3297
28
28
  kevin_toolbox/computer_science/algorithm/execution_graph/random_node.py,sha256=4txbyT2h5F9JgUejAkqBWamSVQ2FlAW0FKt_i1NW5zs,3189
29
- kevin_toolbox/computer_science/algorithm/execution_graph/simple_node.py,sha256=4K44JfwnYdsRp-F_aB89B-lUDtEhU5whpt3hE-Y646A,3267
29
+ kevin_toolbox/computer_science/algorithm/execution_graph/simple_node.py,sha256=Bz1ABA3O9pFbu4RxLbRN_18_2T3czZ_XgqR_f8QVTYM,3268
30
30
  kevin_toolbox/computer_science/algorithm/for_dict/__init__.py,sha256=YFxhbWIsOMGf7ay3fh0sosvXzpuqQQC1bkXK75LAqO4,37
31
31
  kevin_toolbox/computer_science/algorithm/for_dict/deep_update.py,sha256=_1GL8-zY1t48rp3N_SiirjYPzLwQSN_cpmzLKymOnQI,666
32
32
  kevin_toolbox/computer_science/algorithm/for_seq/__init__.py,sha256=-ch23vULEmsEPb6roGKWCrW1xt6g7RUTevdZGNsReIw,121
@@ -248,7 +248,7 @@ kevin_toolbox/nested_dict_list/serializer/enum_variable.py,sha256=RWPydtXI4adOJY
248
248
  kevin_toolbox/nested_dict_list/serializer/read.py,sha256=BjsEWYoyvEHgRKKVKw0suf1ukug2tAFLMCAmEnndqgg,2945
249
249
  kevin_toolbox/nested_dict_list/serializer/saved_node_name_builder.py,sha256=qsD-rmDmVaKZP4owN3Wm3QY2Ksi71XlYETqw4VmIsSU,1011
250
250
  kevin_toolbox/nested_dict_list/serializer/variable.py,sha256=ZywG6obipRBCGY1cY42gdvsuWk8GLZXr6eCYcW7ZJ9c,392
251
- kevin_toolbox/nested_dict_list/serializer/write.py,sha256=HDmwEQHTnhFYITItFxM5Zw7sl7F4a50_MN59mR-pU3g,21898
251
+ kevin_toolbox/nested_dict_list/serializer/write.py,sha256=bGWP24kikE-L0ODFFMw8Z-uS2Almh-zVitoSHmIt7dc,22169
252
252
  kevin_toolbox/nested_dict_list/serializer/backends/__init__.py,sha256=8g7y-L3cmctxao616dVkGiot00FJzKNmNl_69V2bSmE,39
253
253
  kevin_toolbox/nested_dict_list/serializer/backends/_json_.py,sha256=oJXIc28yjxsD9ZJuw120pVHTVsTzCdaXEhVUSQeydq4,2145
254
254
  kevin_toolbox/nested_dict_list/serializer/backends/_ndl.py,sha256=3YkAq_Bqzehnw0kGxqxwtF6uUz0EV37tLI-1ROHjixY,1794
@@ -292,8 +292,10 @@ kevin_toolbox/patches/for_numpy/linalg/cos_similar.py,sha256=bFkfDwrW3maXq5i9ZAB
292
292
  kevin_toolbox/patches/for_numpy/linalg/entropy.py,sha256=PSdwkzySvWF4h4Xi27w2kvLq5WAeM_ysLstPFNBMoX8,1080
293
293
  kevin_toolbox/patches/for_numpy/linalg/normalize.py,sha256=7qstt__rwUkk3jRJOQoneBp9YdfhYQtWfh6PZoWbvaA,625
294
294
  kevin_toolbox/patches/for_numpy/linalg/softmax.py,sha256=M4a3jyKZBMFdiC_sPqO7AVts6AnEju8WbLc_GNSEtQ4,2095
295
- kevin_toolbox/patches/for_numpy/random/__init__.py,sha256=f1nOm2jr-4x5ZW80S5VzvIAtag0aQTGiYVzxgGG1Oq8,149
295
+ kevin_toolbox/patches/for_numpy/random/__init__.py,sha256=SDFF7yiUrkSHE9f9quALFQd6bCF2Mr1Q0vznl7QBhyo,231
296
296
  kevin_toolbox/patches/for_numpy/random/get_rng.py,sha256=QblrMKg4OFVy-C4A6rQ-zq26uDKzhMifKTFUlyW3Ksw,1999
297
+ kevin_toolbox/patches/for_numpy/random/get_rng_state.py,sha256=wceMn3LXx7Fbe2S5f5p6kkMEpNb6GYq3Y-DG9amuL5w,113
298
+ kevin_toolbox/patches/for_numpy/random/set_rng_state.py,sha256=26Mk3KOsaiteosu9ym3ZdvT5-klQnRREQy4SKiJ-QRE,401
297
299
  kevin_toolbox/patches/for_numpy/random/truncated_multivariate_normal.py,sha256=ZOaFZrzFI-ty7oRwUXxLx7pJMLTPPAAN28_AM6LeUDk,5859
298
300
  kevin_toolbox/patches/for_numpy/random/truncated_normal.py,sha256=uej3SQnLu0HsBTD47Yrgft1NpnsoEIOm925H9ipS8UQ,3726
299
301
  kevin_toolbox/patches/for_numpy/random/variable.py,sha256=Sam-QZgkx9_IvHzZhpUrXld0izP5MZfMBiM8qRWcB6M,231
@@ -324,7 +326,7 @@ kevin_toolbox/patches/for_streamlit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQ
324
326
  kevin_toolbox/patches/for_streamlit/markdown/__init__.py,sha256=ZWNRNA7yn3LD_YMjBuUHrXcxDcG4iswIZtCJVCnRVB0,93
325
327
  kevin_toolbox/patches/for_streamlit/markdown/show.py,sha256=uSkArSUv8N05TFWsIpXa8f15uhN1Lpm0ZHZst_IytgY,327
326
328
  kevin_toolbox/patches/for_streamlit/markdown/show_image.py,sha256=8njiSDiPWWRNwevvpgipxZS3My7bGHp9j0dxLiut_x8,1546
327
- kevin_toolbox/patches/for_streamlit/markdown/show_table.py,sha256=mZu37G9lqtpSEP62YLv88rDw-OSe8BCFkmSa2UQt6fY,3251
329
+ kevin_toolbox/patches/for_streamlit/markdown/show_table.py,sha256=4Nv4SYGwLDi9txlUDSZ2B9uWrtvGhcbphIVfdqcSBN8,3254
328
330
  kevin_toolbox/patches/for_test/__init__.py,sha256=sFr2VZD1zk8Vtjq2_F8uE4xNovJF6yDY8j1YND5XAw0,49
329
331
  kevin_toolbox/patches/for_test/check_consistency.py,sha256=cerf4NywkvWYMvuJUjimfRRVU7D9vL30jTAX0NxxRoM,9422
330
332
  kevin_toolbox/patches/for_torch/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -342,7 +344,7 @@ kevin_toolbox/patches/for_torch/math/get_y_at_x.py,sha256=bfoVcasZ_tMdhR_1Me0Jli
342
344
  kevin_toolbox/patches/for_torch/math/my_around.py,sha256=ptpU3ids50gwf663EpHbw7raj9tNrDGBFZ5t_uMNH14,1378
343
345
  kevin_toolbox/patches/for_torch/nn/__init__.py,sha256=aJs3RMqRzQmd8KKDmQW9FxwCqS5yfPqEdg-m0PwlQro,39
344
346
  kevin_toolbox/patches/for_torch/nn/lambda_layer.py,sha256=KUuLiX_Dr4bvRmpAaCW5QTDWDcnMPRnw0jg4NNXTFhM,223
345
- kevin_toolbox_dev-1.4.1.dist-info/METADATA,sha256=b3yGqO3ykWWJRAx1ChCx9N_v_ezAfbIwchtFwrgtt3U,2234
346
- kevin_toolbox_dev-1.4.1.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
347
- kevin_toolbox_dev-1.4.1.dist-info/top_level.txt,sha256=S5TeRGF-PwlhsaUEPTI-f2vWrpLmh3axpyI6v-Fi75o,14
348
- kevin_toolbox_dev-1.4.1.dist-info/RECORD,,
347
+ kevin_toolbox_dev-1.4.3.dist-info/METADATA,sha256=OiEFU4vF5eltP539ZVxcEU4UEqbRK9LJy86SuegJCAs,1726
348
+ kevin_toolbox_dev-1.4.3.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
349
+ kevin_toolbox_dev-1.4.3.dist-info/top_level.txt,sha256=S5TeRGF-PwlhsaUEPTI-f2vWrpLmh3axpyI6v-Fi75o,14
350
+ kevin_toolbox_dev-1.4.3.dist-info/RECORD,,