Skip to content

Commit

Permalink
Merge pull request #118 from mantidproject/folder-structure-4
Browse files Browse the repository at this point in the history
Re-structure directories 4
  • Loading branch information
GuiMacielPereira authored Jul 8, 2024
2 parents 9744b67 + 0f71923 commit 5910398
Show file tree
Hide file tree
Showing 24 changed files with 46 additions and 47 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Ignore cache files
__pycache__/
*.py[cod]
output_npz_for_testing
!experiments/original_inputs/output_npz_for_testing

src/vesuvio_analysis/core_functions/bootstrap_ws/
running_times.txt
figures/
mvesuvio/tests/analysis/system/data/input/sample_input
tests/analysis/data/inputs/sample_test/output_files/
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ repos:
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
exclude: 'mvesuvio/vesuvio_analysis/scribles|mvesuvio/experiments/original_inputs|mvesuvio/original_inputs.py|unpackaged'
exclude: 'unpackaged|legacy'
types: ['python']
- id: check-added-large-files
args: ['--maxkb=4096']
exclude: 'mvesuvio/experiments/original_inputs|unpackaged'
exclude: 'unpackaged|legacy'

- repo: https://github.com/PyCQA/flake8.git
rev: 6.1.0
hooks:
- id: flake8
args: ['--config', 'config.flake8']
exclude: 'mvesuvio/vesuvio_analysis/scribles|mvesuvio/experiments/original_inputs|mvesuvio/original_inputs.py|unpackaged'
exclude: 'unpackaged|legacy'
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ dependencies:
- conda-wrappers
- pre-commit==2.15 #review this
- coverage
- mantid==6.8
- mantid
- matplotlib
- iminuit
- h5py
- mock
- pytest
- jacobi==0.4.2 #pinned until newer versions functionality confirmed
12 changes: 8 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tests_require = [
"Bug Tracker" = "https://github.com/mantidproject/vesuvio/issues"

[project.entry-points]
console_scripts = { mvesuvio = "mvesuvio.scripts:main" }
console_scripts = { mvesuvio = "mvesuvio.main:main" }

[tool.setuptools.packages.find]
where = ["src"]
Expand All @@ -51,19 +51,23 @@ namespaces = false
"mvesuvio.config" = ["*.properties"]

[tool.pytest.ini_options]
pythonpath = ["."]
testpaths = ["tests/system_tests"]
pythonpath = [
".",
"./src"
]
testpaths = ["tests"]
filterwarnings = ["error"]

[tool.coverage.report]
include = [
"*/src/mvesuvio/*",
"*/tools/calibration_scripts/*"
]

omit = [
"*tests*",
"*unpackaged*",
"*legacy"
"*legacy*"
]

fail_under = 0
Expand Down
2 changes: 1 addition & 1 deletion src/mvesuvio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from mvesuvio._version import __version__
__project_url__ = "https://github.com/mantidproject/vesuvio"

from mvesuvio.scripts import main
from mvesuvio.main import main

class ArgInputs:
def __init__(self, command):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from mantid.simpleapi import *
from scipy import optimize

from .fit_in_yspace import passDataIntoWS, replaceZerosWithNCP
from .analysis_fitting import passDataIntoWS, replaceZerosWithNCP

# Format print output of arrays
np.set_printoptions(suppress=True, precision=4, linewidth=100, threshold=sys.maxsize)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .analysis_functions import iterativeFitForDataReduction
from .analysis_reduction import iterativeFitForDataReduction
from mantid.api import AnalysisDataService
from mantid.simpleapi import CreateEmptyTableWorkspace
import numpy as np
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
import argparse
from os import environ, path
from mvesuvio.scripts import handle_config
from mvesuvio.util import handle_config


def main(manual_args=None):
Expand Down Expand Up @@ -87,7 +87,7 @@ def __run_analysis(yes_to_all):
environ["MANTIDPROPERTIES"] = path.join(
handle_config.VESUVIO_CONFIG_PATH, "Mantid.user.properties"
)
from mvesuvio import analysis_runner
from mvesuvio.main import analysis_runner

analysis_runner.run(yes_to_all)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from pathlib import Path
import importlib
import sys
from mvesuvio.run_script import runScript
from mvesuvio.scripts import handle_config
from mvesuvio.run_routine import runRoutine
from mvesuvio.util import handle_config


def run(yes_to_all=False):
Expand All @@ -21,7 +21,7 @@ def run(yes_to_all=False):
yFitIC = ai.YSpaceFitInitialConditions
userCtr = ai.UserScriptControls

runScript(
runRoutine(
userCtr,
wsBackIC,
wsFrontIC,
Expand Down
8 changes: 4 additions & 4 deletions src/mvesuvio/run_script.py → src/mvesuvio/run_routine.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from mvesuvio.ICHelpers import (
from mvesuvio.util.process_inputs import (
buildFinalWSName,
completeICFromInputs,
completeYFitIC,
)
from mvesuvio.fit_in_yspace import fitInYSpaceProcedure
from mvesuvio.procedures import (
from mvesuvio.analysis_fitting import fitInYSpaceProcedure
from mvesuvio.analysis_routines import (
runIndependentIterativeProcedure,
runJointBackAndForwardProcedure,
runPreProcToEstHRatio,
Expand All @@ -13,7 +13,7 @@
)
from mantid.api import mtd

def runScript(
def runRoutine(
userCtr,
wsBackIC,
wsFrontIC,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from mantid.simpleapi import Load, LoadVesuvio, SaveNexus, DeleteWorkspace
from pathlib import Path
from mvesuvio.scripts import handle_config
from mvesuvio.util import handle_config
from mantid.kernel import logger
import ntpath

Expand Down
Empty file.
Binary file not shown.
13 changes: 6 additions & 7 deletions tests/analysis/system/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import numpy as np
import numpy.testing as nptest
from pathlib import Path
from mvesuvio.run_script import runScript
from mvesuvio.scripts import handle_config
from mvesuvio.run_routine import runRoutine
from mvesuvio.util import handle_config
from tests.analysis.data.inputs.sample_test import (
LoadVesuvioBackParameters,
LoadVesuvioFrontParameters,
Expand All @@ -13,10 +13,9 @@
UserScriptControls,
)
import mvesuvio
sample_test_dir = Path(__file__).absolute().parent.parent / "data" / "inputs" / "sample_test.py"
mvesuvio.set_config(
ip_folder=str(Path(handle_config.VESUVIO_PACKAGE_PATH).joinpath("config", "ip_files")),
inputs_file=str(sample_test_dir)
inputs_file=str(Path(__file__).absolute().parent.parent / "data" / "inputs" / "sample_test.py")
)

ipFilesPath = Path(handle_config.read_config_var("caching.ipfolder"))
Expand All @@ -40,7 +39,7 @@ def get_current_result(cls):

@classmethod
def _run(cls):
scattRes, yfitRes = runScript(
scattRes, yfitRes = runRoutine(
UserScriptControls(),
LoadVesuvioBackParameters(ipFilesPath),
LoadVesuvioFrontParameters(ipFilesPath),
Expand All @@ -60,9 +59,9 @@ def _run(cls):

@classmethod
def _load_benchmark_results(cls):
testPath = Path(__file__).absolute().parent.parent / "data" / "outputs"
benchmarkPath = Path(__file__).absolute().parent.parent / "data" / "benchmark"
benchmarkResults = np.load(
str(testPath / "stored_spec_144-182_iter_3_GC_MS.npz")
str(benchmarkPath / "stored_spec_144-182_iter_3_GC_MS.npz")
)
AnalysisRunner._benchmarkResults = benchmarkResults

Expand Down
13 changes: 6 additions & 7 deletions tests/analysis/system/test_yspace_fit.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from mvesuvio.run_script import runScript
from mvesuvio.run_routine import runRoutine
from mantid.simpleapi import Load
from mantid.api import AnalysisDataService
from pathlib import Path
import numpy as np
import unittest
import numpy.testing as nptest
from mvesuvio.scripts import handle_config
from mvesuvio.util import handle_config
from tests.analysis.data.inputs.sample_test import (
LoadVesuvioBackParameters,
LoadVesuvioFrontParameters,
Expand All @@ -14,10 +14,9 @@
YSpaceFitInitialConditions,
)
import mvesuvio
sample_test_dir = Path(__file__).absolute().parent.parent / "data" / "inputs" / "sample_test.py"
mvesuvio.set_config(
ip_folder=str(Path(handle_config.VESUVIO_PACKAGE_PATH).joinpath("config", "ip_files")),
inputs_file=str(sample_test_dir)
inputs_file=str(Path(__file__).absolute().parent.parent / "data" / "inputs" / "sample_test.py")
)
np.set_printoptions(suppress=True, precision=8, linewidth=150)

Expand Down Expand Up @@ -47,7 +46,7 @@ class AnalysisRunner:
_benchmarkResults = None
_currentResults = None
_input_data_path = Path(__file__).absolute().parent.parent / "data" / "inputs"
_output_data_path = Path(__file__).absolute().parent.parent / "data" / "outputs"
_benchmark_path = Path(__file__).absolute().parent.parent / "data" / "benchmark"
_workspaces_loaded = False

@classmethod
Expand Down Expand Up @@ -86,14 +85,14 @@ def _load_workspaces(cls):
def _run(cls):
cls.load_workspaces() # Load data to skip run of routine

scattRes, yfitRes = runScript(
scattRes, yfitRes = runRoutine(
userCtr, wsBackIC, wsFrontIC, bckwdIC, fwdIC, yFitIC, True
)
cls._currentResults = yfitRes

@classmethod
def _load_benchmark_results(cls):
cls._benchmarkResults = np.load(str(cls._output_data_path / "stored_yspace_fit.npz"))
cls._benchmarkResults = np.load(str(cls._benchmark_path / "stored_yspace_fit.npz"))


class TestSymSumYSpace(unittest.TestCase):
Expand Down
13 changes: 6 additions & 7 deletions tests/analysis/system/test_yspace_fit_GC.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from mvesuvio.run_script import runScript
from mvesuvio.run_routine import runRoutine
from mantid.simpleapi import Load
from mantid.api import AnalysisDataService
from pathlib import Path
import numpy as np
import unittest
import numpy.testing as nptest
from mvesuvio.scripts import handle_config
from mvesuvio.util import handle_config
from tests.analysis.data.inputs.sample_test import (
LoadVesuvioBackParameters,
LoadVesuvioFrontParameters,
Expand All @@ -14,10 +14,9 @@
YSpaceFitInitialConditions,
)
import mvesuvio
sample_test_dir = Path(__file__).absolute().parent.parent / "data" / "inputs" / "sample_test.py"
mvesuvio.set_config(
ip_folder=str(Path(handle_config.VESUVIO_PACKAGE_PATH).joinpath("config", "ip_files")),
inputs_file=str(sample_test_dir)
inputs_file=str(Path(__file__).absolute().parent.parent / "data" / "inputs" / "sample_test.py")
)
np.set_printoptions(suppress=True, precision=8, linewidth=150)

Expand Down Expand Up @@ -48,7 +47,7 @@ class AnalysisRunner:
_benchmarkResults = None
_currentResults = None
_input_data_path = Path(__file__).absolute().parent.parent / "data" / "inputs"
_output_data_path = Path(__file__).absolute().parent.parent / "data" / "outputs"
_benchmark_path = Path(__file__).absolute().parent.parent / "data" / "benchmark"
_workspaces_loaded = False

@classmethod
Expand Down Expand Up @@ -87,15 +86,15 @@ def _load_workspaces(cls):
def _run(cls):
cls.load_workspaces()

scattRes, yfitRes = runScript(
scattRes, yfitRes = runRoutine(
userCtr, wsBackIC, wsFrontIC, bckwdIC, fwdIC, yFitIC, True
)
cls._currentResults = yfitRes

@classmethod
def _load_benchmark_results(cls):
cls._benchmarkResults = np.load(
str(cls._output_data_path / "stored_yspace_fit_GC.npz")
str(cls._benchmark_path / "stored_yspace_fit_GC.npz")
)


Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/unit/test_analysis_functions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from mock import MagicMock
from mvesuvio.analysis_functions import extractWS
from mvesuvio.analysis_reduction import extractWS


class TestAnalysisFunctions(unittest.TestCase):
Expand Down
File renamed without changes.

0 comments on commit 5910398

Please sign in to comment.