Spaces:
Running
Running
File size: 1,223 Bytes
b43adf7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
from pathlib import Path
from cli.config import GenerateConfig
def merge_with_default_config(
default_cfg: GenerateConfig,
n_cases: int,
start_date,
end_date,
output_dir: str,
seed: int,
) -> GenerateConfig:
"""Merge UI values with the repo's default generate config."""
return GenerateConfig(
n_cases=n_cases or default_cfg.n_cases,
start=start_date or default_cfg.start,
end=end_date or default_cfg.end,
output=Path(output_dir) / "cases.csv" if output_dir else default_cfg.output,
seed=seed if seed is not None else default_cfg.seed,
)
def build_case_type_distribution(
rsa_pct: int,
rfa_pct: int,
crp_pct: int,
ca_pct: int,
ccc_pct: int,
cp_pct: int,
cmp_pct: int,
) -> dict[str, float]:
"""Convert percentage inputs into a probability distribution."""
total = rsa_pct + rfa_pct + crp_pct + ca_pct + ccc_pct + cp_pct + cmp_pct
if total == 0:
return {}
return {
"RSA": rsa_pct / total,
"RFA": rfa_pct / total,
"CRP": crp_pct / total,
"CA": ca_pct / total,
"CCC": ccc_pct / total,
"CP": cp_pct / total,
"CMP": cmp_pct / total,
}
|