Skip to content

Commit

Permalink
Fix use of config, rename CLI args
Browse files Browse the repository at this point in the history
  • Loading branch information
sgreenbury committed Sep 16, 2024
1 parent 393d189 commit 032fcf0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
16 changes: 8 additions & 8 deletions scripts/1_prep_synthpop.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import click
import numpy as np
import tomlkit
from uatk_spc.builder import Builder

import acbm
from acbm.utils import get_config


@click.command()
# TODO: add override for case when seed provided from CLI
# @click.option("--seed", default=1, help="Seed for random state", type=int)
@click.option("--config", prompt="Filepath relative to repo root of config", type=str)
def main(config):
# Read config
with open(acbm.root_path / config, "rb") as f:
config_dict = tomlkit.load(f)
seed = config_dict["parameters"]["seed"]
region = config_dict["parameters"]["region"]
@click.option(
"--config_file", prompt="Filepath relative to repo root of config", type=str
)
def main(config_file):
config = get_config(config_file)
seed = config["parameters"]["seed"]
region = config["parameters"]["region"]

# Seed RNG
np.random.seed(seed)
Expand Down
15 changes: 10 additions & 5 deletions scripts/2_match_households_and_individuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@


@click.command()
@click.option("--config", prompt="Filepath relative to repo root of config", type=str)
def main(config):
config_loaded = get_config(config)
@click.option(
"--config_file", prompt="Filepath relative to repo root of config", type=str
)
def main(config_file):
config = get_config(config_file)

# Seed RNG
SEED = config_loaded["seed"]
SEED = config["parameters"]["seed"]
np.random.seed(SEED)

pd.set_option("display.max_columns", None)
Expand Down Expand Up @@ -89,7 +91,10 @@ def get_interim_path(
unique_households = spc["household"].unique()
# Sample a subset of households
sampled_households = pd.Series(unique_households).sample(
n=min(config_loaded["number_of_households"], unique_households),
n=min(
config["parameters"]["number_of_households"],
unique_households.shape[0],
),
random_state=SEED,
)
# Filter the original DataFrame based on the sampled households
Expand Down

0 comments on commit 032fcf0

Please sign in to comment.