Ticket #6108 (closed: fixed)
Rename bug when workspace variable is in Python
Reported by: | Martyn Gigg | Owned by: | Martyn Gigg |
---|---|---|---|
Priority: | critical | Milestone: | Release 2.4 |
Component: | Mantid | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Tester: | Wenduo Zhou |
Description
- Run this is Python to produce a workspace called 'ws1'
ws1 = Load('MAR11001.raw')
- Use the dock to rename the workspace to 'ws2'
- Rerun the above python snippet.
- Instead of producing a new ws1, it will produce ws2
Change History
comment:1 Changed 8 years ago by Nick Draper
- Owner set to Martyn Gigg
- Status changed from new to assigned
comment:2 Changed 8 years ago by Martyn Gigg
- Status changed from assigned to accepted
The current framework underneath tries to be clever with the naming so that you can do this:
def convert(workspace): # Replace the input workspace workspace = simpleapi.ConvertUnits(workspace, Target='Energy') return workspace raw = simpleapi.LoadRaw('IRS21360.raw',SpectrumMax=1) raw = convert(raw)
and still have it replace the workspace and not create a new one called 'workspace'.
I think the way forward is to move back to the simple approach of saying the workspace takes the LHS name and to replace in a function requires using the other syntax:
def convert(workspace): # Replace the input workspace simpleapi.ConvertUnits(InputWorkspace=workspace, OutputWorkspace=workspace,Target='Energy') return workspace raw = simpleapi.LoadRaw('IRS21360.raw',SpectrumMax=1) raw = convert(raw)
Changing the current behaviour will fix the more critical and confusing rename bug and anyone using the new-style function syntax will get an error when there workspace doesn't have the correct name.
comment:3 Changed 8 years ago by Martyn Gigg
Fix rename bug in simpleapi. Refs #6108
Changeset: 86b95e8f80067c1766779f723146ddff18ea0554
comment:4 Changed 8 years ago by Martyn Gigg
- Status changed from accepted to verify
- Resolution set to fixed
Tester: Check the steps in the first description now do the correct thing. Also play with the python in comment #2 and check that the output makes sense and that the workspace is correct.
Although I'm not sure what the solution is here, as the implications of changing the underlying behaviour need to be carefully considered