Skip to content

Commit

Permalink
Merge branch 'dev' into deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrkarr committed Dec 28, 2020
2 parents f91ccc2 + dcf53b0 commit 70ec4c5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion biosimulators_test_suite/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.4'
__version__ = '0.1.5'
2 changes: 1 addition & 1 deletion biosimulators_test_suite/exec_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def run(self):
print(termcolor.colored(result.type.value, TERMINAL_COLORS[result.type.value]), end='')
print(' (', end='')
if result.warnings:
print(termcolor.colored(str(len(result.warnings)) + ', ', TERMINAL_COLORS['warned']), end='')
print(termcolor.colored(str(len(result.warnings)) + ' warnings, ', TERMINAL_COLORS['warned']), end='')
print('{:.1f} s'.format(result.duration), end='')
print(').')

Expand Down
23 changes: 19 additions & 4 deletions biosimulators_test_suite/test_case/published_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def from_dict(self, data):
id = exp_report_def['id']

data_set_labels = set(exp_report_def.get('dataSets', []))
points = tuple(exp_report_def['points'])

values = {}
for key, val in exp_report_def.get('values', {}).items():
Expand All @@ -173,7 +174,20 @@ def from_dict(self, data):
else:
values[key] = {}
for k, v in val.items():
values[key][tuple(int(index) for index in k.split(","))] = v
multi_index = tuple(int(index) for index in k.split(","))
try:
numpy.ravel_multi_index([multi_index], points)[0]
except ValueError:
raise ValueError((
"Key '{}' of the expected values of report '{}' of published project test case '{}' is invalid. "
"Key must be less than or equal to '{}'."
).format(
multi_index,
self.id,
self.id.replace('published_project.PublishedProjectTestCase:', ''),
tuple(p - 1 for p in points),
))
values[key][multi_index] = v

invalid_dataset_ids = set(values.keys()).difference(set(data_set_labels))
if invalid_dataset_ids:
Expand All @@ -187,7 +201,7 @@ def from_dict(self, data):
self.expected_reports.append(ExpectedSedReport(
id=id,
data_sets=data_set_labels,
points=tuple(exp_report_def['points']),
points=points,
values=values,
))

Expand Down Expand Up @@ -305,16 +319,17 @@ def eval(self, specifications):
value = report.loc[data_set_label, :]
for el_id, expected_el_value in expected_value.items():
el_index = numpy.ravel_multi_index([el_id], value.shape)[0]
actual_el_value = value[el_index]
try:
numpy.testing.assert_allclose(
value[el_index],
actual_el_value,
expected_el_value,
rtol=self.r_tol,
atol=self.a_tol,
)
except AssertionError:
errors.append('Data set {} of report {} does not have expected value at {}: {} != {}'.format(
data_set_label, expected_report.id, el_id, value[el_index], expected_el_value))
data_set_label, expected_report.id, el_id, actual_el_value, expected_el_value))
else:
try:
numpy.testing.assert_allclose(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"values": {
"time": {
"0": 0.0,
"301": 5100.0
"300": 5100.0
}
}
}],
Expand Down
12 changes: 10 additions & 2 deletions tests/test_case/test_published_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,19 @@ def test_CuratedCombineArchiveTestCase_from_dict_error_handling(self):
filename = os.path.join('sbml-core', 'Caravagna-J-Theor-Biol-2010-tumor-suppressive-oscillations.json')
with open(os.path.join(base_path, filename), 'r') as file:
data = json.load(file)
data['expectedReports'][0]['values']['t'] = [0, 1, 2, 3, 4, 5]
id = 'published_project.PublishedProjectTestCase:sbml-core/Caravagna-J-Theor-Biol-2010-tumor-suppressive-oscillations.json'

data['expectedReports'][0]['values'] = {'t': [0, 1, 2, 3, 4, 5]}
with self.assertRaisesRegex(ValueError, "keys were not in the 'dataSets' property"):
id = 'published_project.PublishedProjectTestCase:sbml-core/Caravagna-J-Theor-Biol-2010-tumor-suppressive-oscillations.json'
PublishedProjectTestCase(id=id).from_dict(data)

data['expectedReports'][0]['values'] = {'T': {'5001': 1000.2}}
with self.assertRaisesRegex(ValueError, "Key must be less than or equal to"):
PublishedProjectTestCase(id=id).from_dict(data)

data['expectedReports'][0]['values'] = {'T': {'5000': 1000.}}
PublishedProjectTestCase(id=id).from_dict(data)

def test_CuratedCombineArchiveTestCase_from_json(self):
base_path = os.path.join(os.path.dirname(__file__), '..', '..', 'examples')
filename = os.path.join('sbml-core', 'Caravagna-J-Theor-Biol-2010-tumor-suppressive-oscillations.json')
Expand Down

0 comments on commit 70ec4c5

Please sign in to comment.