feat: 改进状态机
This commit is contained in:
@@ -101,9 +101,11 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import heurams.kernel.repolib as repolib # 这是 RepoLib 子模块, 用于管理和结构化 repo(中文含义: 仓库) 数据结构与本地文件间的联系\n",
|
||||
"import heurams.kernel.particles as pt # 这是 Particles(中文含义: 粒子) 子模块, 用于运行时的记忆管理操作\n",
|
||||
"from pathlib import Path # 这是 Python 的 Pathlib 模块, 用于表示文件路径, 在整个项目中, 都使用此模块表示路径"
|
||||
"import heurams.kernel.repolib as repolib # 这是 RepoLib 子模块, 用于管理和结构化 repo(中文含义: 仓库) 数据结构与本地文件间的联系\n",
|
||||
"import heurams.kernel.particles as pt # 这是 Particles(中文含义: 粒子) 子模块, 用于运行时的记忆管理操作\n",
|
||||
"from pathlib import (\n",
|
||||
" Path,\n",
|
||||
") # 这是 Python 的 Pathlib 模块, 用于表示文件路径, 在整个项目中, 都使用此模块表示路径"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -231,6 +233,7 @@
|
||||
"source": [
|
||||
"test_repo_dic = test_repo.export_to_single_dict()\n",
|
||||
"from pprint import pprint\n",
|
||||
"\n",
|
||||
"pprint(test_repo_dic)"
|
||||
]
|
||||
},
|
||||
@@ -287,7 +290,10 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"test_repo.persist_to_repodir(save_list=[\"schedule\", \"payload\", \"manifest\", \"typedef\", \"algodata\"], source=Path(\"test_new_repo\"))\n",
|
||||
"test_repo.persist_to_repodir(\n",
|
||||
" save_list=[\"schedule\", \"payload\", \"manifest\", \"typedef\", \"algodata\"],\n",
|
||||
" source=Path(\"test_new_repo\"),\n",
|
||||
")\n",
|
||||
"!tree"
|
||||
]
|
||||
},
|
||||
@@ -336,11 +342,12 @@
|
||||
],
|
||||
"source": [
|
||||
"from heurams.utils.lict import Lict\n",
|
||||
"lct = Lict() # 空的\n",
|
||||
"lct = Lict(initlist=[(\"name\", \"tom\"), (\"age\", 12), (\"enemy\", \"jerry\")]) # 基于列表\n",
|
||||
"\n",
|
||||
"lct = Lict() # 空的\n",
|
||||
"lct = Lict(initlist=[(\"name\", \"tom\"), (\"age\", 12), (\"enemy\", \"jerry\")]) # 基于列表\n",
|
||||
"print(lct)\n",
|
||||
"lct = Lict(initdict={\"name\": \"tom\", \"age\": 12, \"enemy\": \"jerry\"}) # 基于字典\n",
|
||||
"print(lct)\n"
|
||||
"lct = Lict(initdict={\"name\": \"tom\", \"age\": 12, \"enemy\": \"jerry\"}) # 基于字典\n",
|
||||
"print(lct)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -404,7 +411,7 @@
|
||||
"\n",
|
||||
"# 错误的方式\n",
|
||||
"lct.dicted_data[\"type\"] = \"cat\"\n",
|
||||
"print(lct) # 将不会同步修改\n",
|
||||
"print(lct) # 将不会同步修改\n",
|
||||
"\n",
|
||||
"# 不推荐, 但可用的方式\n",
|
||||
"lct.dicted_data[\"type\"] = \"cat\"\n",
|
||||
@@ -412,7 +419,7 @@
|
||||
"print(lct)\n",
|
||||
"\n",
|
||||
"# 推荐方式\n",
|
||||
"lct['is_human'] = False\n",
|
||||
"lct[\"is_human\"] = False\n",
|
||||
"print(lct)"
|
||||
]
|
||||
},
|
||||
@@ -446,7 +453,7 @@
|
||||
"# 由于 jupyter 的环境处理, 请不要重复运行此单元格, 如果想再看一遍, 请重启 jupyter 后再全部运行\n",
|
||||
"\n",
|
||||
"# 唯一推荐方式\n",
|
||||
"lct.append(('enemy_2', 'spike'))\n",
|
||||
"lct.append((\"enemy_2\", \"spike\"))\n",
|
||||
"print(lct.dicted_data)"
|
||||
]
|
||||
},
|
||||
@@ -507,7 +514,16 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"lct = Lict(initdict={'age': 12, 'enemy': 'jerry', 'is_human': False, 'name': 'tom', 'type': 'cat', 'enemy_2': 'spike'})\n",
|
||||
"lct = Lict(\n",
|
||||
" initdict={\n",
|
||||
" \"age\": 12,\n",
|
||||
" \"enemy\": \"jerry\",\n",
|
||||
" \"is_human\": False,\n",
|
||||
" \"name\": \"tom\",\n",
|
||||
" \"type\": \"cat\",\n",
|
||||
" \"enemy_2\": \"spike\",\n",
|
||||
" }\n",
|
||||
")\n",
|
||||
"print(lct)\n",
|
||||
"print(lct.dicted_data)\n",
|
||||
"print(\"------\")\n",
|
||||
@@ -517,7 +533,16 @@
|
||||
"while len(lct) > 0:\n",
|
||||
" print(lct.pop())\n",
|
||||
" print(lct)\n",
|
||||
"lct = Lict(initdict={'age': 12, 'enemy': 'jerry', 'is_human': False, 'name': 'tom', 'type': 'cat', 'enemy_2': 'spike'})\n",
|
||||
"lct = Lict(\n",
|
||||
" initdict={\n",
|
||||
" \"age\": 12,\n",
|
||||
" \"enemy\": \"jerry\",\n",
|
||||
" \"is_human\": False,\n",
|
||||
" \"name\": \"tom\",\n",
|
||||
" \"type\": \"cat\",\n",
|
||||
" \"enemy_2\": \"spike\",\n",
|
||||
" }\n",
|
||||
")\n",
|
||||
"..."
|
||||
]
|
||||
},
|
||||
@@ -654,10 +679,14 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"repo = repolib.Repo.create_from_repodir(Path('./test_repo'))\n",
|
||||
"repo = repolib.Repo.create_from_repodir(Path(\"./test_repo\"))\n",
|
||||
"for i in repo.ident_index:\n",
|
||||
" n = pt.Nucleon.create_on_nucleonic_data(nucleonic_data=repo.nucleonic_data_lict.get_itemic_unit(i))\n",
|
||||
" e = pt.Electron.create_on_electonic_data(electronic_data=repo.electronic_data_lict.get_itemic_unit(i))\n",
|
||||
" n = pt.Nucleon.create_on_nucleonic_data(\n",
|
||||
" nucleonic_data=repo.nucleonic_data_lict.get_itemic_unit(i)\n",
|
||||
" )\n",
|
||||
" e = pt.Electron.create_on_electonic_data(\n",
|
||||
" electronic_data=repo.electronic_data_lict.get_itemic_unit(i)\n",
|
||||
" )\n",
|
||||
" e.activate()\n",
|
||||
" e.revisor(5, True)\n",
|
||||
" print(repr(n))\n",
|
||||
|
||||
Reference in New Issue
Block a user