Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fitting widget refactor #2651

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Fitting widget refactor #2651

wants to merge 7 commits into from

Conversation

rozyczko
Copy link
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
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.

@@ -1891,7 +1677,7 @@ def onFit(self):
return

# 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
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.setFocus()

self.iterateOverPolyModel(updateFittedValues)

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

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

@rozyczko
Copy link
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
Member Author

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

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.

4 participants