Skip to content

[Code scan] Fix syntax error in the RT-TDDFT projection tool #7541

Description

@njzjz

This issue is a result of a Codex global repository scan.

tools/02_postprocessing/rt-tddft-tools/projection.py currently cannot be parsed by Python because line 9 contains fdir suffix + s_dir instead of a valid expression. This makes the projection tool fail before any runtime logic is reached.

def __init__(self, stepref, klist, steps, fdir='./OUT.ABACUS', wfc_dir='', s_dir=''):
self.stepref = stepref
self.klist = klist
self.steps = steps
self.wfc_dir = fdir + wfc_dir
self.s_dir = fdir suffix + s_dir
wfc_ref, Ocp_ref = self.read_wfc(klist[0]+1, stepref+1, dir=self.wfc_dir)

Relevant code:

self.wfc_dir = fdir + wfc_dir
self.s_dir = fdir suffix + s_dir

I verified this with AST parsing / py_compile-equivalent parsing; Python reports:

SyntaxError: invalid syntax (projection.py, line 9)

The example copy of this file uses the likely intended expression:

self.wfc_dir = fdir + wfc_dir
self.s_dir = fdir + s_dir
wfc_ref, Ocp_ref = self.read_wfc(klist[0]+1, stepref+1, dir=self.wfc_dir)

Suggested fix:

Change line 9 to self.s_dir = fdir + s_dir. While touching this file, also consider replacing the later global steps references with self.steps so the class works when imported rather than only when run through its __main__ block.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions