Skip to content
Merged
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
25 changes: 7 additions & 18 deletions crcsim/combine_tests.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import json
from enum import Enum, unique
from pathlib import Path

import fire


@unique
class TestCombiningMethod(str, Enum):
SERIAL = "serial"
PARALLEL = "parallel"
from crcsim.enums import TestCombiningMethod


def combine_tests_in_params(
Expand Down Expand Up @@ -62,7 +57,10 @@ def combine_tests_in_params(

# Combine cost and other fields
combined["cost"] = t1["cost"] + t2["cost"]
combined["proportion"] = 1.0 # Set to 1.0 to ensure it's selected
# By default, keep the assigned test proportions from the base params
# and do not assign the combined test to anyone. Edits to test proportions
# should be handled downstream in experiment logic.
combined["proportion"] = 0.0
combined["routine_start"] = min(t1["routine_start"], t2["routine_start"])
combined["routine_end"] = max(t1["routine_end"], t2["routine_end"])
combined["routine_freq"] = min(t1["routine_freq"], t2["routine_freq"])
Expand All @@ -87,23 +85,14 @@ def combine_tests_in_params(
)
]

# Name for the new test
new_test_name = f"{test1}_{test2}_{how}"
# Add the combined test to the parameters.
new_test_name = f"{test1}_{test2}_{how.value}"

# Add the combined test to routine_tests if not already present
if new_test_name not in params["routine_tests"]:
params["routine_tests"].append(new_test_name)

# Set proportion of all other tests to 0.0
for test_name in params["tests"]:
params["tests"][test_name]["proportion"] = 0.0

# Now add the combined test to the tests dictionary
params["tests"][new_test_name] = combined

# By default, we'll assign everyone the combined test
params["tests"][new_test_name]["proportion"] = 1.0

return params


Expand Down
6 changes: 6 additions & 0 deletions crcsim/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,9 @@ class Sex(Enum):
FEMALE = "female"
MALE = "male"
OTHER = "other"


@unique
class TestCombiningMethod(str, Enum):
SERIAL = "serial"
PARALLEL = "parallel"
Loading