Skip to content

fix(cfg): reject plot options a one-call function does not read (#74) - #88

Merged
lllangWV merged 2 commits into
mainfrom
t3/resolve-important-issue
Oct 28, 2026
Merged

lllangWV merged 2 commits into
mainfrom
t3/resolve-important-issue

Conversation

@lllangWV

@lllangWV lllangWV commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner
film.mp4

Why

The one-call plotting functions took any keyword argument. ConfigManager.merge_configs put an unknown key in config.custom_settings, and nothing read it. A misspelt or retired option did nothing and said nothing. The Getting Started notebook passed xlabel, ylabel, cache and verbose to bandsplot, and all four were dropped. Fixes #74.

What changed

  • merge_configs(default_config, user_config, caller, also_accepts=()) raises TypeError for a key that is not a config field. The message names the caller and the closest valid name, as Python does for an unexpected keyword argument. custom_settings is removed.
  • dosplot draws x_label and y_label, which Inconsistent PDOS data in plotted figure and data file & export_data_file error #10's script passed. An empty value keeps the labels it picks. bandsplot takes verbose, which its own progress message already named.
  • tests/test_documented_calls.py checks the plot options of each documented bandsplot, dosplot and unfold call through merge_configs. A new rule row in CLAUDE.md names this check.

Scope

  • Covers bandsplot, dosplot, unfold, the five FermiHandler plot methods and BandStructure2DHandler.plot_band_structure.
  • Leaves out the config fields that are fields but that nothing reads: 152 of 235 across the five configs, for example minor_y_tick_params, grid and legend. Those still pass silently. Wiring them up or removing them is a follow-up.

Tradeoffs

  • TypeError, not a warning. It matches Python and unfold's check for removed parameters. A warning is easy to miss in a notebook, and the option still does nothing.

Blast Radius

A user script that passes an option nothing reads now fails with a TypeError that names the fix. Before, it ran and ignored the option. bandsplot now calls set_verbose_level(verbose) like dosplot, so it sets the user and pyprocar logger levels on each call. quiet_welcome=True still silences it.

Verification

  • Same driver on main and on this PR, through verify.sh run on dos/non-spin-polarized (a6af36c). On main, dosplot(cache=True) runs and says nothing, and x_label/y_label are dropped. On this PR:
    TypeError: dosplot() got unexpected keyword argument 'cache' (did you mean 'use_cache'?); print_plot_opts=True lists its plot options
    TypeError: bandsplot() got unexpected keyword argument 'xlabel' (did you mean 'x_label'?); print_plot_opts=True lists its plot options
    
    main (before) and PR (after): dosplot draws the x_label and y_label the user passes
  • Gates at a6af36c: non-data suite 3564 passed; data tests in tests/pyprocar/scripts and tests/pyprocar/cfg 107 passed; ty baseline 0 new, 0 stale; both ruff gates ok; red_green.py origin/main ok. The three new data tests fail on main for their stated reasons ([] == [0] for verbose, the hard-coded labels), and the default-label guard passes there.
  • The bands driver now types its selections as dict[str, Any]. That clears 15 ty baseline entries, pruned in their own commit.

Not verified

  • tests/pyprocar/io/abinit/test_dos.py (9 tests): the Abinit DOS fixture is missing from the local data store, so they fail on setup. They do not call the changed code with plot options.
  • The Fermi handlers with a misspelt option. A unit test covers also_accepts, and the existing FermiHandler data tests pass with off_screen.

Created with Claude Opus 5.5 in T3 Code.

lllangWV and others added 2 commits October 28, 2026 08:41
`ConfigManager.merge_configs` stored any keyword it did not know in
`config.custom_settings`, which nothing read, so a misspelt or retired
option did nothing and said nothing. Notebooks passed `xlabel`, `ylabel`,
`cache` and `verbose` to `bandsplot`, and #10's script passed `x_label`
and `y_label` to `dosplot`, all dropped silently.

`merge_configs` now takes the calling function and raises `TypeError`
for a key that is neither a config field nor a key the caller reads
itself, naming the closest valid option, as Python does for an
unexpected keyword argument. `custom_settings` is gone.

- `dosplot` draws `x_label` and `y_label`; empty keeps its own labels.
- `bandsplot` takes `verbose`, which its progress message already named.
- FermiHandler methods that build a plotter accept `off_screen`,
  `window_size` and `theme`; `create_isovalue_gif` does not read them.
- The Getting Started notebook passes `use_cache` and `x_label`.
- `tests/test_documented_calls.py` checks documented plot options
  against `merge_configs`.

Co-Authored-By: Claude <noreply@anthropic.com>
…ions fix

Co-Authored-By: Claude <noreply@anthropic.com>
@lllangWV
lllangWV merged commit 3766c94 into main Oct 28, 2026
5 checks passed
@lllangWV
lllangWV deleted the t3/resolve-important-issue branch October 28, 2026 14:41
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.

One-call plotting functions silently ignore unknown keyword arguments (x_label, y_label in dosplot)

1 participant