fix: 变更哈希注册表以修复重复键造成的崩溃
This commit is contained in:
@@ -9,10 +9,10 @@ timestamp_override = -1
|
||||
quick_pass = true
|
||||
|
||||
# [调试] 自动化测试模式(仅用于测试完整性)
|
||||
auto_pass = false
|
||||
auto_pass = true
|
||||
|
||||
# 对于每个项目的默认新记忆原子数量
|
||||
scheduled_num = 20
|
||||
scheduled_num = 100
|
||||
|
||||
# UTC 时间戳修正 仅用于 UNIX 日时间戳的生成修正, 单位为秒
|
||||
timezone_offset = +28800 # 中国标准时间 (UTC+8)
|
||||
|
||||
@@ -2,7 +2,7 @@ schedule = ["quick_review", "recognition", "final_review"]
|
||||
|
||||
[phases]
|
||||
quick_review = [["FillBlank", "1.0"], ["Recognition", "1.0"]]
|
||||
recognition = [["Recognition", "1.0"]]
|
||||
recognition = [["FillBlank", "1.0"]]
|
||||
final_review = [["FillBlank", "1.0"], ["Recognition", "1.0"]]
|
||||
|
||||
[annotation]
|
||||
|
||||
@@ -17,6 +17,7 @@ import heurams.services.version as version
|
||||
from heurams.context import *
|
||||
from heurams.kernel.particles import *
|
||||
from heurams.kernel.repolib import *
|
||||
from heurams.kernel.algorithms import algorithms
|
||||
from heurams.services.logger import get_logger
|
||||
|
||||
from .about import AboutScreen
|
||||
@@ -58,14 +59,14 @@ class DashboardScreen(Screen):
|
||||
f"当前 UNIX 日时间戳: {timer.get_daystamp()}"
|
||||
),
|
||||
Label(f"应用时区修正: UTC+{config_var.get()['timezone_offset'] / 3600}"),
|
||||
Label(f"全局算法设置: {config_var.get()['algorithm']['default']}"),
|
||||
Label(f"全局算法设置: {config_var.get()['algorithm']['default']}: {algorithms[config_var.get()['algorithm']['default']].desc}"),
|
||||
classes="column infview",
|
||||
),
|
||||
Vertical(
|
||||
Label(f"已加载 {len(self.repostat)} 个单元集", classes='dataview'),
|
||||
Label(f"共计 {reduce(lambda x, y: x + y, map(lambda x: x.get('unit_sum'), self.repostat.values()))} 个单元", classes='dataview'),
|
||||
Label(f"已激活 {reduce(lambda x, y: x + y, map(lambda x: x.get('activated_sum'), self.repostat.values()))} 个单元", classes='dataview'),
|
||||
Label(f"终端尺寸: {os.get_terminal_size()[0]}x{os.get_terminal_size()[1]}"),
|
||||
Label(f""),
|
||||
classes="column dataview",
|
||||
),
|
||||
id="dashboardtop"
|
||||
@@ -191,4 +192,4 @@ class DashboardScreen(Screen):
|
||||
if str(event.button.id).startswith("launch_"): # type: ignore
|
||||
from .preparation import launch
|
||||
launch(repo=self.dirname2repo[event.button.id[7:]], app=self.app, scheduled_num=-1) # type: ignore
|
||||
# TODO: 这样启动的记忆实例的状态机无法绑定到 PreparationScreen 中
|
||||
# TODO: 这样启动的记忆实例的状态机无法绑定到 PreparationScreen 中
|
||||
|
||||
@@ -70,8 +70,9 @@ class ClozePuzzle(BasePuzzleWidget):
|
||||
# 渲染当前问题的选项
|
||||
with Container(id="btn-container"):
|
||||
for i in self.ans:
|
||||
self.hashmap[str(hash(i))] = i
|
||||
btnid = f"sel000-{hash(i)}"
|
||||
h = str(hash(i))
|
||||
self.hashmap[h] = i
|
||||
btnid = f"sel000-{h}"
|
||||
logger.debug(f"建立按钮 {btnid}")
|
||||
yield Button(i, id=f"{btnid}")
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ logger = get_logger(__name__)
|
||||
|
||||
class BaseAlgorithm:
|
||||
algo_name = "BaseAlgorithm"
|
||||
|
||||
desc = '算法基类'
|
||||
class AlgodataDict(TypedDict):
|
||||
real_rept: int
|
||||
rept: int
|
||||
|
||||
@@ -10,7 +10,7 @@ logger = get_logger(__name__)
|
||||
|
||||
class FAST0Algorithm(BaseAlgorithm):
|
||||
algo_name = "FAST-0"
|
||||
|
||||
desc = '快速筛选用特殊调度器'
|
||||
class AlgodataDict(TypedDict):
|
||||
real_rept: int
|
||||
rept: int
|
||||
|
||||
@@ -10,7 +10,7 @@ logger = get_logger(__name__)
|
||||
|
||||
class SM2Algorithm(BaseAlgorithm):
|
||||
algo_name = "SM-2"
|
||||
|
||||
desc = '经典间隔重复算法'
|
||||
class AlgodataDict(TypedDict):
|
||||
efactor: float
|
||||
real_rept: int
|
||||
|
||||
@@ -71,7 +71,8 @@ class Fission(Machine):
|
||||
"alia": item,
|
||||
}
|
||||
)
|
||||
self.current_puzzle_inf = self.puzzles_inf[0]
|
||||
if self.puzzles_inf:
|
||||
self.current_puzzle_inf = self.puzzles_inf[0]
|
||||
|
||||
for i in range(len(self.puzzles_inf)):
|
||||
self.min_ratings.append(float('inf'))
|
||||
@@ -94,12 +95,14 @@ class Fission(Machine):
|
||||
return self.current_puzzle_inf
|
||||
|
||||
def report(self, rating):
|
||||
self.min_ratings[self.cursor] = min(rating, self.min_ratings[self.cursor])
|
||||
if self.puzzles_inf:
|
||||
self.min_ratings[self.cursor] = min(rating, self.min_ratings[self.cursor])
|
||||
|
||||
def get_quality(self):
|
||||
if self.is_state("retronly", self):
|
||||
return reduce(lambda x, y: min(x, y), self.min_ratings)
|
||||
raise IndexError
|
||||
if self.puzzles_inf:
|
||||
if self.is_state("retronly", self):
|
||||
return reduce(lambda x, y: min(x, y), self.min_ratings)
|
||||
raise IndexError
|
||||
|
||||
def forward(self, step=1):
|
||||
"""将谜题指针向前移动并依情况更新或完成"""
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
# 哈希服务
|
||||
import hashlib
|
||||
|
||||
import random
|
||||
from heurams.services.logger import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def get_md5(text):
|
||||
logger.debug(f"计算哈希, 输入`{text}`")
|
||||
logger.debug(f"计算MD5哈希, 输入`{text}`")
|
||||
result = hashlib.md5(text.encode("utf-8")).hexdigest()
|
||||
logger.debug("哈希结果: %s...", result[:8])
|
||||
return result
|
||||
|
||||
|
||||
def hash(text):
|
||||
logger.debug(f"计算哈希, 输入`{text}`")
|
||||
result = hashlib.md5(text.encode("utf-8")).hexdigest()
|
||||
logger.debug(f"计算MD5-时间复合哈希, 输入`{text}`")
|
||||
result = hashlib.md5(f"{text}{random.randint(0,1000)}".encode("utf-8")).hexdigest()
|
||||
logger.debug("哈希结果: %s...", result[:8])
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user