-
Notifications
You must be signed in to change notification settings - Fork 40
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
Ess gui 1574 invariant #1590
Ess gui 1574 invariant #1590
Changes from 1 commit
23968a7
f7b872d
cba0e10
7618493
af992c4
dc18842
53de045
11e3a99
ea89300
024a434
992f9f2
48041a6
369d9da
40b6d20
5940cbd
e636f16
efcef1d
89741d4
c1080fe
c0fa5ad
3952b23
3a364c7
5939b17
5e0592c
7f7a523
574dc97
8a607a9
0d50b7a
01456e7
812dcde
4240977
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,13 +60,14 @@ def __init__(self, parent): | |
|
||
# invariant total | ||
self.qstar_total = None | ||
self.qdata = None | ||
self.qhigh = None | ||
self.qlow = None | ||
self._model = None | ||
|
||
self.progress_low_qstar = 0.0 | ||
self.progress_high_qstar = 0.0 | ||
self.progress_qstar = 100.0 | ||
self.progress_data_qstar = 100.0 | ||
|
||
def setModel(self, model): | ||
""" """ | ||
|
@@ -77,13 +78,20 @@ def showDialog(self): | |
# Pull out data from the model | ||
self.qstar_total = float(self._model.item(WIDGETS.W_INVARIANT).text()) | ||
|
||
self.txtQData.setText(str(self.qstar_total)) | ||
self.txtQDataErr.setText(self._model.item(WIDGETS.W_INVARIANT_ERR).text()) | ||
|
||
# Reset progress counters | ||
self.progress_low_qstar = 0.0 | ||
self.progress_high_qstar = 0.0 | ||
self.progress_qstar = 100.0 | ||
self.progress_data_qstar = 100.0 | ||
|
||
# Q* from data | ||
self.qdata = float(self._model.item(WIDGETS.D_DATA_QSTAR).text()) | ||
rozyczko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
self.txtQData.setText(str(self.qdata)) | ||
self.txtQDataErr.setText(self._model.item(WIDGETS.D_DATA_QSTAR_ERR).text()) | ||
try: | ||
self.progress_data_qstar = (self.qdata/self.qstar_total)*100.0 | ||
except: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid bare
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again am going to ask to defer this. This would be a change to the original structure of the code. The change here is another copy paste from the other identical sections below it. I would rather keep the style the same until we change all of them. Otherwise it becomes hard to follow (at least for me who is not a python ninja 😃 when each related bit is written with a different style. |
||
self.progress_data_qstar = 'error' | ||
|
||
# Low-Q | ||
if self._model.item(WIDGETS.W_ENABLE_LOWQ).text() == "true": | ||
|
@@ -107,11 +115,6 @@ def showDialog(self): | |
except: | ||
self.progress_high_qstar = 'error' | ||
|
||
try: | ||
self.progress_qstar -= self.progress_low_qstar + self.progress_high_qstar | ||
except: | ||
self.progress_qstar = 'error' | ||
|
||
# check values and display warning | ||
if self.checkValues(): | ||
self.lblWarning.setText(self.checkValues()) | ||
|
@@ -127,10 +130,10 @@ def showDialog(self): | |
else: | ||
self.progressBarHighQ.setValue(self.progress_high_qstar) | ||
|
||
if self.progress_qstar == 'error': | ||
if self.progress_data_qstar == 'error': | ||
self.progressBarData.setValue(0) | ||
else: | ||
self.progressBarData.setValue(self.progress_qstar) | ||
self.progressBarData.setValue(self.progress_data_qstar) | ||
|
||
self.show() | ||
|
||
|
@@ -149,10 +152,10 @@ def checkValues(self): | |
return warning_msg | ||
|
||
msg = '' | ||
if self.progress_qstar == 'error': | ||
if self.progress_data_qstar == 'error': | ||
msg += 'Error occurred when computing invariant from data.\n ' | ||
try: | ||
if float(self.progress_qstar) > 100: | ||
if float(self.progress_data_qstar) > 100: | ||
msg += "Invariant Q contribution is greater than 100% .\n" | ||
except ValueError: | ||
# Text message, skip msg update | ||
|
@@ -202,4 +205,7 @@ def checkValues(self): | |
msg += "The sum of all extrapolated contributions is higher " \ | ||
"than 5% of the invariant.\n" | ||
|
||
if msg == '': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to output it or it was set for debugging purposes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No. That can stay in. Similar messaging is in 4.x. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes this was very deliberate (and took me a while to figure out). Currently, without this, the default is message in the details warnings box is: NOTE: this is set in the panel initialization as the default entry at which point it is true that no details are avalialbe since the code running the calculation has not run so decided that changing it there was not correct? Also, oddly line 59 sets the same message but is never used anywhere that I can see! (and changing it has no effect I could see). Was going to delete but decided I didn't know enough? Should we delete? self.warning_msg = "No Details on calculations available...\n" |
||
msg = "No Warnings to report\n" | ||
|
||
return msg |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,6 +251,8 @@ def calculateThread(self, extrapolation): | |
self.updateFromModel() | ||
msg = '' | ||
|
||
qstar_data = 0.0 | ||
qstar_data_err = 0.0 | ||
qstar_low = 0.0 | ||
qstar_low_err = 0.0 | ||
qstar_high = 0.0 | ||
|
@@ -287,7 +289,7 @@ def calculateThread(self, extrapolation): | |
calculation_failed = False | ||
|
||
try: | ||
qstar_total, qstar_total_error = inv.get_qstar_with_error() | ||
qstar_data, qstar_data_err = inv.get_qstar_with_error() | ||
except Exception as ex: | ||
msg += str(ex) | ||
calculation_failed = True | ||
|
@@ -412,13 +414,15 @@ def calculateThread(self, extrapolation): | |
reactor.callFromThread(self.updateModelFromThread, WIDGETS.W_SPECIFIC_SURFACE_ERR, | ||
surface_error) | ||
|
||
qstar_total += qstar_low + qstar_high | ||
qstar_total = qstar_data + qstar_low + qstar_high | ||
qstar_total_error = np.sqrt( | ||
qstar_total_error * qstar_total_error | ||
qstar_data_err * qstar_total_error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't be "qstar_data_err * qstar_data_err" ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. Will need @butlerpd to check this one. Where these things are calculated and passed from is a bit of a can of worms as you no doubt discovered. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @smk78 for letting me take a look - sometimes weird things happen in this invariant code indeed.... but in this case I am thoroughly embarrassed. @wpotrzebowski is correct. Here we are just adding the errors in quadrature not doine sophisticated error propagation through a function (where something like this might be used). My bad (must have been in a hurry to get to something else |
||
+ qstar_low_err * qstar_low_err + qstar_high_err * qstar_high_err) | ||
|
||
reactor.callFromThread(self.updateModelFromThread, WIDGETS.W_INVARIANT, qstar_total) | ||
reactor.callFromThread(self.updateModelFromThread, WIDGETS.W_INVARIANT_ERR, qstar_total_error) | ||
reactor.callFromThread(self.updateModelFromThread, WIDGETS.D_DATA_QSTAR, qstar_data) | ||
reactor.callFromThread(self.updateModelFromThread, WIDGETS.D_DATA_QSTAR_ERR, qstar_data_err) | ||
reactor.callFromThread(self.updateModelFromThread, WIDGETS.D_LOW_QSTAR, qstar_low) | ||
reactor.callFromThread(self.updateModelFromThread, WIDGETS.D_LOW_QSTAR_ERR, qstar_low_err) | ||
reactor.callFromThread(self.updateModelFromThread, WIDGETS.D_HIGH_QSTAR, qstar_high) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename
progress_*
topercentage_*
. The code is using a progress bar to represent a fixed percentage, not one that updates as the calculation progresses. I spent some time looking for the loop which updated the progress without success.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed it is .... not ideal. However I am going to ask to defer this to the next effort. Indeed part of the naming comes from the fact that the widget chosen for this IS in fact a progress bar which is not ideal either and part of @smk78 issue with why low q is always reporting 0% when 4.x was reporting a value of 0.6%. Also I am not yet familiar enough with the code base much less Qt to make such wholesale changes and testing for unintended consequences (e.g. did I really catch all the calls using it) to feel comfortable doing this before a release with zero time to look at it.
For now that bit is just copied/pasted and keeping exactly the same style as the entire rest of the invariant GUI code.