Skip to content

Commit

Permalink
Make validate_visualization_df work without matplotlib installation (#…
Browse files Browse the repository at this point in the history
…215)



Only import plotting functions in `petab.visualize` if matplotlib is installed.

Closes #212



Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com>
  • Loading branch information
dweindl and dilpath authored Jul 17, 2023
1 parent 25ee7aa commit b02d768
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions petab/visualize/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,32 @@
``import petab.visualize``.
"""
import importlib.util

from .plot_data_and_simulation import (
plot_without_vis_spec,
plot_with_vis_spec,
plot_problem,
)
mpl_spec = importlib.util.find_spec("matplotlib")

from .plot_residuals import plot_goodness_of_fit, plot_residuals_vs_simulation
from .plotter import MPLPlotter
from .plotting import DataProvider, Figure

__all__ = [
"plot_without_vis_spec",
"plot_with_vis_spec",
"plot_problem",
"plot_goodness_of_fit",
"plot_residuals_vs_simulation",
"MPLPlotter",
"DataProvider",
"Figure"
]

if mpl_spec is not None:
from .plot_data_and_simulation import (
plot_without_vis_spec,
plot_with_vis_spec,
plot_problem,
)

from .plot_residuals import plot_goodness_of_fit, plot_residuals_vs_simulation
from .plotter import MPLPlotter

__all__.extend([
"plot_without_vis_spec",
"plot_with_vis_spec",
"plot_problem",
"plot_goodness_of_fit",
"plot_residuals_vs_simulation",
"MPLPlotter",
])

0 comments on commit b02d768

Please sign in to comment.