Skip to content

Commit

Permalink
Added ProtocolToFeaturesTest
Browse files Browse the repository at this point in the history
  • Loading branch information
rgerkin committed May 3, 2019
1 parent e95051b commit d92c868
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions sciunit/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,3 +562,28 @@ def compute_score(self, observation, prediction):
low = observation[0]
high = observation[1]
return self.score_type(low < prediction < high)

class ProtocolToFeaturesTest(Test):
"""Assume that generating a prediction consists of:
1) Setting up a simulation experiment protocol,
2) Running a model (using e.g. RunnableModel)
3) Extract features from the results
"""

def generate_prediction(self, model):
run_method = getattr(model, "run", None)
assert callable(run_method), "Model must have a `run` method to use a ProtocolToFeatureTest"
self.setup_protocol(model)
result = self.get_result(model)
prediction = self.extract_features(model, result)
return prediction

def setup_protocol(self, model):
return NotImplementedError()

def get_result(self, model):
return NotImplementedError()

def extract_features(self, model, result):
return NotImplementedError()

0 comments on commit d92c868

Please sign in to comment.