Skip to content

Commit

Permalink
Merge pull request #36 from mj-will/fix-plots-not-closing
Browse files Browse the repository at this point in the history
Close figures that weren't closed
  • Loading branch information
mj-will authored Feb 24, 2021
2 parents 96d351c + a969bd2 commit e216686
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nessai/nestedsampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,8 +945,8 @@ def plot_state(self):

fig.tight_layout()
fig.subplots_adjust(top=0.95)

fig.savefig(f'{self.output}/state.png')
plt.close(fig)

def plot_trace(self):
"""
Expand Down
6 changes: 3 additions & 3 deletions nessai/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def plot_1d_comparison(*live_points, parameters=None, labels=None,
plt.tight_layout()
if filename is not None:
fig.savefig(filename, bbox_inches='tight')
plt.close()
plt.close(fig)
else:
return fig

Expand Down Expand Up @@ -207,7 +207,7 @@ def plot_indices(indices, nlive=None, filename=None, plot_breakdown=True):

if filename is not None:
plt.savefig(filename, bbox_inches='tight')
plt.close()
plt.close(fig)
else:
return fig

Expand Down Expand Up @@ -241,7 +241,7 @@ def plot_loss(epoch, history, filename=None):

if filename is not None:
plt.savefig(filename, bbox_inches='tight')
plt.close()
plt.close(fig)
else:
return fig

Expand Down
2 changes: 2 additions & 0 deletions nessai/proposal/flowproposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ def train(self, x, plot=True):
plt.hist(np.sqrt(np.sum(z_training_data ** 2, axis=1)), 'auto')
plt.xlabel('Radius')
fig.savefig(block_output + 'radial_dist.png')
plt.close(fig)

plot_1d_comparison(z_training_data, z_gen,
labels=['z_live_points', 'z_generated'],
Expand Down Expand Up @@ -1422,6 +1423,7 @@ def plot_pool(self, z, x):
plt.tight_layout()
fig.savefig(
f'{self.output}/pool_{self.populated_count}_log_q.png')
plt.close(fig)

def resume(self, model, flow_config, weights_file=None):
"""
Expand Down

0 comments on commit e216686

Please sign in to comment.