Skip to content

Commit

Permalink
Do workaround for mantid editor bug
Browse files Browse the repository at this point in the history
Mantid editor caches variables in the module scope, leading to wrong behaviours

The changes implemented in this commit fix this by calling the variables inside functions
  • Loading branch information
GuiMacielPereira committed Feb 13, 2024
1 parent 600a8bb commit 5238de6
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions mvesuvio/vesuvio_analysis/ICHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@
from mantid.kernel import logger
import ntpath

inputsPath = Path(handle_config.read_config_var("caching.inputs"))
scriptName = inputsPath.name.removesuffix(".py")
experimentPath = inputsPath.parent / scriptName

def _get_expr_path():
inputsPath = Path(handle_config.read_config_var("caching.inputs"))
scriptName = _get_script_name()
experimentPath = inputsPath.parent / scriptName
return experimentPath


def _get_script_name():
inputsPath = Path(handle_config.read_config_var("caching.inputs"))
scriptName = inputsPath.name.removesuffix(".py")
return scriptName

# inputsPath = Path(handle_config.read_config_var("caching.inputs"))
# scriptName = inputsPath.name.removesuffix(".py")
# experimentPath = inputsPath.parent / scriptName


def completeICFromInputs(IC, wsIC):
"""Assigns new methods to the initial conditions class from the inputs of that class"""
scriptName = _get_script_name()

assert (
IC.lastSpec > IC.firstSpec
Expand Down Expand Up @@ -81,6 +95,10 @@ def completeICFromInputs(IC, wsIC):


def setInputWSForSample(wsIC):
experimentPath = _get_expr_path()
scriptName = _get_script_name()
print(scriptName.upper())

inputWSPath = experimentPath / "input_ws"
inputWSPath.mkdir(parents=True, exist_ok=True)

Expand Down Expand Up @@ -114,6 +132,7 @@ def getRunningMode(wsIC):


def setOutputDirsForSample(IC):
experimentPath = _get_expr_path()
outputPath = experimentPath / "output_files"
outputPath.mkdir(parents=True, exist_ok=True)

Expand Down Expand Up @@ -208,6 +227,8 @@ def completeBootIC(bootIC, bckwdIC, fwdIC, yFitIC):

def setBootstrapDirs(bckwdIC, fwdIC, bootIC, yFitIC):
"""Form bootstrap output data paths"""
experimentPath = _get_expr_path()
scriptName = _get_script_name()

# Select script name and experiments path
sampleName = bckwdIC.scriptName # Name of sample currently running
Expand Down Expand Up @@ -318,12 +339,14 @@ def noOfHistsFromTOFBinning(IC):


def buildFinalWSName(procedure: str, IC):
scriptName = _get_script_name()
# Format of corrected ws from last iteration
name = scriptName + "_" + procedure + "_" + str(IC.noOfMSIterations)
return name


def completeYFitIC(yFitIC):
experimentPath = _get_expr_path()
# Set directories for figures
figSavePath = experimentPath / "figures"
figSavePath.mkdir(exist_ok=True)
Expand Down

0 comments on commit 5238de6

Please sign in to comment.