Skip to content

Commit

Permalink
update version
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Sep 11, 2024
1 parent 4602355 commit c8114b5
Show file tree
Hide file tree
Showing 5 changed files with 66,483 additions and 27 deletions.
17 changes: 11 additions & 6 deletions bio_compose/data_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import time
import os
from warnings import warn
from dataclasses import asdict, dataclass
from functools import wraps
from typing import Dict, List, Union, Any, Callable
Expand Down Expand Up @@ -234,12 +235,16 @@ def save_plot(func):
"""
@wraps(func)
def wrapper(self, *args, **kwargs):
fig, data = func(self, *args, **kwargs)
save_dest = kwargs.get('save_dest', None)
if save_dest is not None:
dest = save_dest + '.pdf'
self.export_plot(fig=fig, save_dest=dest)
return data
try:
fig, data = func(self, *args, **kwargs)
save_dest = kwargs.get('save_dest', None)
if save_dest is not None:
dest = save_dest + '.pdf'
self.export_plot(fig=fig, save_dest=dest)
return data
except ValueError as e:
warn(str(e))
return {}

return wrapper

Expand Down
22 changes: 11 additions & 11 deletions bio_compose/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ def get_rmse(self, job_id: str) -> dict:
"""
try:
output = self.get_output(job_id=job_id)
return output['content'].get('results').get('rmse') or {}
except Exception as e:
return output['content'].get('results').get('rmse', {})
except:
import traceback
tb_str = traceback.format_exc()
error_message = (
Expand Down Expand Up @@ -406,19 +406,19 @@ def visualize_rmse(self, job_id: str, fig_dimensions: tuple[int, int] = None, co
"""
Visualize the root-mean-squared error between simulator verification outputs as a heatmap.
Args:
- **job_id**: `str`: verification job id. This value can be easily derived from either of `Verifier`'s `.verify_...` methods.
- **fig_dimensions**: `Tuple[int, int], optional`: The value to use as the `figsize` parameter for a call to `matplotlib.pyplot.figure()`. If `None` is passed, default to (8, 6).
- **color_mapping**: `List[str], optional`: list of colors to use for each simulator in the grid. Defaults to None.
- **save_dest**: `str`: destination at which to save figure. Defaults to `None`.
:param job_id: (`str`) verification job id. This value can be easily derived from either of `Verifier`'s `.verify_...` methods.
:param fig_dimensions: (`Tuple[int, int], optional`) The value to use as the `figsize` parameter for a call to `matplotlib.pyplot.figure()`. If `None` is passed, default to (8, 6).
:param color_mapping: (`List[str], optional`) list of colors to use for each simulator in the grid. Defaults to None.
:param save_dest: `(str`) destination at which to save figure. Defaults to `None`.
Returns:
`Tuple[matplotlib.Figure, Dict]` of matplotlib Figure and simulator RMSE scores
:return: matplotlib Figure and simulator RMSE scores
:rtype: `Tuple[matplotlib.Figure, Dict]`
"""
# extract data
rmse_matrix = self.get_rmse(job_id)
if 'error' in rmse_matrix.keys():
raise IOError(f"The job for {job_id} is either not ready or has an error. Please check the output.")
if not rmse_matrix or 'error' in rmse_matrix.keys():
raise ValueError(f"The job for {job_id} is either not ready or has an error in rmse scoring. Please check the output.")

simulators = list(rmse_matrix.keys())
n_simulators = len(simulators)

Expand Down
8 changes: 8 additions & 0 deletions documentation/source/verification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ Running **OMEX verifications**:
verification = verify(filepath, simulators)
Visualizing verifications:

.. code-block:: python
# visualize observables
verification.observables()
# visualize root-mean-square error scores for all simulators involved in the verification.
verification.rmse(save_dest='/my/save/path/for/observables')
Running **SBML verifications**:

Expand Down
12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c8114b5

Please sign in to comment.