def test_plot_wrong_label_type(self): lc = Lightcurve(self.times, self.counts) with pytest.raises(TypeError): with warnings.catch_warnings(record=True) as w: lc.plot(labels=123) assert "must be either a list or tuple" in str(w[0].message)
def test_plot_labels_index_error(self): lc = Lightcurve(self.times, self.counts) with warnings.catch_warnings(record=True) as w: lc.plot(labels=('x')) assert np.any( ["must have two labels" in str(wi.message) for wi in w])
def test_plot_matplotlib_not_installed(self): try: import matplotlib.pyplot as plt except Exception as e: lc = Lightcurve(self.times, self.counts) try: lc.plot() except Exception as e: assert type(e) is ImportError assert str(e) == "Matplotlib required for plot()"
def test_plot_custom_filename(self): lc = Lightcurve(self.times, self.counts) lc.plot(save=True, filename='lc.png') assert os.path.isfile('lc.png') os.unlink('lc.png')
def test_plot_default_filename(self): lc = Lightcurve(self.times, self.counts) lc.plot(save=True) assert os.path.isfile('out.png') os.unlink('out.png')
def test_plot_simple(self): lc = Lightcurve(self.times, self.counts) lc.plot() assert plt.fignum_exists(1)
def test_plot_title(self): lc = Lightcurve(self.times, self.counts) lc.plot(title="Test Lightcurve") assert plt.fignum_exists(1)
def test_plot_labels_index_error(self): lc = Lightcurve(self.times, self.counts) with warnings.catch_warnings(record=True) as w: lc.plot(labels=('x')) assert "must have two labels" in str(w[0].message)
def test_plot_axis(self): lc = Lightcurve(self.times, self.counts) lc.plot(axis=[0, 1, 0, 100]) assert plt.fignum_exists(1)
def test_plot_simple(self): lc = Lightcurve(self.times, self.counts) with warnings.catch_warnings(): warnings.simplefilter("ignore", category=UserWarning) lc.plot() assert plt.fignum_exists(1)