Skip to content

Commit

Permalink
Add t_rads vs. shell id plot to html report.
Browse files Browse the repository at this point in the history
  • Loading branch information
Karan Desai committed Jun 11, 2016
1 parent d30b60c commit 2f4d86b
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions tardis/tests/tests_slow/test_w7.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ def plot_spectrum(self, has_passed):
ldl_ax.plot(self.reference['wavelength'], deviation,
color="red", marker=".")

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

def test_montecarlo_properties(self):
Expand All @@ -180,7 +178,35 @@ def test_montecarlo_properties(self):
self.reference['montecarlo_nu'],
self.result.montecarlo_nu)

def test_shell_temperature(self):
assert_quantity_allclose(
def test_shell_temperature(self, request):
try:
assert_quantity_allclose(
self.reference['t_rads'],
self.result.t_rads)
except Exception as e:
self.plot_t_rads(has_passed=False)
raise e
else:
self.plot_t_rads(has_passed=True)

request.config.dokureport.add_plot(
os.path.join(self.base_plot_dir, "t_rads.png")
)

def plot_t_rads(self, has_passed):
plt.suptitle("Shell temperature for packets", fontweight="bold")

ax = plt.subplot(111)
ax.set_xlabel("Shell id")
ax.set_ylabel("t_rads")

if has_passed:
ax.text(0.8, 0.8, 'passed', transform=ax.transAxes,
bbox={'facecolor': 'green', 'alpha': 0.5, 'pad': 10})
ax.plot(self.result.t_rads, color="green", marker=".")
else:
ax.text(0.8, 0.8, 'failed', transform=ax.transAxes,
bbox={'facecolor': 'red', 'alpha': 0.5, 'pad': 10})
ax.plot(self.result.t_rads, color="red", marker=".")
ax.axis([0, 28, 5000, 10000])
plt.savefig(os.path.join(self.base_plot_dir, "t_rads.png"))

0 comments on commit 2f4d86b

Please sign in to comment.