Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions tests/optimization/test_optimizable_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,17 @@ def test_hold_temp_must_be_divisible_by_50(self):
hold_time=5,
)

def test_ramp_rate_conversion(self):
"""Ramp rate is converted to sweep_step_size."""
def test_ramp_step_time_backward_compat(self):
"""Can still use ramp_step_time directly."""
recipe = OptimizableRecipe(
precursors={"BaO": 0.5},
hold_temp=1000,
hold_time=5,
ramp_rate=10.0, # 10 K/step
ramp_step_time=5,
)

# TEMP_STEP_SIZE = 50, so sweep_step_size = 50/10 = 5
assert recipe.ramp_rate == 10.0
assert recipe.sweep_step_size == 5

def test_sweep_step_size_backward_compat(self):
"""Can still use sweep_step_size directly."""
recipe = OptimizableRecipe(
precursors={"BaO": 0.5},
hold_temp=1000,
hold_time=5,
sweep_step_size=5,
)

# ramp_rate = 50/5 = 10
assert recipe.sweep_step_size == 5
assert recipe.ramp_rate == 10.0
# ramp_step_time = 5
assert recipe.ramp_step_time == 5

def test_to_recipe(self):
"""Can convert to ReactionRecipe."""
Expand Down Expand Up @@ -97,7 +83,7 @@ def test_from_params(self):
params = {
"hold_temp": 1000,
"hold_time": 5,
"ramp_rate": 10.0,
"ramp_step_time": 5,
"Ba_source_ratio": 0.5,
"Ti_source_ratio": 0.5,
}
Expand All @@ -115,7 +101,7 @@ def test_from_params(self):

assert recipe.hold_temp == 1000
assert recipe.hold_time == 5
assert recipe.ramp_rate == 10.0
assert recipe.ramp_step_time == 5
assert recipe.precursors["BaO"] == 0.5
assert recipe.precursors["TiO2"] == 0.5
assert recipe.simulation_size == 8
Expand All @@ -133,6 +119,7 @@ def test_from_params_defaults(self):

assert recipe.hold_temp == 1000
assert recipe.hold_time == 5 # Default from params.get
assert recipe.ramp_step_time == 1 # Default from params.get
assert recipe.precursors["BaO"] == 0.5 # Default ratio

def test_repr(self):
Expand Down
16 changes: 8 additions & 8 deletions tests/optimization/test_search_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ def test_add_hold_time_range(self):
assert len(ss.parameters) == 1
param = ss.parameters[0]
assert param.name == "hold_time"
assert isinstance(param, ContinuousParameter)
assert isinstance(param, DiscreteParameter)
assert param.low == 1
assert param.high == 10

def test_add_ramp_rate_range(self):
"""Ramp rate creates a continuous parameter."""
ss = SearchSpace().add_ramp_rate_range(5.0, 20.0)
def test_add_ramp_step_time_range(self):
"""Ramp step time creates a continuous parameter."""
ss = SearchSpace().add_ramp_step_time_range(5, 20)

assert len(ss.parameters) == 1
param = ss.parameters[0]
assert param.name == "ramp_rate"
assert isinstance(param, ContinuousParameter)
assert param.name == "ramp_step_time"
assert isinstance(param, DiscreteParameter)
assert param.low == 5.0
assert param.high == 20.0

Expand Down Expand Up @@ -82,7 +82,7 @@ def test_fluent_chaining(self):
SearchSpace()
.add_temperature_range(800, 1400, step=50)
.add_hold_time_range(1, 15)
.add_ramp_rate_range(5.0, 20.0)
.add_ramp_step_time_range(5, 20)
.add_precursor_slot("Ba_source", ["BaCO3", "BaO"])
.add_precursor_ratio("Ba_source", 0.4, 0.6)
)
Expand All @@ -91,7 +91,7 @@ def test_fluent_chaining(self):
param_names = [p.name for p in ss.parameters]
assert "hold_temp" in param_names
assert "hold_time" in param_names
assert "ramp_rate" in param_names
assert "ramp_step_time" in param_names
assert "Ba_source" in param_names
assert "Ba_source_ratio" in param_names

Expand Down