fix: 修复浅拷贝导致的 eval 问题

This commit is contained in:
2025-12-09 14:10:08 +08:00
parent 42708e8a09
commit 23780a57c6
2 changed files with 20 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ import heurams.services.hasher as hasher
import pathlib
import toml
import json
from copy import deepcopy
def load_nucleon(path: pathlib.Path, fmt = "toml"):
with open(path, "r") as f:
@@ -28,7 +29,7 @@ def load_nucleon(path: pathlib.Path, fmt = "toml"):
for item, attr in nested_data.items():
if item == "__metadata__":
continue
lst.append((Nucleon(hasher.hash(item), attr, nested_data['__metadata__']), nested_data["__metadata__"]["orbital"]))
lst.append((Nucleon(hasher.hash(item), attr, deepcopy(nested_data['__metadata__'])), deepcopy(nested_data["__metadata__"]["orbital"])))
return lst
def load_electron(path: pathlib.Path, fmt = "json") -> dict: