Skip to content

Commit

Permalink
Add facility to save plots in directory structure.
Browse files Browse the repository at this point in the history
- Directories are named according to commit hash.

- Log scale has been removed from graphs due to a
  ValueError. Zero cannot be represented on a log
  scale.
  • Loading branch information
Karan Desai committed May 24, 2016
1 parent cf886d9 commit 9f37a6d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tardis/tests/tests_slow/test_w7.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from numpy.testing import assert_allclose
from astropy.tests.helper import assert_quantity_allclose

import tardis
from tardis.atomic import AtomData
from tardis.simulation.base import Simulation
from tardis.model import Radial1DModel
Expand Down Expand Up @@ -57,6 +58,11 @@ def setup(self, request, reference, data_path, atomic_data_fname,
# Get the reference data through the fixture.
self.reference = reference

# Path to directory where comparison plots for test run on current
# commit will be saved. Temporarily kept as `/tmp` directory.
# TODO: Can be created as a fixture later.
self.plot_savedir = os.path.join("/tmp", tardis.__githash__)

def test_j_estimators(self):
assert_allclose(
self.reference['j_estimators'],
Expand Down Expand Up @@ -145,14 +151,13 @@ def plot_spectrum(self, passed):
bbox={'facecolor': 'green', 'alpha': 0.5, 'pad': 10})
ldl_ax.plot(self.reference['wavelength'], deviation, "g+")
else:
ldl_ax.set_yscale("log")
ldl_ax.text(0.8, 0.8, 'failed', transform=ldl_ax.transAxes,
bbox={'facecolor': 'red', 'alpha': 0.5, 'pad': 10})
ldl_ax.plot(self.reference['wavelength'], deviation, "rx")

# Figure is saved in `tmp` directory right now, till a suitable way of
# saving them is decided.
plt.savefig(os.path.join("/tmp", "spectrum_plot.png"))
plt.savefig(os.path.join(self.plot_savedir, "spectrum.png"))

def test_montecarlo_properties(self):
assert_quantity_allclose(
Expand Down

0 comments on commit 9f37a6d

Please sign in to comment.