Repository navigation
fix: define and apply the fitted background in exp07's GenX script - #11
Merged
Merged
Conversation
This was referenced Oct 24, 2026
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.
Tier: physics
runs/exp07_fourier_hires/engine/script_builder.py) now defines the background:ibkgwith getter and setter inSim_Vars, starting frominit_params["ibkg"];Ibkg=1e-10;Sim()copies it into the instrument.engine/fitting.pyregisters"v.set_ibkg"as a fit parameter, and with the script on main GenX raisesAttributeError: 'Sim_Vars' object has no attribute 'get_ibkg'when that parameter is registered (genx 3.7.13 as locked, and 3.8.0). The exp07 GenX fit therefore stopped in_setup_parameters. Now it can run, the background is fitted and applied, and the starting background is the 1e-7 the fitter passes rather than 1e-10.Fixes item 1 of #9. Item 2 (layer order) is a decision and is not touched.
Stacked on #6 (
chore/conventions), which adds the tests directory and the pytest setup. Merge #6 first; GitHub then retargets this PR tomain.Correction to #9 item 1
The issue says the background "is fitted but not applied". That is the Reflecto case (Reflecto#2, fixed in Reflecto#5). In exp07 it is worse: the script never defined
ibkg(git log -S ibkgon the file is empty), so the fit could not register the parameter at all.Evidence
Test first (18f80c9), then the fix (0071c07).
tests/test_exp07_genx_script.py:test_background_can_be_registered_as_a_fit_parameter(whatfitting.pydoes)test_background_reaches_the_simulation(ibkg 1e-7 → 1e-5 moves the q = 0.5 tail by 9.9e-6)test_intensity_scale_reaches_the_simulation(control: i0 was already applied)The tests simulate with
compile=False. The defaultcompile=Truereruns the script and resetsv, so it would hide any parameter change.Tests
Local, Windows,
uv sync --frozen(genx 3.7.13):uv run pytest: 27 passed (26 s);uvx ruff@0.17.1 check: clean.