fix: 修复 Lict 问题
This commit is contained in:
@@ -12,7 +12,7 @@ for i in repo.ident_index:
|
||||
n = pt.Nucleon.from_data(nucleonic_data=repo.nucleonic_data_lict.get_itemic_unit(i))
|
||||
e = pt.Electron.from_data(
|
||||
electronic_data=repo.electronic_data_lict.get_itemic_unit(i),
|
||||
algo_name=repo.config['algorithm']
|
||||
algo_name=repo.config["algorithm"],
|
||||
)
|
||||
print(n)
|
||||
input()
|
||||
|
||||
@@ -35,7 +35,7 @@ class DashboardScreen(Screen):
|
||||
("q", "go_back", "返回"),
|
||||
]
|
||||
|
||||
CSS_PATH = Path(__file__).parent.parent / 'css' / "screens" / "dashboard.tcss"
|
||||
CSS_PATH = Path(__file__).parent.parent / "css" / "screens" / "dashboard.tcss"
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -109,7 +109,10 @@ class DashboardScreen(Screen):
|
||||
}
|
||||
initial_time = float("inf")
|
||||
for i in range(repo.data_length):
|
||||
e = pt.Electron.from_data(electronic_data=repo.electronic_data_lict[i], algo_name=repo.config['algorithm'])
|
||||
e = pt.Electron.from_data(
|
||||
electronic_data=repo.electronic_data_lict[i],
|
||||
algo_name=repo.config["algorithm"],
|
||||
)
|
||||
n = pt.Nucleon.from_data(repo.nucleonic_data_lict[i])
|
||||
if e.is_activated():
|
||||
repo.progress["have_activated_ever"] = 1
|
||||
|
||||
@@ -48,9 +48,7 @@ class PreparationScreen(Screen):
|
||||
yield Header(show_clock=True)
|
||||
with ScrollableContainer(id="vice_container"):
|
||||
yield Label(f"准备就绪: [b]{self.repo.manifest['title']}[/b]\n")
|
||||
yield Label(
|
||||
f"[b]仓库路径: {self.repo.source}[/b]"
|
||||
)
|
||||
yield Label(f"[b]仓库路径: {self.repo.source}[/b]")
|
||||
yield Label(f"\n单元数量: {len(self.repo)}\n")
|
||||
yield Label(f"最小记忆分组: {self.scheduled_num}\n", id="schnum_label")
|
||||
|
||||
@@ -93,7 +91,7 @@ class PreparationScreen(Screen):
|
||||
)
|
||||
e = pt.Electron.from_data(
|
||||
electronic_data=self.repo.electronic_data_lict.get_itemic_unit(i),
|
||||
algo_name=self.repo.config['algorithm']
|
||||
algo_name=self.repo.config["algorithm"],
|
||||
)
|
||||
statstr = ""
|
||||
|
||||
@@ -148,7 +146,7 @@ def launch(repo, app, scheduled_num):
|
||||
)
|
||||
e = pt.Electron.from_data(
|
||||
electronic_data=repo.electronic_data_lict.get_itemic_unit(i),
|
||||
algo_name=repo.config['algorithm']
|
||||
algo_name=repo.config["algorithm"],
|
||||
)
|
||||
a = pt.Atom(n, e, repo.orbitic_data)
|
||||
atoms.append(a)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# 已弃用
|
||||
from collections import UserList
|
||||
from typing import Any, Iterator
|
||||
|
||||
@@ -2,10 +2,23 @@ from collections.abc import MutableSequence
|
||||
from typing import Any, Iterator, Optional
|
||||
|
||||
class Lict(MutableSequence):
|
||||
""" "列典" 对象
|
||||
|
||||
def __init__(self, initlist: Optional[list] = None,
|
||||
同时兼容字典和列表大多数 API, 两边数据同步的容器, 性能与 list/dict 大体相当
|
||||
列表数据是 dictobj.items() 的格式
|
||||
支持根据字典或列表初始化
|
||||
限制要求:
|
||||
- 键名一定唯一, 且仅能为字符串
|
||||
- append 的元组中, 表示键名的元素不能重复, 否则会导致覆盖行为
|
||||
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
initlist: Optional[list] = None,
|
||||
initdict: Optional[dict] = None,
|
||||
forced_order: bool = False):
|
||||
forced_order: bool = False,
|
||||
):
|
||||
self._dict = {}
|
||||
self._list = []
|
||||
self._dict_dirty = False
|
||||
@@ -99,12 +112,12 @@ class Lict(MutableSequence):
|
||||
self._list.append(item) # 两端都已同步
|
||||
self._sync_if_needed() # 以防 forced_order
|
||||
|
||||
def append_if_it_donesnt_exist_before(self, item: Any):
|
||||
def append_if_it_doesnt_exist_before(self, item: Any):
|
||||
if item != (item[0], item[1]):
|
||||
raise NotImplementedError
|
||||
self._sync_if_needed()
|
||||
if item[0] not in self:
|
||||
super().append(item)
|
||||
self.append(item)
|
||||
self._sync_if_needed()
|
||||
|
||||
def insert(self, i: int, item: Any) -> None:
|
||||
@@ -147,18 +160,6 @@ class Lict(MutableSequence):
|
||||
def reverse(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def keys(self):
|
||||
self._sync_if_needed()
|
||||
return self._dict.keys()
|
||||
|
||||
def values(self):
|
||||
self._sync_if_needed()
|
||||
return self._dict.values()
|
||||
|
||||
def items(self):
|
||||
self._sync_if_needed()
|
||||
return self._list
|
||||
|
||||
def get_itemic_unit(self, ident):
|
||||
return (ident, self._dict[ident])
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# 已弃用
|
||||
class RefVar:
|
||||
def __init__(self, initvalue) -> None:
|
||||
self.data = initvalue
|
||||
@@ -64,11 +64,11 @@ class Repo:
|
||||
"source": self.source,
|
||||
}
|
||||
self.config = {
|
||||
"algorithm": config_var.get()['interface']['global']['algorithm'],
|
||||
"scheduled_num": config_var.get()['interface']['global']['scheduled_num'],
|
||||
"algorithm": config_var.get()["interface"]["global"]["algorithm"],
|
||||
"scheduled_num": config_var.get()["interface"]["global"]["scheduled_num"],
|
||||
}
|
||||
try:
|
||||
self.config.update(dict(config_var.get()['repo'][self.manifest['package']]))
|
||||
self.config.update(dict(config_var.get()["repo"][self.manifest["package"]]))
|
||||
except:
|
||||
pass
|
||||
self._generate_particles_data()
|
||||
@@ -82,7 +82,7 @@ class Repo:
|
||||
self.data_length = len(self.nucleonic_data_lict)
|
||||
self.ident_index = self.nucleonic_data_lict.keys()
|
||||
for i in self.ident_index:
|
||||
self.algodata.append_if_it_donesnt_exist_before((i, {}))
|
||||
self.algodata.append_if_it_doesnt_exist_before((i, {}))
|
||||
self.electronic_data_lict = self.algodata
|
||||
|
||||
def _nucleonic_proc(self, unit):
|
||||
|
||||
Reference in New Issue
Block a user