-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c3397d
commit dcf791b
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
_topics/_08_reproducible_research_practices/src/python/analysis.py
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,18 @@ | ||
from demo1 import Experiment, Trial | ||
from pathlib import Path | ||
|
||
data_path = Path(r"src/data/demo1.json") | ||
task_spec = Path(r"src/json/experiment-example.json") | ||
with open(data_path, "r", encoding="utf-8") as f: | ||
trials = [Trial.model_validate_json(x) for x in f.readlines()] | ||
|
||
# print all trials | ||
[print(trial) for trial in trials] | ||
# print total reward consumed | ||
reward_consumed = sum([trial.reward_amount for trial in trials]) | ||
print(f"Animal consumed a total of {reward_consumed} ml") | ||
|
||
# print the task settings that gave rise to the trials | ||
with open(task_spec, "r", encoding="utf-8") as f: | ||
task_settings = Experiment.model_validate_json(f.read()) | ||
print(task_settings) |