Commit 08cf1661 authored by Philipp Arras's avatar Philipp Arras
Browse files

Make matplotlib optional dependency again

parent 17ab7ea9
Pipeline #128090 passed with stages
in 19 minutes and 24 seconds
......@@ -22,8 +22,6 @@ from os import makedirs
from os.path import isdir, isfile, join
from warnings import warn
from matplotlib.colors import LogNorm
from ..domain_tuple import DomainTuple
from ..multi_domain import MultiDomain
from ..multi_field import MultiField
......@@ -518,6 +516,11 @@ def _append_key(s, key):
def _plot_stats(file_name, mean, var, ground_truth, comm, plotting_kwargs):
try:
from matplotlib.colors import LogNorm
except ImportError:
return
p = Plot()
if ground_truth is not None:
p.add(ground_truth, title="Ground truth", **plotting_kwargs)
......
......@@ -17,6 +17,7 @@
import os
from itertools import product
from warnings import warn
from datetime import datetime as dt
import numpy as np
......@@ -640,7 +641,11 @@ class Plot:
Override the blocking behavior of the non-interactive plotting
mode. The plot will not be closed in this case but is left open!
"""
import matplotlib.pyplot as plt
try:
import matplotlib.pyplot as plt
warn("Since matplotlib is not installed, NIFTy will not generate any plots.")
except ImportError:
return
nplot = len(self._plots)
fig = plt.figure()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment