[Code scan] Periodic table list and JSON data are inconsistent for elements 104-118
bugdpdatareproduced
This issue is part of a Codex global repository code scan.
`ELEMENTS` lists elements through Og (118), but `periodic_table.json` stops at Lr (103). In addition, `Element.from_Z()` uses `Z < len(ELEMENTS)`, which excludes the last listed element even if data existed.
Affected code/data:
https://github.com/deepmodeling/dpdata/blob/a7a50bfc096e1a65470af6f1c48152dc0275ec1c/dpdata/periodic_table.py#L9-L128
https://github.com/deepmodeling/dpdata/blob/a7a50bfc096e1a65470af6f1c48152dc0275ec1c/dpdata/periodic_table.py#L131-L153
https://github.com/deepmodeling/dpdata/blob/a7a50bfc096e1a65470af6f1c48152dc0275ec1c/dpdata/periodic_table.json#L918-L926
Minimal reproducer:
```python
import json
from pathlib import Path
from dpdata.periodic_table import ELEMENTS, Element
data = json.loads(Path("dpdata/periodic_table.json").read_text())
print([e for e in ELEMENTS if e not in data])
for z in [117, 118]:
try:
print(z, Element.from_Z(z))
except Exception as exc:
print(z, type(exc).__name__, exc)
```
Current output:
```text
['Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', 'Rg', 'Cn', 'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og']
117 KeyError 'Ts'
118 AssertionError
```
The JSON data and `ELEMENTS` should be consistent, and `from_Z()` should accept the final element in the list.
关闭于 2026-07-06 0 条评论