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

Commit 42dd6bb

Browse files
author
Tanguy Damart
committed
Add tests
1 parent c2661a0 commit 42dd6bb

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

bluepyopt/ephys/evaluators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,17 @@ def run_protocols(self, protocols, param_values):
184184

185185
def evaluate_with_dicts(self, param_dict=None, target='scores'):
186186
"""Run evaluation with dict as input and output"""
187-
187+
188188
if target not in ['scores', 'values']:
189189
raise Exception(
190190
'CellEvaluator: target has to be "scores" or "values".')
191-
191+
192192
if self.fitness_calculator is None:
193193
raise Exception(
194194
'CellEvaluator: need fitness_calculator to evaluate')
195195

196196
logger.debug('Evaluating %s', self.cell_model.name)
197-
197+
198198
responses = self.run_protocols(
199199
self.fitness_protocols.values(),
200200
param_dict)

bluepyopt/ephys/objectives.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def calculate_score(self, responses):
7575
"""Objective score"""
7676

7777
return self.calculate_feature_scores(responses)[0]
78-
78+
7979
def calculate_value(self, responses):
8080
"""Objective value"""
8181

bluepyopt/tests/test_ephys/test_evaluators.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ def test_CellEvaluator_evaluate():
110110
sim=sim)
111111

112112
responses = protocol.run(cell_model, {'cm': 1.0}, sim=sim)
113+
113114
feature_value = efeature.calculate_feature(responses)
115+
feature_value_eva = evaluator.evaluate_with_dicts(
116+
{'cm': 1.0}, target='values'
117+
)
114118

115119
score = evaluator.evaluate([1.0])
116120
expected_score = abs(mean - feature_value)
@@ -120,3 +124,6 @@ def test_CellEvaluator_evaluate():
120124
score_dict = evaluator.objective_dict(score)
121125

122126
nt.assert_almost_equal(score_dict['singleton'], expected_score)
127+
nt.assert_almost_equal(
128+
feature_value, feature_value_eva['singleton']
129+
)

bluepyopt/tests/test_ephys/test_objectives.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@ def test_SingletonObjective():
7979
responses = {'square_pulse_step1.soma.v': response, }
8080

8181
efeature_value = efeature.calculate_feature(responses)
82+
efeature_value_obj = s_obj.calculate_value(responses)
8283

8384
nt.assert_almost_equal(
8485
s_obj.calculate_score(responses),
8586
abs(efeature_value - mean))
87+
nt.assert_almost_equal(efeature_value_obj, efeature_value)
8688

8789

8890
@attr('unit')

0 commit comments

Comments
 (0)