Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 1dbebd4

Browse files
author
Jaquier Aurélien Tristan
committed
Improve lfpy example scripts
1 parent 3206e0d commit 1dbebd4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

examples/l5pc_lfpy/generate_extra_features.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ def default(self, obj):
8181

8282
def dict_to_json(data, path):
8383
"""Save some data in a json file."""
84-
s = json.dumps(data, indent=2, cls=NumpyEncoder)
8584
with open(path, "w") as f:
86-
f.write(s)
85+
json.dump(data, f, indent=2, cls=NumpyEncoder)
8786

8887

8988
def add_extra_objectives(evaluator):

examples/l5pc_lfpy/l5pc_lfpy_evaluator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ def get_recording_names(protocol_name, location=None):
8888

8989
def define_fitness_calculator(protocols, feature_file):
9090

91-
feature_definitions = json.load(open(feature_file))
91+
with open(feature_file, "r") as f:
92+
feature_definitions = json.load(f)
9293

9394
objectives = []
9495
threshold = -20

0 commit comments

Comments
 (0)