-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
224-224 not 244-224, cleaner code for frontier selecting, filling depth
- Loading branch information
1 parent
7f1de6c
commit 611e4c9
Showing
4 changed files
with
88 additions
and
39 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,38 @@ | ||
import argparse | ||
import json | ||
import os | ||
from collections import Counter | ||
|
||
|
||
def read_json_files(directory): | ||
failure_causes = [] | ||
for filename in os.listdir(directory): | ||
if filename.endswith(".json"): | ||
with open(os.path.join(directory, filename), "r") as f: | ||
data = json.load(f) | ||
if "failure_cause" in data: | ||
failure_causes.append(data["failure_cause"]) | ||
return failure_causes | ||
|
||
|
||
def calculate_frequencies(failure_causes): | ||
counter = Counter(failure_causes) | ||
total = sum(counter.values()) | ||
for cause, count in counter.items(): | ||
percentage = (count / total) * 100 | ||
print( | ||
f"Failure cause: {cause}, Frequency: {count}, Percentage: {percentage:.2f}%" | ||
) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description="Process some integers.") | ||
parser.add_argument("directory", type=str, help="Directory to process") | ||
args = parser.parse_args() | ||
|
||
failure_causes = read_json_files(args.directory) | ||
calculate_frequencies(failure_causes) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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