Skip to content

Commit 3c8be0c

Browse files
committed
docs(nnp): document NaN-padding gotcha in load_input
Two recent CI failures (Element(nan), int(nan)) were caused by tag rows being narrower than the widest line in input.nn, so pandas pads the rest with NaN. Slice-style reads like row[1:] must use pd.notna() — 'is not None' and truthiness checks both pass NaN through silently.
1 parent 9f5ce1d commit 3c8be0c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/maml/apps/pes/_nnp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,9 @@ def str_formatify(string):
518518
param = {}
519519
with open(filename) as f:
520520
lines = f.readlines()
521+
# Rows have varying widths (e.g. `elements Mo` has 2 fields, symfunction rows have 9).
522+
# pandas pads short rows with NaN, so any `[1:]`-style slice over a tag row must filter
523+
# NaN values via `pd.notna(...)` — `is not None` / truthiness checks pass NaN through.
521524
df = pd.DataFrame([line.split() for line in lines if "#" not in line])
522525
self.elements = sorted(
523526
(element for element in np.ravel(df[df[0] == "elements"])[1:] if pd.notna(element)),

0 commit comments

Comments
 (0)