Skip to content

Commit 8193877

Browse files
committed
Removes limits struct from input to RAT
1 parent 5a26412 commit 8193877

File tree

4 files changed

+9
-71
lines changed

4 files changed

+9
-71
lines changed
34 KB
Binary file not shown.

RATapi/inputs.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import RATapi
1111
import RATapi.controls
1212
import RATapi.wrappers
13-
from RATapi.rat_core import Checks, Control, Limits, NameStore, ProblemDefinition
13+
from RATapi.rat_core import Checks, Control, NameStore, ProblemDefinition
1414
from RATapi.utils.enums import Calculations, Languages, LayerModels, TypeOptions
1515

1616
parameter_field = {
@@ -113,7 +113,7 @@ def __len__(self):
113113
return len(self.files)
114114

115115

116-
def make_input(project: RATapi.Project, controls: RATapi.Controls) -> tuple[ProblemDefinition, Limits, Control]:
116+
def make_input(project: RATapi.Project, controls: RATapi.Controls) -> tuple[ProblemDefinition, Control]:
117117
"""Construct the inputs required for the compiled RAT code using the data defined in the input project and controls.
118118
119119
Parameters
@@ -127,28 +127,14 @@ def make_input(project: RATapi.Project, controls: RATapi.Controls) -> tuple[Prob
127127
-------
128128
problem : RAT.rat_core.ProblemDefinition
129129
The problem input used in the compiled RAT code.
130-
limits : RAT.rat_core.Limits
131-
A list of min/max values for each parameter defined in the project.
132130
cpp_controls : RAT.rat_core.Control
133131
The controls object used in the compiled RAT code.
134132
135133
"""
136-
limits = Limits()
137-
138-
for class_list in RATapi.project.parameter_class_lists:
139-
setattr(
140-
limits,
141-
parameter_field[class_list],
142-
[[element.min, element.max] for element in getattr(project, class_list)],
143-
)
144-
145-
if project.model == LayerModels.CustomXY:
146-
controls.calcSldDuringFit = True
147-
148134
problem = make_problem(project)
149135
cpp_controls = make_controls(controls)
150136

151-
return problem, limits, cpp_controls
137+
return problem, cpp_controls
152138

153139

154140
def make_problem(project: RATapi.Project) -> ProblemDefinition:

RATapi/run.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def run(project, controls):
109109

110110
horizontal_line = "\u2500" * 107 + "\n"
111111
display_on = controls.display != Display.Off
112-
problem_definition, limits, cpp_controls = make_input(project, controls)
112+
problem_definition, cpp_controls = make_input(project, controls)
113113

114114
if display_on:
115115
print("Starting RAT " + horizontal_line)
@@ -118,7 +118,6 @@ def run(project, controls):
118118
with ProgressBar(display=display_on), TextOutput(display=display_on):
119119
problem_definition, output_results, bayes_results = RATapi.rat_core.RATMain(
120120
problem_definition,
121-
limits,
122121
cpp_controls,
123122
)
124123
end = time.time()

tests/test_inputs.py

Lines changed: 5 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import RATapi
1010
import RATapi.wrappers
1111
from RATapi.inputs import FileHandles, check_indices, make_controls, make_input, make_problem
12-
from RATapi.rat_core import Checks, Control, Limits, NameStore, ProblemDefinition
12+
from RATapi.rat_core import Checks, Control, NameStore, ProblemDefinition
1313
from RATapi.utils.enums import (
1414
BackgroundActions,
1515
BoundHandling,
@@ -351,36 +351,6 @@ def custom_xy_problem(test_names, test_checks):
351351
return problem
352352

353353

354-
@pytest.fixture
355-
def normal_limits():
356-
"""The expected limits object from "standard_layers_project" and "custom_xy_project"."""
357-
limits = Limits()
358-
limits.params = [[1.0, 5.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]
359-
limits.backgroundParams = [[1e-7, 1e-5]]
360-
limits.scalefactors = [[0.02, 0.25]]
361-
limits.bulkIns = [[0.0, 0.0]]
362-
limits.bulkOuts = [[6.2e-6, 6.35e-6]]
363-
limits.resolutionParams = [[0.01, 0.05]]
364-
limits.domainRatios = []
365-
366-
return limits
367-
368-
369-
@pytest.fixture
370-
def domains_limits():
371-
"""The expected limits object from "domains_project"."""
372-
limits = Limits()
373-
limits.params = [[1.0, 5.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0]]
374-
limits.backgroundParams = [[1e-7, 1e-5]]
375-
limits.scalefactors = [[0.02, 0.25]]
376-
limits.bulkIns = [[0.0, 0.0]]
377-
limits.bulkOuts = [[6.2e-6, 6.35e-6]]
378-
limits.resolutionParams = [[0.01, 0.05]]
379-
limits.domainRatios = [[0.4, 0.6]]
380-
381-
return limits
382-
383-
384354
@pytest.fixture
385355
def standard_layers_controls():
386356
"""The expected controls object for input to the compiled RAT code given the default inputs and
@@ -458,55 +428,38 @@ def custom_xy_controls():
458428

459429

460430
@pytest.mark.parametrize(
461-
["test_project", "test_problem", "test_limits", "test_controls"],
431+
["test_project", "test_problem", "test_controls"],
462432
[
463433
(
464434
"standard_layers_project",
465435
"standard_layers_problem",
466-
"normal_limits",
467436
"standard_layers_controls",
468437
),
469438
(
470439
"custom_xy_project",
471440
"custom_xy_problem",
472-
"normal_limits",
473441
"custom_xy_controls",
474442
),
475443
(
476444
"domains_project",
477445
"domains_problem",
478-
"domains_limits",
479446
"standard_layers_controls",
480447
),
481448
],
482449
)
483-
def test_make_input(test_project, test_problem, test_limits, test_controls, request) -> None:
484-
"""When converting the "project" and "controls", we should obtain the five input objects required for the compiled
450+
def test_make_input(test_project, test_problem, test_controls, request) -> None:
451+
"""When converting the "project" and "controls", we should obtain the two input objects required for the compiled
485452
RAT code.
486453
"""
487454
test_project = request.getfixturevalue(test_project)
488455
test_problem = request.getfixturevalue(test_problem)
489-
test_limits = request.getfixturevalue(test_limits)
490456
test_controls = request.getfixturevalue(test_controls)
491457

492-
parameter_fields = [
493-
"params",
494-
"backgroundParams",
495-
"scalefactors",
496-
"bulkIns",
497-
"bulkOuts",
498-
"resolutionParams",
499-
"domainRatios",
500-
]
458+
problem, controls = make_input(test_project, RATapi.Controls())
501459

502-
problem, limits, controls = make_input(test_project, RATapi.Controls())
503460
problem = pickle.loads(pickle.dumps(problem))
504461
check_problem_equal(problem, test_problem)
505462

506-
limits = pickle.loads(pickle.dumps(limits))
507-
for limit_field in parameter_fields:
508-
assert np.all(getattr(limits, limit_field) == getattr(test_limits, limit_field))
509-
510463
controls = pickle.loads(pickle.dumps(controls))
511464
check_controls_equal(controls, test_controls)
512465

0 commit comments

Comments
 (0)