Commit 44d6d22d authored by Martin Reinecke's avatar Martin Reinecke
Browse files

Merge branch 'non-blocking-plots' into 'NIFTy_5'

Allow for non-blocking plots

See merge request !362
parents 156c9d79 bad4b4dc
Pipeline #62620 passed with stages
in 8 minutes and 34 seconds
......@@ -73,7 +73,6 @@ class KLMetric(EndomorphicOperator):
return self._KL.metric_sample(from_inverse, dtype)
class MetricGaussianKL_MPI(Energy):
"""Provides the sampled Kullback-Leibler divergence between a distribution
and a Metric Gaussian.
......@@ -116,7 +115,7 @@ class MetricGaussianKL_MPI(Energy):
_samples : None
Only a parameter for internal uses. Typically not to be set by users.
seed_offset : int
A parameter with which one can controll from which seed the samples
A parameter with which one can controll from which seed the samples
are drawn. Per default, the seed is different for MPI tasks, but the
same every time this class is initialized.
......@@ -132,7 +131,6 @@ class MetricGaussianKL_MPI(Energy):
Torsten A. Enßlin, `<>`_
def __init__(self, mean, hamiltonian, n_samples, constants=[],
point_estimates=[], mirror_samples=False,
napprox=0, _samples=None, seed_offset=0):
......@@ -171,14 +171,15 @@ def _find_closest(A, target):
return idx
def _makeplot(name):
def _makeplot(name, block=True):
import matplotlib.pyplot as plt
if dobj.rank != 0:
if name is None:
if block:
extension = os.path.splitext(name)[1]
if extension in (".pdf", ".png", ".svg"):
......@@ -511,6 +512,9 @@ class Plot(object):
If left empty, the plot will be shown on the screen,
otherwise it will be written to a file with the given name.
Supported extensions: .png and .pdf. Default: None.
block: bool
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
nplot = len(self._plots)
......@@ -537,4 +541,4 @@ class Plot(object):
ax = fig.add_subplot(ny, nx, i+1)
_plot(self._plots[i], ax, **self._kwargs[i])
_makeplot(kwargs.pop("name", None))
_makeplot(kwargs.pop("name", None), block=kwargs.pop("block", True))
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