Skip to content

Fix TypeError in check_files SPC level-of-theory validation#112

Merged
bobbypaton merged 2 commits into
masterfrom
fix/check-spc-lot
Jul 9, 2026
Merged

Fix TypeError in check_files SPC level-of-theory validation#112
bobbypaton merged 2 commits into
masterfrom
fix/check-spc-lot

Conversation

@bobbypaton

@bobbypaton bobbypaton commented Jul 9, 2026

Copy link
Copy Markdown
Member

Fixes #111

Problem

Combining --check with --spc <suffix> crashed:

File "goodvibes/validation.py", line 330, in check_files
    l_o_t_spc = [level_of_theory(name) for name in names_spc]
TypeError: 'list' object is not callable

check_files() takes level_of_theory as a list of per-file strings, but the SPC-validation branch still contained a call from before the refactor, when io.level_of_theory (a file parser) was imported at module level. The list parameter shadowed the function name. Not Windows-specific — reproduces on any platform.

Fix

  • Import the parser as read_level_of_theory (aliased so the parameter no longer shadows it) and use it to read each SPC file's level of theory — the correct behavior, since the parameter only holds the freq-level strings.
  • On the mismatch path, pass names_spc (the SPC filenames) to print_check_fails instead of the parent filenames, so groups are attributed correctly when an SPC file is missing.

Testing

  • Reproduced the crash with goodvibes ethane.out --spc TZ --check; after the fix the run completes and reports Using B3LYP/6-311G(d,p) in all the single-point corrections (the TZ single-point level, distinct from the B3LYP/6-31G(d) freq level).
  • Added regression test test_check_files_spc_reads_spc_level_of_theory.
  • Full suite: 2512 passed; ruff clean.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected single-point correction validation so the level of theory is derived from the single-point (SPC) data files.
    • Improved mismatch reporting to reference the relevant SPC files when discrepancies are detected.
    • When SPC files are missing, the validation now logs a caution instead of failing the “levels of theory” check.
  • Tests
    • Added regression coverage for SPC level-of-theory reading and for missing-SPC handling.

check_files() takes level_of_theory as a list of per-file strings, but
the SPC branch still called it as a function -- a leftover from before
the refactor, when io.level_of_theory was imported at module level. Any
run combining --check with --spc crashed with
"TypeError: 'list' object is not callable".

Import the io parser under an alias (read_level_of_theory) and use it
to read each SPC file's level of theory. Also pass names_spc rather
than the parent filenames to print_check_fails on the mismatch path,
so groups are attributed to the right files when an SPC file is
missing.

Fixes #111
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9f485781-962d-4680-b2b1-ddae4a56205b

📥 Commits

Reviewing files that changed from the base of the PR and between 4c9b9d3 and 4f873a0.

📒 Files selected for processing (2)
  • goodvibes/validation.py
  • tests/test_validation.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/test_validation.py
  • goodvibes/validation.py

📝 Walkthrough

Walkthrough

goodvibes/validation.py now re-reads SPC level-of-theory values from the SPC files themselves during check_files, uses SPC filenames in mismatch reporting, and logs a caution when SPC files are missing. tests/test_validation.py adds regression coverage for both the SPC-derived level-of-theory message and the missing-file path.

Changes

SPC level-of-theory validation fix

Layer / File(s) Summary
SPC level-of-theory re-read and reporting fix
goodvibes/validation.py
Imports read_level_of_theory alias and uses it to recompute SPC level-of-theory per file instead of the passed-in parameter; reports mismatches using names_spc and logs a missing-file caution.
SPC validation regression tests
tests/test_validation.py
Adds imports for ThermoOptions and datapath, plus tests covering the SPC-derived level-of-theory message and the missing SPC file caution path.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing the SPC validation TypeError in check_files.
Linked Issues check ✅ Passed The fix addresses #111 by stopping check_files from calling a list as a function during --check with --spc, and regression tests cover the crash path.
Out of Scope Changes check ✅ Passed The changes stay focused on SPC validation and its regression tests, with no unrelated functionality added.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/check-spc-lot

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
goodvibes/validation.py (1)

355-360: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Avoid reading each SPC file twice. level_of_theory(name) and parse_qcdata(name) both reopen the same SPC file; if SPC validation needs both the level and geometry, surface the level of theory from parse_qcdata (or combine the two parsers) so each file is read once.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@goodvibes/validation.py` around lines 355 - 360, The SPC duplicate-check loop
currently reads each file twice via level_of_theory(name) and
parse_qcdata(name), so update the validation flow to reuse a single parse per
file. Adjust parse_qcdata or its caller in the SPC handling path to return the
level of theory alongside cartesians, then have the logic that builds
geom_duplic_list_spc consume that combined result instead of reopening each SPC
file.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@goodvibes/validation.py`:
- Around line 330-336: Guard the SPC level-of-theory check in validation logic
so it only reports success when the SPC file list is complete and non-empty. In
the `l_o_t_spc` / `all_same` branch, add the same kind of length check used by
the geometry block before accessing `l_o_t_spc[0]`, and route empty or partial
`names_spc` cases to `print_check_fails` instead of logging the blanket success
message. This should be fixed in the SPC-reading section that uses
`read_level_of_theory`, `all_same`, and `print_check_fails`.

---

Nitpick comments:
In `@goodvibes/validation.py`:
- Around line 355-360: The SPC duplicate-check loop currently reads each file
twice via level_of_theory(name) and parse_qcdata(name), so update the validation
flow to reuse a single parse per file. Adjust parse_qcdata or its caller in the
SPC handling path to return the level of theory alongside cartesians, then have
the logic that builds geom_duplic_list_spc consume that combined result instead
of reopening each SPC file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3af0d489-fce8-487a-baf9-68650ba0a158

📥 Commits

Reviewing files that changed from the base of the PR and between a693b3c and 4c9b9d3.

📒 Files selected for processing (2)
  • goodvibes/validation.py
  • tests/test_validation.py

Comment thread goodvibes/validation.py Outdated
names_spc only collects SPC files that exist on disk, so it can be
empty or shorter than the input file list (e.g. --spc link, or a
missing _TZ partner file). all_same([]) returns True, so the empty
case crashed with IndexError on l_o_t_spc[0], and a partial list
logged a blanket success after checking only a subset.

Mirror the length check the geometry block already uses: only run the
success/mismatch branches when every input file has an SPC partner,
otherwise log an explicit caution that files are missing.

@bobbypaton bobbypaton left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed per suggestion from coderabbit

@bobbypaton
bobbypaton merged commit 7e477b2 into master Jul 9, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check option causes an error in SPC validation

1 participant