-
Notifications
You must be signed in to change notification settings - Fork 0
refactor testing! #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| /target | ||
| .DS_Store | ||
| .idea/ | ||
| scripts/__pycache__ | ||
| .venv |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| from pathlib import Path | ||
| from random import Random | ||
|
|
||
| SCRIPT_DIR = Path(__file__).resolve().parent | ||
| INPUT_DIR = SCRIPT_DIR.parent / "tests" / "inputs" | ||
|
|
||
|
|
||
| def write_stimulus(aag_path: Path) -> None: | ||
| # get I and L from 'aag M I L O A' | ||
| aag_header = aag_path.read_text().split() | ||
| I = int(aag_header[2]) | ||
| L = int(aag_header[3]) | ||
|
|
||
| # just for fun: use path name as random seed! | ||
| # (not necessary AT ALL but I think it's cool) | ||
| rng = Random(aag_path.name) | ||
| clock_cycles = 1 if L == 0 else 2**L + 1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't totally understand why 2^L+1 is the right number of cycles, but choosing something that is somehow related to the number of latches seems perfectly reasonable, I suppose. |
||
| input_rows = [] | ||
| for _ in range(clock_cycles): | ||
| input_rows.append("".join(rng.choice("01") for _ in range(I))) | ||
|
|
||
| stim_path = aag_path.with_suffix(".stim") | ||
|
|
||
| stim_path.write_text("\n".join([*input_rows, "."]) + "\n") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, this might be slightly more readable/maintainable as a loop. Something like this: with open(stim_path, 'w') as f:
for row in input_rows:
print(row, file=f)
print('.', file=f) |
||
| print(f"wrote {stim_path}") | ||
|
|
||
|
|
||
| def main() -> None: | ||
| for aag_path in sorted(INPUT_DIR.glob("*.aag")): | ||
| write_stimulus(aag_path) | ||
|
|
||
| print(f"wrote AIGER stimulus inputs to {INPUT_DIR}") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is pretty cool. 😃