Repository navigation
fix(cfg): reject plot options a one-call function does not read (#74) - #88
Merged
Merged
Conversation
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
film.mp4
Why
The one-call plotting functions took any keyword argument.
ConfigManager.merge_configsput an unknown key inconfig.custom_settings, and nothing read it. A misspelt or retired option did nothing and said nothing. The Getting Started notebook passedxlabel,ylabel,cacheandverbosetobandsplot, and all four were dropped. Fixes #74.What changed
merge_configs(default_config, user_config, caller, also_accepts=())raisesTypeErrorfor 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_settingsis removed.dosplotdrawsx_labelandy_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.bandsplottakesverbose, which its own progress message already named.tests/test_documented_calls.pychecks the plot options of each documentedbandsplot,dosplotandunfoldcall throughmerge_configs. A new rule row inCLAUDE.mdnames this check.Scope
bandsplot,dosplot,unfold, the fiveFermiHandlerplot methods andBandStructure2DHandler.plot_band_structure.minor_y_tick_params,gridandlegend. Those still pass silently. Wiring them up or removing them is a follow-up.Tradeoffs
TypeError, not a warning. It matches Python andunfold'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
TypeErrorthat names the fix. Before, it ran and ignored the option.bandsplotnow callsset_verbose_level(verbose)likedosplot, so it sets theuserandpyprocarlogger levels on each call.quiet_welcome=Truestill silences it.Verification
mainand on this PR, throughverify.sh runondos/non-spin-polarized(a6af36c). On main,dosplot(cache=True)runs and says nothing, andx_label/y_labelare dropped. On this PR:tests/pyprocar/scriptsandtests/pyprocar/cfg107 passed; ty baseline 0 new, 0 stale; both ruff gates ok;red_green.py origin/mainok. The three newdatatests fail on main for their stated reasons ([] == [0]forverbose, the hard-coded labels), and the default-label guard passes there.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.also_accepts, and the existingFermiHandlerdata tests pass withoff_screen.Created with Claude Opus 5.5 in T3 Code.