Skip to content
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

added docstrings #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pypastry/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@
import pypastry


=======
def cache_display(results_from_repo: Iterator['pypastry.experiment.results.Result']) -> None:
"""
Caches results from the machine learning experiments and selects the recent 5 results tp be displayed
Args:
results_from_repo (list):

Returns:
None

"""
from pandas import DataFrame

results = []
Expand Down Expand Up @@ -46,7 +56,18 @@ def cache_display(results_from_repo: Iterator['pypastry.experiment.results.Resul
output_file.write(display)



=======
def print_cache_file(limit = False):
"""
Prints the 5 most recent experiment results to screen
Args:
None

Returns:
None

"""
with open(DISPLAY_PATH) as display_file:
read_lines = display_file.read()
read_list = read_lines.split("\n")
Expand Down
10 changes: 10 additions & 0 deletions pypastry/experiment/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@ def __init__(self, results_path: str):
self.results_path = results_path

def save_results(self, run_infos: List[Dict[str, Any]], dataset_info: Dict[str, Any]) -> List[str]:
"""
Stores all experiment results into a json file
Args:
run_infos (dict): Dictionary containing results information
daraset_info (dict): Dictionary contatining dataset information

Returns:
List of result files names
"""
try:
mkdir(self.results_path)
except FileExistsError:
pass
new_filenames = []
for i, run_info in enumerate(run_infos):
run_info['dataset'] = dataset_info
# TODO put git commit hash or combination of username and timestamp in the prefix to avoid merge conflicts
with NamedTemporaryFile(mode='w', prefix='result-', suffix='.json',
dir=self.results_path, delete=False) as output_file:
json.dump(run_info, output_file, indent=4)
Expand Down