-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functionality for extracting households (#144)
* Add functionality to sample a household from a microsim Fixes #143 * Versioning * Add random sample feature
- Loading branch information
1 parent
70de623
commit 5200aeb
Showing
4 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- bump: minor | ||
changes: | ||
added: | ||
- Simulation helper to extract individual households from a microsimulation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import yaml | ||
from pathlib import Path | ||
import numpy as np | ||
import json | ||
|
||
|
||
def generate_test_from_situation(situation: dict, file_path: str): | ||
"""Generate a test from a situation. | ||
Args: | ||
situation (dict): The situation to generate the test from. | ||
test_name (str): The name of the test. | ||
""" | ||
|
||
yaml_contents = [ | ||
{ | ||
"input": situation, | ||
"output": {}, | ||
} | ||
] | ||
|
||
with open(Path(file_path), "w+") as f: | ||
yaml.dump(yaml_contents, f) |