Skip to content

Fitting widget refactor#2651

Closed
rozyczko wants to merge 7 commits intomainfrom
fitting_widget_refactor
Closed

Fitting widget refactor#2651
rozyczko wants to merge 7 commits intomainfrom
fitting_widget_refactor

Conversation

@rozyczko
Copy link
Copy Markdown
Member

Description

This is a code maintenance/upkeep commit.
FittingWidget.py grew too big and needed to be refactored.
This PR addresses polydispersity and magnetism tabs/logic.

Fixes #

How Has This Been Tested?

Local dev build on Win10

Review Checklist (please remove items if they don't apply):

  • Code has been reviewed
  • Functionality has been tested
  • Windows installer (GH artifact) has been tested (installed and worked)
  • MacOSX installer (GH artifact) has been tested (installed and worked)

@wpotrzebowski wpotrzebowski added Discuss At The Call Issues to be discussed at the fortnightly call and removed Discuss At The Call Issues to be discussed at the fortnightly call labels Sep 25, 2023
Copy link
Copy Markdown
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 is a lot cleaner and makes FittingWidget a bit more accessible. I haven't combed through all of the code, but the majority of the additions in new locations look like a simple copy/paste from FittingWidget.

I would suggest looking at the work in #2647 to be sure the changes made there are also applied here since merging the two will be nearly impossible.


# keep local copy of kernel parameters, as they will change during the update
self.kernel_module_copy = copy.deepcopy(self.kernel_module)
self.logic.kernel_module_copy = copy.deepcopy(self.logic.kernel_module)
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.

kernel_module_copy is still in FittingWidget, not FittingLogic.


self.iterateOverPolyModel(updateFittedValues)

def updateFullMagnetModel(self, param_dict):
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.

Would this fit better in MagnetismWidget?

updateDataSignal = QtCore.Signal()
iterateOverModelSignal = QtCore.Signal()

def __init__(self, parent=None, logic=None):
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.

parent is never used.

self._magnet_model = FittingUtilities.ToolTippedItemModel()
self.is2D = False
self.isActive = False
self.logic = logic
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.

Would this be better served as self.parent.logic? The current implementation makes it seem like the magnetism and polydispersity widgets have their own logic elements.

# Just create a simple param entry
self.addNameToPolyModel(i, param_name)

def addNameToPolyModel(self, i, param_name):
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.

The i parameter was removed from this method in #2647 due to #2563, which is related to the distribution combo box of multiplicity models. You might want to do something similar here.

Short description of why this fails: In line 237, a polydispersity row is added to the end of all items, but then, in row 244, the combo box is added to the ith row, but i only goes up to the number of parameters, not accounting for n_shells and the number of polydisperse parameters in each shell.

Comment on lines +3849 to +3857
if param_name != param.name:
return
# Modify the param value
self._model_model.blockSignals(True)
if self.has_error_column:
# err column changes the indexing
self._model_model.item(row, 0).child(0).child(0,5).setText(combo_string)
else:
self._model_model.item(row, 0).child(0).child(0,4).setText(combo_string)
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.

param and combo_string and not defined in this context.

@wpotrzebowski wpotrzebowski added Discuss At The Call Issues to be discussed at the fortnightly call and removed Discuss At The Call Issues to be discussed at the fortnightly call labels Oct 9, 2023
@butlerpd butlerpd added Discuss At The Call Issues to be discussed at the fortnightly call and removed Discuss At The Call Issues to be discussed at the fortnightly call labels Oct 23, 2023
@butlerpd
Copy link
Copy Markdown
Member

Should this be part of a 6.0 release? or is it a bridge too far?

@butlerpd butlerpd added the Discuss At The Call Issues to be discussed at the fortnightly call label Nov 19, 2023
@butlerpd
Copy link
Copy Markdown
Member

Could be done as 6.1 so not a top priority but would be nice to have

@rozyczko
Copy link
Copy Markdown
Member Author

Could be done as 6.1 so not a top priority but would be nice to have

Seeing how close we get with 6.0, I'd prefer to postpone it to 6.1. Maybe merge to main as soon as 6.0 is out so we have time for testing?

@rozyczko rozyczko marked this pull request as draft November 29, 2023 09:16
@wpotrzebowski wpotrzebowski removed the Discuss At The Call Issues to be discussed at the fortnightly call label Dec 3, 2023
@rozyczko
Copy link
Copy Markdown
Member Author

I will have to redo parts of it seeing how the original FittingWidget changed.

@rozyczko rozyczko mentioned this pull request Jan 7, 2025
4 tasks
@krzywon
Copy link
Copy Markdown
Contributor

krzywon commented Mar 20, 2025

The rebased branch was just merged. Can we close this PR and delete the branch now?

@jamescrake-merani
Copy link
Copy Markdown
Contributor

I don't see why not, but lets double check at the technical meeting this afternoon.

@krzywon krzywon closed this Mar 21, 2025
@krzywon krzywon deleted the fitting_widget_refactor branch December 12, 2025 15:53
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.

5 participants