-
Notifications
You must be signed in to change notification settings - Fork 2
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
941 append scaling to ws name #951
base: main
Are you sure you want to change the base?
Conversation
The new class WorkspaceNameAppender returns the changed workspace name for 4 operations: Sum, Subtract, Scale and Rebose. This implementation makes it easier to change the naming conventions if needed. Altered tests to import this class, so that tests get updated if naming convention changes.
@@ -25,6 +25,7 @@ | |||
from mslice.workspace.pixel_workspace import PixelWorkspace | |||
from mslice.workspace.histogram_workspace import HistogramWorkspace | |||
from mslice.workspace.workspace import Workspace | |||
from mslice.workspace.helperfunctions import WorkspaceNameAppender |
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.
Could we rename this WorkspaceNameHandler
or something, as we will have to prepend, not just append?
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.
This looks good. I can think of a few other instances where this would be useful to use, could you apply them here:
https://github.com/mantidproject/mslice/blob/5af891e298559faef096b834992c4cafc00d8bd4/src/mslice/util/mantid/algorithm_wrapper.py#L55&#L59
Also, we could do with getting rid of checks like this
if hasattr(workspace, str(ws)) and ws is not None and ws.name().endswith('_HIDDEN'): |
Something like
WorkspaceNameHander.isHidden(wsName)
.
If you search for __MSL
__HIDDEN
etc. will you will find other instances too.
My ambition is that we can look at this one class to understand what has happened to a workspace, rather than traipsing through the code looking for name modifications.
- Altered class for ws name handling of ws operatiosn - Started looking into other sections of code where names of ws are altered - Changed some parts of algorithm wrapper and scripting files - Currently it's a mess because I don't understand what these routines are doing yet
- Named methods in WorkspaceNameHandler according to their function - replaced several parts of code with new methods
- Removed '.' from workspaces names because might cause trouble with mantid - Added two methods for appending sufixes to workspaces
- Checked that changing the suffixes in my code makes tests fail - The prefixes '__MSL', '__MSLTMP' and suffix '_HIDDEN' are not covered by the unit tests
|
- Prevented scaling factor in workspace names from having more than 2 decimal places
24d3131
to
fda5254
Compare
325caeb
to
83ba1b2
Compare
for more information, see https://pre-commit.ci
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.
Good work, have done an initial review of implementation. Let me know what you think.
@@ -116,3 +115,60 @@ def __exit__(self, exc_type, exc_val, exc_tb): | |||
if self.workspace: | |||
self.workspace.remove_saved_attributes() | |||
return True | |||
|
|||
|
|||
class WorkspaceNameHandler: |
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.
I'm surprised there are so many options! I don't think it's ideal to have a separate function for each combination of functions. It's plausible in the future we have to add more, and therefore the number of combination functions will increase exponentially.
I wonder if it's a good idea to instead have a WorkspaceNameOptions
class, that has a constructor that default sets everything to false via named arguments.
We could then do a combination of functions by doing:
WorkspaceNameHandler.set_workspace_options(workspace.name, WorkSpaceOptions(hidden_from_mslice=True, hidden_from_ADS=True))
You would then only need individual functions in the WorkspaceNameHandler
class, and these would not have to be exposed.
Perhaps when checking we could then do:
WorkspaceNameHandler.assert_workspace_options(workspace, WorkspaceOptions(hidden_from_mslice=True, hidden_from_ADS=True)
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.
I have now implemented these suggestions, but instead of creating and entirely separate WorkspaceOptions
class, I preferred to opt for two methods get_name
and assert_name
that mimicks this. So in this case one would do WorkspaceNameHandler(workspace.name).get_name(hidden_from_mslice=True, hidden_from_ADS=True
and WorkspaceNameHandler(workspace.name).assert_name(hidden_from_mslice=True, hiddden_from_ADS=True)
.
def merged(self) -> str: | ||
return self.add_sufix('_merged') | ||
|
||
def isHiddenFromMsl(self) -> bool: |
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.
You've swapped from snake case to camel case here, worth having a flick through these if you haven't already: https://developer.mantidproject.org/Standards/PythonStandards.html
This reverts commit 9883cf5.
Summary
Description of work:
_subtracted
, I changed it to include the scaling factor of the background workspace to_minus_ssf_0.95
, as seen in:Question
To test:
WorkspaceNameAppender
and tell me if it's fine (maybe needs an initializer method?)workspaces.helperfunctions
), is it the best location or should I move somewhere else?Fixes #941 .