Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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])
Exemplo n.º 4
0
    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()"
Exemplo n.º 5
0
    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()"
Exemplo n.º 6
0
 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')
Exemplo n.º 7
0
 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')
Exemplo n.º 8
0
 def test_plot_simple(self):
     lc = Lightcurve(self.times, self.counts)
     lc.plot()
     assert plt.fignum_exists(1)
Exemplo n.º 9
0
 def test_plot_title(self):
     lc = Lightcurve(self.times, self.counts)
     lc.plot(title="Test Lightcurve")
     assert plt.fignum_exists(1)
Exemplo n.º 10
0
 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')
Exemplo n.º 11
0
 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')
Exemplo n.º 12
0
 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)
Exemplo n.º 13
0
 def test_plot_simple(self):
     lc = Lightcurve(self.times, self.counts)
     lc.plot()
     assert plt.fignum_exists(1)
Exemplo n.º 14
0
 def test_plot_axis(self):
     lc = Lightcurve(self.times, self.counts)
     lc.plot(axis=[0, 1, 0, 100])
     assert plt.fignum_exists(1)
Exemplo n.º 15
0
 def test_plot_axis(self):
     lc = Lightcurve(self.times, self.counts)
     lc.plot(axis=[0, 1, 0, 100])
     assert plt.fignum_exists(1)
Exemplo n.º 16
0
 def test_plot_title(self):
     lc = Lightcurve(self.times, self.counts)
     lc.plot(title="Test Lightcurve")
     assert plt.fignum_exists(1)
Exemplo n.º 17
0
 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)