From 4b475f69dddf16264cd1989776c1d0ed8a22c663 Mon Sep 17 00:00:00 2001 From: Paul Sharp <44529197+DrPaulSharp@users.noreply.github.com> Date: Wed, 16 Apr 2025 14:09:48 +0100 Subject: [PATCH 1/4] Renames "BayesResults" as "OutputBayesResult" in "rat_core" --- cpp/includes/defines.h | 6 +++--- cpp/rat.cpp | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cpp/includes/defines.h b/cpp/includes/defines.h index 67b0fda7..02b5fa97 100644 --- a/cpp/includes/defines.h +++ b/cpp/includes/defines.h @@ -262,12 +262,12 @@ struct DreamOutput py::array_t CR; }; -const std::string docsBayesResults = R"(The Python binding for the C++ bayesResults struct. +const std::string docsOutputBayesResult = R"(The Python binding for the C++ bayesResults struct. The results of a Bayesian RAT calculation. Parameters ---------- -predictionIntervals : RATapi.rat_core.orePredictionIntervals +predictionIntervals : RATapi.rat_core.PredictionIntervals The prediction intervals. confidenceIntervals : RATapi.rat_core.ConfidenceIntervals The 65% and 95% confidence intervals for the best fit results. @@ -282,7 +282,7 @@ chain : np.ndarray The ``i``'th column of the array contains the chain for parameter ``fitNames[i]``. )"; -struct BayesResults +struct OutputBayesResult { PredictionIntervals predictionIntervals; ConfidenceIntervals confidenceIntervals; diff --git a/cpp/rat.cpp b/cpp/rat.cpp index a92dc49d..e699ad11 100644 --- a/cpp/rat.cpp +++ b/cpp/rat.cpp @@ -510,9 +510,9 @@ ProblemDefinition problemDefinitionFromStruct(const RAT::b_ProblemDefinition pro return problem_def; } -BayesResults bayesResultsFromStruct(const RAT::BayesResults results) +OutputBayesResult OutputBayesResultsFromStruct(const RAT::BayesResults results) { - BayesResults bayesResults; + OutputBayesResult bayesResults; bayesResults.chain = pyArrayFromRatArray2d(results.chain); @@ -575,7 +575,7 @@ out_problem_def : Rat.rat_core.ProblemDefinition The project input with the updated fit values. results : Rat.rat_core.OutputResult The results from a RAT calculation. -bayes_result : Rat.rat_core.BayesResults +bayes_result : Rat.rat_core.OutputBayesResult The extra results if RAT calculation is Bayesian. )"; @@ -593,7 +593,7 @@ py::tuple RATMain(const ProblemDefinition& problem_def, const Control& control) out_problem_def.customFiles = problem_def.customFiles.attr("copy")(); return py::make_tuple(out_problem_def, OutputResultFromStruct(results), - bayesResultsFromStruct(bayesResults)); + OutputBayesResultsFromStruct(bayesResults)); } const std::string docsMakeSLDProfileXY = R"(Creates the profiles for the SLD plots @@ -787,14 +787,14 @@ PYBIND11_MODULE(rat_core, m) { .def_readwrite("R_stat", &DreamOutput::R_stat) .def_readwrite("CR", &DreamOutput::CR); - py::class_(m, "BayesResults", docsBayesResults.c_str()) + py::class_(m, "OutputBayesResult", docsOutputBayesResult.c_str()) .def(py::init<>()) - .def_readwrite("predictionIntervals", &BayesResults::predictionIntervals) - .def_readwrite("confidenceIntervals", &BayesResults::confidenceIntervals) - .def_readwrite("dreamParams", &BayesResults::dreamParams) - .def_readwrite("dreamOutput", &BayesResults::dreamOutput) - .def_readwrite("nestedSamplerOutput", &BayesResults::nestedSamplerOutput) - .def_readwrite("chain", &BayesResults::chain); + .def_readwrite("predictionIntervals", &OutputBayesResult::predictionIntervals) + .def_readwrite("confidenceIntervals", &OutputBayesResult::confidenceIntervals) + .def_readwrite("dreamParams", &OutputBayesResult::dreamParams) + .def_readwrite("dreamOutput", &OutputBayesResult::dreamOutput) + .def_readwrite("nestedSamplerOutput", &OutputBayesResult::nestedSamplerOutput) + .def_readwrite("chain", &OutputBayesResult::chain); py::class_(m, "Calculation", docsCalculation.c_str()) .def(py::init<>()) From 34516e5a1d50654767c098080ba4ca975ab0d478 Mon Sep 17 00:00:00 2001 From: Paul Sharp <44529197+DrPaulSharp@users.noreply.github.com> Date: Wed, 16 Apr 2025 15:43:56 +0100 Subject: [PATCH 2/4] Updates submodule --- RATapi/inputs.py | 2 +- RATapi/outputs.py | 4 ++-- RATapi/utils/plotting.py | 6 +++--- cpp/RAT | 2 +- cpp/rat.cpp | 42 +++++++++++++++++++--------------------- tests/conftest.py | 2 +- tests/test_inputs.py | 6 +++--- tests/test_plotting.py | 18 ++++++++--------- tests/test_run.py | 4 ++-- 9 files changed, 42 insertions(+), 44 deletions(-) diff --git a/RATapi/inputs.py b/RATapi/inputs.py index 3798cb0f..06d9f82c 100644 --- a/RATapi/inputs.py +++ b/RATapi/inputs.py @@ -284,7 +284,7 @@ def make_problem(project: RATapi.Project) -> ProblemDefinition: problem.numberOfContrasts = len(project.contrasts) problem.geometry = project.geometry problem.useImaginary = project.absorption - problem.repeatLayers = [[0, 1]] * len(project.contrasts) # This is marked as "to do" in RAT + problem.repeatLayers = [1] * len(project.contrasts) problem.contrastBackgroundParams = contrast_background_params problem.contrastBackgroundTypes = contrast_background_types problem.contrastBackgroundActions = [contrast.background_action for contrast in project.contrasts] diff --git a/RATapi/outputs.py b/RATapi/outputs.py index 150ebc2d..925db7c5 100644 --- a/RATapi/outputs.py +++ b/RATapi/outputs.py @@ -409,7 +409,7 @@ class BayesResults(Results): def make_results( procedure: Procedures, output_results: RATapi.rat_core.OutputResult, - bayes_results: Optional[RATapi.rat_core.BayesResults] = None, + bayes_results: Optional[RATapi.rat_core.OutputBayesResult] = None, ) -> Union[Results, BayesResults]: """Initialise a python Results or BayesResults object using the outputs from a RAT calculation. @@ -419,7 +419,7 @@ def make_results( The procedure used by the calculation. output_results : RATapi.rat_core.OutputResult The C++ output results from the calculation. - bayes_results : Optional[RATapi.rat_core.BayesResults] + bayes_results : Optional[RATapi.rat_core.OutputBayesResult] The optional extra C++ Bayesian output results from a Bayesian calculation. Returns diff --git a/RATapi/utils/plotting.py b/RATapi/utils/plotting.py index 19596198..f9abcee5 100644 --- a/RATapi/utils/plotting.py +++ b/RATapi/utils/plotting.py @@ -17,7 +17,7 @@ import RATapi import RATapi.inputs import RATapi.outputs -from RATapi.rat_core import PlotEventData, makeSLDProfileXY +from RATapi.rat_core import PlotEventData, makeSLDProfile def plot_errorbars(ax: Axes, x: np.ndarray, y: np.ndarray, err: np.ndarray, one_sided: bool, color: str): @@ -154,11 +154,11 @@ def plot_ref_sld_helper( layer = data.resampledLayers[i][j] if layers.shape[1] == 4: layer = np.delete(layer, 2, 1) - new_profile = makeSLDProfileXY( + new_profile = makeSLDProfile( layers[0, 1], # Bulk In layers[-1, 1], # Bulk Out - data.subRoughs[i], # roughness layer, + data.subRoughs[i], # roughness 1, ) diff --git a/cpp/RAT b/cpp/RAT index df626113..589c9871 160000 --- a/cpp/RAT +++ b/cpp/RAT @@ -1 +1 @@ -Subproject commit df626113d7a930cfa23c1ab47fdf9b1111b52123 +Subproject commit 589c987180f33f1e265537044a6497ef51f4ef09 diff --git a/cpp/rat.cpp b/cpp/rat.cpp index e699ad11..3335e09a 100644 --- a/cpp/rat.cpp +++ b/cpp/rat.cpp @@ -16,7 +16,7 @@ setup_pybind11(cfg) #include "RAT/RATMain_initialize.h" #include "RAT/RATMain_terminate.h" #include "RAT/RATMain_types.h" -#include "RAT/makeSLDProfileXY.h" +#include "RAT/makeSLDProfile.h" #include "RAT/dylib.hpp" #include "RAT/events/eventManager.h" #include "includes/defines.h" @@ -263,7 +263,7 @@ RAT::b_ProblemDefinition createProblemDefinitionStruct(const ProblemDefinition& problem_struct.numberOfContrasts = problem.numberOfContrasts; stringToRatBoundedArray(problem.geometry, problem_struct.geometry.data, problem_struct.geometry.size); problem_struct.useImaginary = problem.useImaginary; - problem_struct.repeatLayers = customCaller("Problem.repeatLayers", pyListToRatCellWrap2, problem.repeatLayers); + problem_struct.repeatLayers = customCaller("Problem.repeatLayers", pyArrayToRatRowArray1d, problem.repeatLayers); problem_struct.contrastBackgroundParams = customCaller("Problem.contrastBackgroundParams", pyListToRatCellWrap3, problem.contrastBackgroundParams); problem_struct.contrastBackgroundTypes = customCaller("Problem.contrastBackgroundTypes", pyListToRatCellWrap02d, problem.contrastBackgroundTypes); problem_struct.contrastBackgroundActions = customCaller("Problem.contrastBackgroundActions", pyListToRatCellWrap02d, problem.contrastBackgroundActions); @@ -460,7 +460,7 @@ ProblemDefinition problemDefinitionFromStruct(const RAT::b_ProblemDefinition pro problem_def.numberOfContrasts = problem.numberOfContrasts; stringFromRatBoundedArray(problem.geometry.data, problem.geometry.size, problem_def.geometry); problem_def.useImaginary = problem.useImaginary; - problem_def.repeatLayers = pyListFromRatCellWrap2(problem.repeatLayers); + problem_def.repeatLayers = pyArrayFromRatArray1d>(problem.repeatLayers); problem_def.contrastBackgroundParams = pyListFromBoundedCellWrap>(problem.contrastBackgroundParams); problem_def.contrastBackgroundTypes = pyListFromRatCellWrap02d(problem.contrastBackgroundTypes); problem_def.contrastBackgroundActions = pyListFromRatCellWrap02d(problem.contrastBackgroundActions); @@ -596,7 +596,7 @@ py::tuple RATMain(const ProblemDefinition& problem_def, const Control& control) OutputBayesResultsFromStruct(bayesResults)); } -const std::string docsMakeSLDProfileXY = R"(Creates the profiles for the SLD plots +const std::string docsMakeSLDProfile = R"(Creates the profiles for the SLD plots Parameters ---------- @@ -604,10 +604,10 @@ bulk_in : float Bulk in value for contrast. bulk_out : float Bulk out value for contrast. -ssub : float - Substrate roughness. layers : np.ndarray[np.float] Array of parameters for each layer in the contrast. +ssub : float + Substrate roughness. number_of_repeats : int, default: 1 Number of times the layers are repeated. @@ -617,22 +617,20 @@ sld_profile : np.ndarray[np.float] Computed SLD profile )"; -py::array_t makeSLDProfileXY(real_T bulk_in, - real_T bulk_out, - real_T ssub, - const py::array_t &layers, - int number_of_repeats=DEFAULT_NREPEATS) +py::array_t makeSLDProfile(real_T bulk_in, + real_T bulk_out, + const py::array_t &layers, + real_T ssub, + int number_of_repeats=DEFAULT_NREPEATS) { coder::array out; coder::array layers_array = pyArrayToRatArray2d(layers); - py::buffer_info buffer_info = layers.request(); - RAT::makeSLDProfileXY(bulk_in, - bulk_out, - ssub, - layers_array, - buffer_info.shape[0], - number_of_repeats, - out); + RAT::makeSLDProfile(bulk_in, + bulk_out, + layers_array, + ssub, + number_of_repeats, + out); return pyArrayFromRatArray2d(out); @@ -1047,7 +1045,7 @@ PYBIND11_MODULE(rat_core, m) { p.numberOfContrasts = t[6].cast(); p.geometry = t[7].cast(); p.useImaginary = t[8].cast(); - p.repeatLayers = t[9].cast(); + p.repeatLayers = t[9].cast>(); p.contrastBackgroundParams = t[10].cast(); p.contrastBackgroundTypes = t[11].cast(); p.contrastBackgroundActions = t[12].cast(); @@ -1099,6 +1097,6 @@ PYBIND11_MODULE(rat_core, m) { m.def("RATMain", &RATMain, docsRATMain.c_str(), py::arg("problem_def"), py::arg("control")); - m.def("makeSLDProfileXY", &makeSLDProfileXY, docsMakeSLDProfileXY.c_str(), - py::arg("bulk_in"), py::arg("bulk_out"), py::arg("ssub"), py::arg("layers"), py::arg("number_of_repeats") = DEFAULT_NREPEATS); + m.def("makeSLDProfile", &makeSLDProfile, docsMakeSLDProfile.c_str(), + py::arg("bulk_in"), py::arg("bulk_out"), py::arg("layers"), py::arg("ssub"), py::arg("number_of_repeats") = DEFAULT_NREPEATS); } diff --git a/tests/conftest.py b/tests/conftest.py index 50fbc11c..c109c92d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2253,7 +2253,7 @@ def dream_bayes(): This optimisation used the parameters: nSamples=1, nChains=1. """ - bayes = RATapi.rat_core.BayesResults() + bayes = RATapi.rat_core.OutputBayesResult() bayes.predictionIntervals = RATapi.rat_core.PredictionIntervals() bayes.predictionIntervals.reflectivity = [ np.array( diff --git a/tests/test_inputs.py b/tests/test_inputs.py index 2874a888..e7efd7b4 100644 --- a/tests/test_inputs.py +++ b/tests/test_inputs.py @@ -174,7 +174,7 @@ def standard_layers_problem(test_names, test_checks): problem.simulationLimits = [[1.0, 1.0]] problem.numberOfContrasts = 1 problem.numberOfLayers = 1 - problem.repeatLayers = [[0, 1]] + problem.repeatLayers = [1] problem.layersDetails = [[2, 3, 4, float("NaN"), 2]] problem.contrastLayers = [[1]] problem.numberOfDomainContrasts = 0 @@ -242,7 +242,7 @@ def domains_problem(test_names, test_checks): problem.simulationLimits = [[1.0, 1.0]] problem.numberOfContrasts = 1 problem.numberOfLayers = 1 - problem.repeatLayers = [[0, 1]] + problem.repeatLayers = [1] problem.layersDetails = [[2, 3, 4, float("NaN"), 2]] problem.contrastLayers = [[2, 1]] problem.numberOfDomainContrasts = 2 @@ -311,7 +311,7 @@ def custom_xy_problem(test_names, test_checks): problem.data = [np.empty([0, 6])] problem.dataLimits = [[0.0, 0.0]] problem.simulationLimits = [[0.005, 0.7]] - problem.repeatLayers = [[0, 1]] + problem.repeatLayers = [1] problem.layersDetails = [] problem.contrastLayers = [[]] problem.numberOfContrasts = 1 diff --git a/tests/test_plotting.py b/tests/test_plotting.py index 78ddd08c..d907ba16 100644 --- a/tests/test_plotting.py +++ b/tests/test_plotting.py @@ -140,9 +140,9 @@ def test_ref_sld_bayes(fig, bayes_fig, bayes): assert any(isinstance(comp, PolyCollection) for comp in components) -@patch("RATapi.utils.plotting.makeSLDProfileXY") +@patch("RATapi.utils.plotting.makeSLDProfile") def test_sld_profile_function_call(mock: MagicMock) -> None: - """Tests the makeSLDProfileXY function called with + """Tests the makeSLDProfile function called with correct args. """ RATplot.plot_ref_sld_helper(data()) @@ -150,21 +150,21 @@ def test_sld_profile_function_call(mock: MagicMock) -> None: assert mock.call_count == 3 assert mock.call_args_list[0].args[0] == 2.07e-06 assert mock.call_args_list[0].args[1] == 6.28e-06 - assert mock.call_args_list[0].args[2] == 0.0 + assert mock.call_args_list[0].args[3] == 0.0 assert mock.call_args_list[0].args[4] == 1 assert mock.call_args_list[1].args[0] == 2.07e-06 assert mock.call_args_list[1].args[1] == 1.83e-06 - assert mock.call_args_list[1].args[2] == 0.0 + assert mock.call_args_list[1].args[3] == 0.0 assert mock.call_args_list[1].args[4] == 1 assert mock.call_args_list[2].args[0] == 2.07e-06 assert mock.call_args_list[2].args[1] == -5.87e-07 - assert mock.call_args_list[2].args[2] == 0.0 + assert mock.call_args_list[2].args[3] == 0.0 assert mock.call_args_list[2].args[4] == 1 -@patch("RATapi.utils.plotting.makeSLDProfileXY") +@patch("RATapi.utils.plotting.makeSLDProfile") def test_live_plot(mock: MagicMock) -> None: plot_data = data() @@ -177,17 +177,17 @@ def test_live_plot(mock: MagicMock) -> None: assert mock.call_count == 3 assert mock.call_args_list[0].args[0] == 2.07e-06 assert mock.call_args_list[0].args[1] == 6.28e-06 - assert mock.call_args_list[0].args[2] == 0.0 + assert mock.call_args_list[0].args[3] == 0.0 assert mock.call_args_list[0].args[4] == 1 assert mock.call_args_list[1].args[0] == 2.07e-06 assert mock.call_args_list[1].args[1] == 1.83e-06 - assert mock.call_args_list[1].args[2] == 0.0 + assert mock.call_args_list[1].args[3] == 0.0 assert mock.call_args_list[1].args[4] == 1 assert mock.call_args_list[2].args[0] == 2.07e-06 assert mock.call_args_list[2].args[1] == -5.87e-07 - assert mock.call_args_list[2].args[2] == 0.0 + assert mock.call_args_list[2].args[3] == 0.0 assert mock.call_args_list[2].args[4] == 1 diff --git a/tests/test_run.py b/tests/test_run.py index f488de4a..a3242d45 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -76,7 +76,7 @@ def reflectivity_calculation_problem(): problem.simulationLimits = [[0.011403, 0.59342], [0.011403, 0.59342]] problem.numberOfContrasts = 2.0 problem.numberOfLayers = 6.0 - problem.repeatLayers = [[0.0, 1.0], [0.0, 1.0]] + problem.repeatLayers = [1.0, 1.0] problem.layersDetails = [ np.array([2.0]), np.array([4.0]), @@ -237,7 +237,7 @@ def dream_problem(): problem.simulationLimits = [[0.011403, 0.59342], [0.011403, 0.59342]] problem.numberOfContrasts = 2.0 problem.numberOfLayers = 6.0 - problem.repeatLayers = [[0.0, 1.0], [0.0, 1.0]] + problem.repeatLayers = [1.0, 1.0] problem.layersDetails = [ np.array([2.0]), np.array([4.0]), From 0354a537e7eab5d7b3d54da6241a79fda6bb1d90 Mon Sep 17 00:00:00 2001 From: Paul Sharp <44529197+DrPaulSharp@users.noreply.github.com> Date: Wed, 16 Apr 2025 16:24:17 +0100 Subject: [PATCH 3/4] Fixes matlab import error --- RATapi/utils/convert.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RATapi/utils/convert.py b/RATapi/utils/convert.py index 35bc216b..250b591e 100644 --- a/RATapi/utils/convert.py +++ b/RATapi/utils/convert.py @@ -549,9 +549,10 @@ def convert_parameters( # scipy.io.savemat doesn't do cells properly: # https://github.com/scipy/scipy/issues/3756 # rather than fiddling we just use matlab - eng = wrappers.start_matlab().result() + eng = wrappers.start_matlab() if eng is None: raise ImportError("matlabengine is not installed.") + eng = eng.result() eng.workspace["problem"] = r1 eng.save(str(filename), "problem", nargout=0) eng.exit() From 25f115c1520c069722776403a61b9466a4b89c6f Mon Sep 17 00:00:00 2001 From: Paul Sharp <44529197+DrPaulSharp@users.noreply.github.com> Date: Wed, 16 Apr 2025 18:21:09 +0100 Subject: [PATCH 4/4] Refactors matlab save in "project_to_r1" --- .../convert_rascal_project/convert_rascal.py | 6 +++--- RATapi/utils/convert.py | 11 +++++------ tests/test_convert.py | 16 ++++++++-------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/RATapi/examples/convert_rascal_project/convert_rascal.py b/RATapi/examples/convert_rascal_project/convert_rascal.py index b0b945f7..2a41b61f 100644 --- a/RATapi/examples/convert_rascal_project/convert_rascal.py +++ b/RATapi/examples/convert_rascal_project/convert_rascal.py @@ -26,7 +26,7 @@ def convert_rascal(mat_filename="lipid_bilayer.mat"): """ project_path = pathlib.Path(__file__).parent / "R1monolayerVolumeModel.mat" - project = RAT.utils.convert.r1_to_project_class(project_path) + project = RAT.utils.convert.r1_to_project(project_path) # change values if you like, including ones not supported by R1 project.parameters["Head Thickness"].prior_type = "gaussian" @@ -35,10 +35,10 @@ def convert_rascal(mat_filename="lipid_bilayer.mat"): # convert DSPC standard layers example to a struct and save as file lipid_bilayer_project = RAT.examples.DSPC_standard_layers()[0] - RAT.utils.convert.project_class_to_r1(lipid_bilayer_project, filename=mat_filename) + RAT.utils.convert.project_to_r1(lipid_bilayer_project, filename=mat_filename) # convert and return as a Python dictionary - struct = RAT.utils.convert.project_class_to_r1(lipid_bilayer_project, return_struct=True) + struct = RAT.utils.convert.project_to_r1(lipid_bilayer_project, return_struct=True) return project, struct diff --git a/RATapi/utils/convert.py b/RATapi/utils/convert.py index 250b591e..7c94ab50 100644 --- a/RATapi/utils/convert.py +++ b/RATapi/utils/convert.py @@ -15,7 +15,7 @@ from RATapi.utils.enums import Geometries, Languages, LayerModels -def r1_to_project_class(filename: Union[str, PathLike]) -> Project: +def r1_to_project(filename: Union[str, PathLike]) -> Project: """Read a RasCAL1 project struct as a Python `Project`. Parameters @@ -318,7 +318,7 @@ def fix_invalid_constraints(name: str, constrs: tuple[float, float], value: floa return project -def project_class_to_r1( +def project_to_r1( project: Project, filename: Union[str, PathLike] = "RAT_project", return_struct: bool = False ) -> Union[dict, None]: """Convert a RAT Project to a RasCAL1 project struct. @@ -549,11 +549,10 @@ def convert_parameters( # scipy.io.savemat doesn't do cells properly: # https://github.com/scipy/scipy/issues/3756 # rather than fiddling we just use matlab - eng = wrappers.start_matlab() - if eng is None: + loader = wrappers.MatlabWrapper.loader + if loader is None: raise ImportError("matlabengine is not installed.") - eng = eng.result() + eng = loader.result() eng.workspace["problem"] = r1 eng.save(str(filename), "problem", nargout=0) - eng.exit() return None diff --git a/tests/test_convert.py b/tests/test_convert.py index e636fc9a..8dc3ecdb 100644 --- a/tests/test_convert.py +++ b/tests/test_convert.py @@ -8,7 +8,7 @@ import pytest import RATapi -from RATapi.utils.convert import project_class_to_r1, r1_to_project_class +from RATapi.utils.convert import project_to_r1, r1_to_project TEST_DIR_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "test_data") @@ -58,9 +58,9 @@ def dspc_bilayer(): ], ) @pytest.mark.parametrize("path_type", [os.path.join, pathlib.Path]) -def test_r1_to_project_class(file, project, path_type, request): +def test_r1_to_project(file, project, path_type, request): """Test that R1 to Project class conversion returns the expected Project.""" - output_project = r1_to_project_class(path_type(TEST_DIR_PATH, file)) + output_project = r1_to_project(path_type(TEST_DIR_PATH, file)) expected_project = request.getfixturevalue(project) # assert statements have to be more careful due to R1 missing features @@ -83,7 +83,7 @@ def test_r1_to_project_class(file, project, path_type, request): def test_r1_involution(project, request, monkeypatch): """Test that converting a Project to an R1 struct and back returns the same project.""" original_project = request.getfixturevalue(project) - r1_struct = project_class_to_r1(original_project, return_struct=True) + r1_struct = project_to_r1(original_project, return_struct=True) # rather than writing the struct to a file and reading the file, just directly # hand the struct over @@ -93,7 +93,7 @@ def mock_load(ignored_filename, **ignored_settings): monkeypatch.setattr("RATapi.utils.convert.loadmat", mock_load, raising=True) - converted_project = r1_to_project_class(project) + converted_project = r1_to_project(project) for class_list in RATapi.project.class_lists: assert getattr(converted_project, class_list) == getattr(original_project, class_list) @@ -105,7 +105,7 @@ def test_invalid_constraints(): match=r"The parameter (.+) has invalid constraints," " these have been adjusted to satisfy the current value of the parameter." ): - output_project = r1_to_project_class(pathlib.Path(TEST_DIR_PATH, "R1DoubleBilayerVolumeModel.mat")) + output_project = r1_to_project(pathlib.Path(TEST_DIR_PATH, "R1DoubleBilayerVolumeModel.mat")) assert output_project.background_parameters[0].min == output_project.background_parameters[0].value @@ -117,7 +117,7 @@ def test_matlab_save(path_type, request): project = request.getfixturevalue("r1_default_project") with tempfile.TemporaryDirectory() as temp: matfile = path_type(temp, "testfile.mat") - project_class_to_r1(project, filename=matfile) - converted_project = r1_to_project_class(matfile) + project_to_r1(project, filename=matfile) + converted_project = r1_to_project(matfile) assert project == converted_project