Skip to content

Commit 1c0d273

Browse files
Critsium-xyclaude
andcommitted
fix(io): read LATTICE_PARAMETER blocks consistently in STRU parsers
Three STRU parsers checked for a LATTICE_PARAMETER block but then read blocks['LATTICE_PARAMETERS'] with an extra S, and treated the list of lines as a string. Read blocks['LATTICE_PARAMETER'][0].split() to match the neighboring LATTICE_CONSTANT idiom, so STRU files using LATTICE_PARAMETER parse instead of raising KeyError. Closes #7555 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 12f66ac commit 1c0d273

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

interfaces/ASE_interface/abacuslite/io/generalio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def _trim(line):
467467
for line in blocks['LATTICE_VECTORS']]
468468
elif 'LATTICE_PARAMETER' in blocks:
469469
stru['lat']['param'] = [float(x)
470-
for x in blocks['LATTICE_PARAMETERS'].split()]
470+
for x in blocks['LATTICE_PARAMETER'][0].split()]
471471

472472
#============ ATOMIC_SPECIES ============
473473
stru['species'] = [dict(zip(['symbol', 'mass', 'pp_file', 'pp_type'],

interfaces/Multiwfn_interface/molden.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ def read_stru(fpath):
841841
if 'LATTICE_VECTORS' in blocks:
842842
stru['lat']['vec'] = [[float(x) for x in line.split()] for line in blocks['LATTICE_VECTORS']]
843843
elif 'LATTICE_PARAMETER' in blocks:
844-
stru['lat']['param'] = [float(x) for x in blocks['LATTICE_PARAMETERS'].split()]
844+
stru['lat']['param'] = [float(x) for x in blocks['LATTICE_PARAMETER'][0].split()]
845845

846846
#============ ATOMIC_SPECIES ============
847847
stru['species'] = [ dict(zip(['symbol', 'mass', 'pp_file', 'pp_type'], line.split())) for line in blocks['ATOMIC_SPECIES'] ]

python/pyabacus/src/pyabacus/io/stru.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def _trim(line):
134134
for line in blocks['LATTICE_VECTORS']]
135135
elif 'LATTICE_PARAMETER' in blocks:
136136
stru['lat']['param'] = [float(x)
137-
for x in blocks['LATTICE_PARAMETERS'].split()]
137+
for x in blocks['LATTICE_PARAMETER'][0].split()]
138138

139139
#============ ATOMIC_SPECIES ============
140140
stru['species'] = [_atomic_species_from_file(line)

0 commit comments

Comments
 (0)