Skip to content

modify the truthiness check#3846

Open
rozyczko wants to merge 2 commits intomainfrom
3053-Phi-and-theta-stuck-at-zero
Open

modify the truthiness check#3846
rozyczko wants to merge 2 commits intomainfrom
3053-Phi-and-theta-stuck-at-zero

Conversation

@rozyczko
Copy link
Member

Description

In the param_remap_to_sasmodels_convert method, the condition if not value: incorrectly treated the value 0.0 as false. When orientation parameters like theta or phi were set to 0, they were being replaced with np.nan, breaking subsequent fits.

Fixes #3053

How Has This Been Tested?

Local tests

Review Checklist:

[if using the editor, use [x] in place of [ ] to check a box]

Documentation (check at least one)

  • There is nothing that needs documenting
  • Documentation changes are in this PR
  • There is an issue open for the documentation (link?)

Installers

  • There is a chance this will affect the installers, if so
    • Windows installer (GH artifact) has been tested (installed and worked)
    • MacOSX installer (GH artifact) has been tested (installed and worked)
    • Wheels installer (GH artifact) has been tested (installed and worked)

Licensing (untick if necessary)

  • The introduced changes comply with SasView license (BSD 3-Clause)

Copy link
Contributor

@DrPaulSharp DrPaulSharp left a comment

Choose a reason for hiding this comment

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

Very good spot here @rozyczko!

A couple of things from me, firstly, does this fix also need to be applied to the following lines dealing with the uncertainty and min/max values? It looks to me like they could trip on a zero value as well. Secondly, do you have an example of a bug that this branch fixes? I tried the instructions in #3053 but couldn't reproduce the bug there.

@krzywon
Copy link
Contributor

krzywon commented Jan 28, 2026

This is a needed change, but I'm not seeing any improvement in the magnetic/2D fitting functionality. I think this should be merged, but don't think it fixes the underlying issue in #3053. I'll update the issue on recreating the problem later today.

@rozyczko
Copy link
Member Author

The magnetic parameter values stored in MagnetismWidget.magnet_params were not being applied to the kernel_module before fitting. When only magnetic parameters were selected for fitting, the fitter used default sasmodels values instead of user-specified values. Including non-magnetic parameters worked because those triggered other code paths that updated the model correctly.

Added updateKernelModelWithExtraParams(model) call before fitting to ensure magnetic parameter values are synced to the kernel_module.

Added immediate sync to kernel_module when magnetic parameters are initialized.

Also, fixed typos in the polydisp widget.

Copy link
Contributor

@krzywon krzywon left a comment

Choose a reason for hiding this comment

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

This seems to be working now! I get real errors and the magnetic params change as a part of the fit. Code looks good.

@krzywon
Copy link
Contributor

krzywon commented Feb 2, 2026

@DrPaulSharp, when you are able, could you compare the behavior outlined in #3053 comment in both this branch and in main? I want to be sure others are able to see the difference in behavior before merging.

@DrPaulSharp
Copy link
Contributor

Hi @krzywon I've tried this, and on this branch I do find that the values change on a fit, but the errors are still extremely large:
image

@krzywon krzywon requested review from butlerpd and dehoni February 10, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phi and theta stuck at zero in 2D theory calculations

3 participants