Skip to content

Commit 34516e5

Browse files
committed
Updates submodule
1 parent 4b475f6 commit 34516e5

File tree

9 files changed

+42
-44
lines changed

9 files changed

+42
-44
lines changed

RATapi/inputs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def make_problem(project: RATapi.Project) -> ProblemDefinition:
284284
problem.numberOfContrasts = len(project.contrasts)
285285
problem.geometry = project.geometry
286286
problem.useImaginary = project.absorption
287-
problem.repeatLayers = [[0, 1]] * len(project.contrasts) # This is marked as "to do" in RAT
287+
problem.repeatLayers = [1] * len(project.contrasts)
288288
problem.contrastBackgroundParams = contrast_background_params
289289
problem.contrastBackgroundTypes = contrast_background_types
290290
problem.contrastBackgroundActions = [contrast.background_action for contrast in project.contrasts]

RATapi/outputs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ class BayesResults(Results):
409409
def make_results(
410410
procedure: Procedures,
411411
output_results: RATapi.rat_core.OutputResult,
412-
bayes_results: Optional[RATapi.rat_core.BayesResults] = None,
412+
bayes_results: Optional[RATapi.rat_core.OutputBayesResult] = None,
413413
) -> Union[Results, BayesResults]:
414414
"""Initialise a python Results or BayesResults object using the outputs from a RAT calculation.
415415
@@ -419,7 +419,7 @@ def make_results(
419419
The procedure used by the calculation.
420420
output_results : RATapi.rat_core.OutputResult
421421
The C++ output results from the calculation.
422-
bayes_results : Optional[RATapi.rat_core.BayesResults]
422+
bayes_results : Optional[RATapi.rat_core.OutputBayesResult]
423423
The optional extra C++ Bayesian output results from a Bayesian calculation.
424424
425425
Returns

RATapi/utils/plotting.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import RATapi
1818
import RATapi.inputs
1919
import RATapi.outputs
20-
from RATapi.rat_core import PlotEventData, makeSLDProfileXY
20+
from RATapi.rat_core import PlotEventData, makeSLDProfile
2121

2222

2323
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(
154154
layer = data.resampledLayers[i][j]
155155
if layers.shape[1] == 4:
156156
layer = np.delete(layer, 2, 1)
157-
new_profile = makeSLDProfileXY(
157+
new_profile = makeSLDProfile(
158158
layers[0, 1], # Bulk In
159159
layers[-1, 1], # Bulk Out
160-
data.subRoughs[i], # roughness
161160
layer,
161+
data.subRoughs[i], # roughness
162162
1,
163163
)
164164

cpp/rat.cpp

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ setup_pybind11(cfg)
1616
#include "RAT/RATMain_initialize.h"
1717
#include "RAT/RATMain_terminate.h"
1818
#include "RAT/RATMain_types.h"
19-
#include "RAT/makeSLDProfileXY.h"
19+
#include "RAT/makeSLDProfile.h"
2020
#include "RAT/dylib.hpp"
2121
#include "RAT/events/eventManager.h"
2222
#include "includes/defines.h"
@@ -263,7 +263,7 @@ RAT::b_ProblemDefinition createProblemDefinitionStruct(const ProblemDefinition&
263263
problem_struct.numberOfContrasts = problem.numberOfContrasts;
264264
stringToRatBoundedArray(problem.geometry, problem_struct.geometry.data, problem_struct.geometry.size);
265265
problem_struct.useImaginary = problem.useImaginary;
266-
problem_struct.repeatLayers = customCaller("Problem.repeatLayers", pyListToRatCellWrap2, problem.repeatLayers);
266+
problem_struct.repeatLayers = customCaller("Problem.repeatLayers", pyArrayToRatRowArray1d, problem.repeatLayers);
267267
problem_struct.contrastBackgroundParams = customCaller("Problem.contrastBackgroundParams", pyListToRatCellWrap3, problem.contrastBackgroundParams);
268268
problem_struct.contrastBackgroundTypes = customCaller("Problem.contrastBackgroundTypes", pyListToRatCellWrap02d, problem.contrastBackgroundTypes);
269269
problem_struct.contrastBackgroundActions = customCaller("Problem.contrastBackgroundActions", pyListToRatCellWrap02d, problem.contrastBackgroundActions);
@@ -460,7 +460,7 @@ ProblemDefinition problemDefinitionFromStruct(const RAT::b_ProblemDefinition pro
460460
problem_def.numberOfContrasts = problem.numberOfContrasts;
461461
stringFromRatBoundedArray(problem.geometry.data, problem.geometry.size, problem_def.geometry);
462462
problem_def.useImaginary = problem.useImaginary;
463-
problem_def.repeatLayers = pyListFromRatCellWrap2(problem.repeatLayers);
463+
problem_def.repeatLayers = pyArrayFromRatArray1d<coder::array<real_T, 2U>>(problem.repeatLayers);
464464
problem_def.contrastBackgroundParams = pyListFromBoundedCellWrap<coder::array<RAT::cell_wrap_3, 2U>>(problem.contrastBackgroundParams);
465465
problem_def.contrastBackgroundTypes = pyListFromRatCellWrap02d(problem.contrastBackgroundTypes);
466466
problem_def.contrastBackgroundActions = pyListFromRatCellWrap02d(problem.contrastBackgroundActions);
@@ -596,18 +596,18 @@ py::tuple RATMain(const ProblemDefinition& problem_def, const Control& control)
596596
OutputBayesResultsFromStruct(bayesResults));
597597
}
598598

599-
const std::string docsMakeSLDProfileXY = R"(Creates the profiles for the SLD plots
599+
const std::string docsMakeSLDProfile = R"(Creates the profiles for the SLD plots
600600
601601
Parameters
602602
----------
603603
bulk_in : float
604604
Bulk in value for contrast.
605605
bulk_out : float
606606
Bulk out value for contrast.
607-
ssub : float
608-
Substrate roughness.
609607
layers : np.ndarray[np.float]
610608
Array of parameters for each layer in the contrast.
609+
ssub : float
610+
Substrate roughness.
611611
number_of_repeats : int, default: 1
612612
Number of times the layers are repeated.
613613
@@ -617,22 +617,20 @@ sld_profile : np.ndarray[np.float]
617617
Computed SLD profile
618618
)";
619619

620-
py::array_t<real_T> makeSLDProfileXY(real_T bulk_in,
621-
real_T bulk_out,
622-
real_T ssub,
623-
const py::array_t<real_T> &layers,
624-
int number_of_repeats=DEFAULT_NREPEATS)
620+
py::array_t<real_T> makeSLDProfile(real_T bulk_in,
621+
real_T bulk_out,
622+
const py::array_t<real_T> &layers,
623+
real_T ssub,
624+
int number_of_repeats=DEFAULT_NREPEATS)
625625
{
626626
coder::array<real_T, 2U> out;
627627
coder::array<real_T, 2U> layers_array = pyArrayToRatArray2d(layers);
628-
py::buffer_info buffer_info = layers.request();
629-
RAT::makeSLDProfileXY(bulk_in,
630-
bulk_out,
631-
ssub,
632-
layers_array,
633-
buffer_info.shape[0],
634-
number_of_repeats,
635-
out);
628+
RAT::makeSLDProfile(bulk_in,
629+
bulk_out,
630+
layers_array,
631+
ssub,
632+
number_of_repeats,
633+
out);
636634

637635
return pyArrayFromRatArray2d(out);
638636

@@ -1047,7 +1045,7 @@ PYBIND11_MODULE(rat_core, m) {
10471045
p.numberOfContrasts = t[6].cast<real_T>();
10481046
p.geometry = t[7].cast<std::string>();
10491047
p.useImaginary = t[8].cast<bool>();
1050-
p.repeatLayers = t[9].cast<py::list>();
1048+
p.repeatLayers = t[9].cast<py::array_t<real_T>>();
10511049
p.contrastBackgroundParams = t[10].cast<py::list>();
10521050
p.contrastBackgroundTypes = t[11].cast<py::list>();
10531051
p.contrastBackgroundActions = t[12].cast<py::list>();
@@ -1099,6 +1097,6 @@ PYBIND11_MODULE(rat_core, m) {
10991097

11001098
m.def("RATMain", &RATMain, docsRATMain.c_str(), py::arg("problem_def"), py::arg("control"));
11011099

1102-
m.def("makeSLDProfileXY", &makeSLDProfileXY, docsMakeSLDProfileXY.c_str(),
1103-
py::arg("bulk_in"), py::arg("bulk_out"), py::arg("ssub"), py::arg("layers"), py::arg("number_of_repeats") = DEFAULT_NREPEATS);
1100+
m.def("makeSLDProfile", &makeSLDProfile, docsMakeSLDProfile.c_str(),
1101+
py::arg("bulk_in"), py::arg("bulk_out"), py::arg("layers"), py::arg("ssub"), py::arg("number_of_repeats") = DEFAULT_NREPEATS);
11041102
}

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2253,7 +2253,7 @@ def dream_bayes():
22532253
22542254
This optimisation used the parameters: nSamples=1, nChains=1.
22552255
"""
2256-
bayes = RATapi.rat_core.BayesResults()
2256+
bayes = RATapi.rat_core.OutputBayesResult()
22572257
bayes.predictionIntervals = RATapi.rat_core.PredictionIntervals()
22582258
bayes.predictionIntervals.reflectivity = [
22592259
np.array(

tests/test_inputs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def standard_layers_problem(test_names, test_checks):
174174
problem.simulationLimits = [[1.0, 1.0]]
175175
problem.numberOfContrasts = 1
176176
problem.numberOfLayers = 1
177-
problem.repeatLayers = [[0, 1]]
177+
problem.repeatLayers = [1]
178178
problem.layersDetails = [[2, 3, 4, float("NaN"), 2]]
179179
problem.contrastLayers = [[1]]
180180
problem.numberOfDomainContrasts = 0
@@ -242,7 +242,7 @@ def domains_problem(test_names, test_checks):
242242
problem.simulationLimits = [[1.0, 1.0]]
243243
problem.numberOfContrasts = 1
244244
problem.numberOfLayers = 1
245-
problem.repeatLayers = [[0, 1]]
245+
problem.repeatLayers = [1]
246246
problem.layersDetails = [[2, 3, 4, float("NaN"), 2]]
247247
problem.contrastLayers = [[2, 1]]
248248
problem.numberOfDomainContrasts = 2
@@ -311,7 +311,7 @@ def custom_xy_problem(test_names, test_checks):
311311
problem.data = [np.empty([0, 6])]
312312
problem.dataLimits = [[0.0, 0.0]]
313313
problem.simulationLimits = [[0.005, 0.7]]
314-
problem.repeatLayers = [[0, 1]]
314+
problem.repeatLayers = [1]
315315
problem.layersDetails = []
316316
problem.contrastLayers = [[]]
317317
problem.numberOfContrasts = 1

tests/test_plotting.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,31 +140,31 @@ def test_ref_sld_bayes(fig, bayes_fig, bayes):
140140
assert any(isinstance(comp, PolyCollection) for comp in components)
141141

142142

143-
@patch("RATapi.utils.plotting.makeSLDProfileXY")
143+
@patch("RATapi.utils.plotting.makeSLDProfile")
144144
def test_sld_profile_function_call(mock: MagicMock) -> None:
145-
"""Tests the makeSLDProfileXY function called with
145+
"""Tests the makeSLDProfile function called with
146146
correct args.
147147
"""
148148
RATplot.plot_ref_sld_helper(data())
149149

150150
assert mock.call_count == 3
151151
assert mock.call_args_list[0].args[0] == 2.07e-06
152152
assert mock.call_args_list[0].args[1] == 6.28e-06
153-
assert mock.call_args_list[0].args[2] == 0.0
153+
assert mock.call_args_list[0].args[3] == 0.0
154154
assert mock.call_args_list[0].args[4] == 1
155155

156156
assert mock.call_args_list[1].args[0] == 2.07e-06
157157
assert mock.call_args_list[1].args[1] == 1.83e-06
158-
assert mock.call_args_list[1].args[2] == 0.0
158+
assert mock.call_args_list[1].args[3] == 0.0
159159
assert mock.call_args_list[1].args[4] == 1
160160

161161
assert mock.call_args_list[2].args[0] == 2.07e-06
162162
assert mock.call_args_list[2].args[1] == -5.87e-07
163-
assert mock.call_args_list[2].args[2] == 0.0
163+
assert mock.call_args_list[2].args[3] == 0.0
164164
assert mock.call_args_list[2].args[4] == 1
165165

166166

167-
@patch("RATapi.utils.plotting.makeSLDProfileXY")
167+
@patch("RATapi.utils.plotting.makeSLDProfile")
168168
def test_live_plot(mock: MagicMock) -> None:
169169
plot_data = data()
170170

@@ -177,17 +177,17 @@ def test_live_plot(mock: MagicMock) -> None:
177177
assert mock.call_count == 3
178178
assert mock.call_args_list[0].args[0] == 2.07e-06
179179
assert mock.call_args_list[0].args[1] == 6.28e-06
180-
assert mock.call_args_list[0].args[2] == 0.0
180+
assert mock.call_args_list[0].args[3] == 0.0
181181
assert mock.call_args_list[0].args[4] == 1
182182

183183
assert mock.call_args_list[1].args[0] == 2.07e-06
184184
assert mock.call_args_list[1].args[1] == 1.83e-06
185-
assert mock.call_args_list[1].args[2] == 0.0
185+
assert mock.call_args_list[1].args[3] == 0.0
186186
assert mock.call_args_list[1].args[4] == 1
187187

188188
assert mock.call_args_list[2].args[0] == 2.07e-06
189189
assert mock.call_args_list[2].args[1] == -5.87e-07
190-
assert mock.call_args_list[2].args[2] == 0.0
190+
assert mock.call_args_list[2].args[3] == 0.0
191191
assert mock.call_args_list[2].args[4] == 1
192192

193193

tests/test_run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def reflectivity_calculation_problem():
7676
problem.simulationLimits = [[0.011403, 0.59342], [0.011403, 0.59342]]
7777
problem.numberOfContrasts = 2.0
7878
problem.numberOfLayers = 6.0
79-
problem.repeatLayers = [[0.0, 1.0], [0.0, 1.0]]
79+
problem.repeatLayers = [1.0, 1.0]
8080
problem.layersDetails = [
8181
np.array([2.0]),
8282
np.array([4.0]),
@@ -237,7 +237,7 @@ def dream_problem():
237237
problem.simulationLimits = [[0.011403, 0.59342], [0.011403, 0.59342]]
238238
problem.numberOfContrasts = 2.0
239239
problem.numberOfLayers = 6.0
240-
problem.repeatLayers = [[0.0, 1.0], [0.0, 1.0]]
240+
problem.repeatLayers = [1.0, 1.0]
241241
problem.layersDetails = [
242242
np.array([2.0]),
243243
np.array([4.0]),

0 commit comments

Comments
 (0)