From 2f4d86b988c01824292ffb23b560e1ec88b19c99 Mon Sep 17 00:00:00 2001 From: Karan Desai Date: Fri, 10 Jun 2016 22:23:18 +0530 Subject: [PATCH] Add t_rads vs. shell id plot to html report. --- tardis/tests/tests_slow/test_w7.py | 34 ++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/tardis/tests/tests_slow/test_w7.py b/tardis/tests/tests_slow/test_w7.py index b5026aef472..87923d2a898 100644 --- a/tardis/tests/tests_slow/test_w7.py +++ b/tardis/tests/tests_slow/test_w7.py @@ -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): @@ -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"))