This issue was found by a Codex global repository scan of tracked non-test files at commit 8c93925cb10b401b2b83c738bd9263fd74474468.
Relevant code
|
def calculate_stability_results(self) -> dict[str, float]: |
|
"""This calculates the stability score for a given LAM.""" |
|
stability_results = self.fetcher.fetch_stability_results() |
|
# filter out models with missing stability results |
|
stability_results = { |
|
model: metrics for model, metrics in stability_results.items() |
|
} |
|
|
|
stability_results = pd.DataFrame.from_dict(stability_results, orient="index") |
|
stability_results = stability_results.map( |
|
lambda cell: self._calculate_instability_error(cell) |
|
) |
|
# average over all systems |
|
stability_results = stability_results.mean(axis=1) |
|
return stability_results.to_dict() |
|
|
|
def _calculate_instability_error(self, cell: dict, lambda_0: float = 5e-4) -> float: |
|
""" |
|
Private method applied to each cell of the stability_results DataFrame. |
|
Calculates the instability error for a given LAM on a given NVE traj. |
|
Penalty is applied if the simulation is not complete, by returning a large value. |
|
""" |
|
|
|
if cell is None or cell.get("steps", None) is None: |
Impact
DataFrame.from_dict(..., orient="index") fills missing per-system NVE entries with NaN. _calculate_instability_error() handles None, but then calls cell.get(...) on the cell value. For NaN, that raises AttributeError instead of returning the documented failure penalty.
A model with one missing NVE system can crash stability scoring rather than receiving the intended penalty.
Suggested fix
Treat non-dict, null, and NaN cells as failed simulations and return 5. Add a regression test where one model is missing a system present for another model.
This issue was found by a Codex global repository scan of tracked non-test files at commit
8c93925cb10b401b2b83c738bd9263fd74474468.Relevant code
LAMBench/lambench/metrics/vishelper/metrics_calculations.py
Lines 166 to 189 in 8c93925
Impact
DataFrame.from_dict(..., orient="index")fills missing per-system NVE entries withNaN._calculate_instability_error()handlesNone, but then callscell.get(...)on the cell value. ForNaN, that raisesAttributeErrorinstead of returning the documented failure penalty.A model with one missing NVE system can crash stability scoring rather than receiving the intended penalty.
Suggested fix
Treat non-dict, null, and
NaNcells as failed simulations and return5. Add a regression test where one model is missing a system present for another model.