Ticket #9037 (closed: fixed)
Logic error in refl gui
Reported by: | Owen Arnold | Owned by: | Keith Brown |
---|---|---|---|
Priority: | blocker | Milestone: | Release 3.1.1 |
Component: | Reflectometry | Keywords: | PatchCandidate |
Cc: | Blocked By: | ||
Blocking: | Tester: | Owen Arnold |
Description
The following is a bug introduced during last iteration's changes:
line 634 in refl_gui.py:
if isinstance(theta, numpy.float64): th = theta.size # This is wrong! elif not isinstance(theta, float): th = theta[len(theta) - 1] else: th = theta
The logic should be cleaned-up anyway.
Change History
comment:3 Changed 7 years ago by Keith Brown
- Status changed from assigned to inprogress
Refs #9037 Logic Error fixed
This was purely down to my own bad understanding of how numpy worked. It should now work as expected.
I also removed a debugging print statement as that was missed in another ticket.
Changeset: f13e8d15ff15fe5338fa639fcff053da0cb1df9d
comment:4 Changed 7 years ago by Keith Brown
Refs #9037 Streamlined check for an array
found out that groupget was already doing a check (it seems i did it and forgot about it) so the check in calcres wasn't required.
The array accessing in groupget has also been streamlined
Changeset: 718afe437517bd6c1ec77c021ad08bdf11c2ca13
comment:5 Changed 7 years ago by Keith Brown
- Status changed from inprogress to verify
- Resolution set to fixed
To tester:
You won't need to start the gui for this test, as the functions i edited in the python script are public so these can be tested in the python window.
This tests calcRes() and groupGet() with numpy.ndarray returning properties. groupGet() handles all the log fetching and if a log is a numpy.ndarray it'll return the last element of it.
You will need INTER00013460.nxs which is found in the ISIS sample data: http://download.mantidproject.org/download.psp?f=/SampleData/SampleData-ISIS.zip
Run this script:
from ui.reflectometer import refl_gui from time import gmtime, strftime,mktime from numpy import * #Load a reflectometry workspace w=Load("INTER00013460.nxs") #change the theta log inot a time series property so it's actually a numpy array tlog=kernel.FloatTimeSeriesProperty("theta") for i in arange(25): tlog.addValue(strftime("%Y-%m-%d %H:%M:%S", gmtime(mktime(gmtime())+i)),1.0*i*i) #add the fudged log w.mutableRun()['theta']=tlog #check the refl_gui script logVal = w.mutableRun()['theta'].value gg_return = refl_gui.groupGet(wksp=w, whattoget='samp', field='theta') print "LOG VALUE" print logVal print "LOG VALUE TYPE", type(logVal) print "REFL GROUPGET RETURN" , gg_return print "GROUPGET RETURN TYPE", type(gg_return) print "VALUE COMPARISON", logVal[-1] == gg_return refl_gui.calcRes(w)
the test should output the following:
- 'Log value type' should be a numpy.ndarray
- 'groupget return type' should be numpy.float64
- 'Log value's last element and 'refl groupget return' should be the same
- 'value comparison' should be true
- calcres will output 3 values, theta should match 'refl groupget return'
comment:6 Changed 7 years ago by Owen Arnold
- Status changed from verify to verifying
- Tester set to Owen Arnold
comment:7 Changed 7 years ago by Owen Arnold
- Status changed from verifying to closed
Merge remote-tracking branch 'origin/bugfix/9037_refl_numpy_fix'
Full changeset: 65c38c2051b86767cbe48140364192550f04216b
comment:8 Changed 7 years ago by Owen Arnold
Good use of python for a verification step by the way. More of this in future please.
comment:9 Changed 7 years ago by Nick Draper
- Milestone changed from Release 3.2 to Release 3.1.1
Moved to patch release 3.1.1
comment:10 Changed 7 years ago by Keith Brown
Refs #9037 Logic Error fixed
This was purely down to my own bad understanding of how numpy worked. It should now work as expected.
I also removed a debugging print statement as that was missed in another ticket.
Changeset: 0294354b38f02de4cc939a709edc83977c7c97ed
comment:11 Changed 7 years ago by Keith Brown
Refs #9037 Streamlined check for an array
found out that groupget was already doing a check (it seems i did it and forgot about it) so the check in calcres wasn't required.
The array accessing in groupget has also been streamlined
Changeset: 3a0ec2626bb507da9891d426689073d2e791e11c
comment:12 Changed 7 years ago by Russell Taylor
The commits above come from putting the work in this ticket into the patch release branch.
comment:13 Changed 5 years ago by Stuart Campbell
This ticket has been transferred to github issue 9880