From 39fc5f4718bbed935cf35a6cd26383927f5f75fb Mon Sep 17 00:00:00 2001 From: Karan Desai Date: Tue, 24 May 2016 18:07:01 +0530 Subject: [PATCH] Cosmetic improvements in plot_spectrum method. --- tardis/tests/tests_slow/test_w7.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tardis/tests/tests_slow/test_w7.py b/tardis/tests/tests_slow/test_w7.py index 870edfdcfdf..0fae7161811 100644 --- a/tardis/tests/tests_slow/test_w7.py +++ b/tardis/tests/tests_slow/test_w7.py @@ -5,7 +5,6 @@ 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 @@ -128,12 +127,12 @@ def test_spectrum(self): self.reference['luminosity_density_lambda'], self.result.spectrum.luminosity_density_lambda) - self.plot_spectrum(passed=True) + self.plot_spectrum(has_passed=True) except Exception as e: - self.plot_spectrum(passed=False) + self.plot_spectrum(has_passed=False) raise e - def plot_spectrum(self, passed): + def plot_spectrum(self, has_passed): plt.suptitle("Deviation in spectrum_quantities", fontweight="bold") # `ldl_` prefixed variables associated with `luminosity_density_lambda`. @@ -142,19 +141,21 @@ def plot_spectrum(self, passed): ldl_ax = plt.subplot(111) ldl_ax.set_title("Deviation in luminosity_density_lambda") ldl_ax.set_xlabel("Wavelength") - ldl_ax.set_ylabel("Relative error (1 - obtained / baseline)") + ldl_ax.set_ylabel("Relative error (1 - result / reference)") deviation = 1 - ( self.result.spectrum.luminosity_density_lambda.value / self.reference['luminosity_density_lambda'].value) - if passed: + if has_passed: ldl_ax.text(0.8, 0.8, 'passed', transform=ldl_ax.transAxes, bbox={'facecolor': 'green', 'alpha': 0.5, 'pad': 10}) - ldl_ax.plot(self.reference['wavelength'], deviation, "g+") + ldl_ax.plot(self.reference['wavelength'], deviation, + color="green", marker=".") else: 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") + 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.