コード例 #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)
コード例 #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)
コード例 #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])
コード例 #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()"
コード例 #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()"
コード例 #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')
コード例 #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')
コード例 #8
0
 def test_plot_simple(self):
     lc = Lightcurve(self.times, self.counts)
     lc.plot()
     assert plt.fignum_exists(1)
コード例 #9
0
 def test_plot_title(self):
     lc = Lightcurve(self.times, self.counts)
     lc.plot(title="Test Lightcurve")
     assert plt.fignum_exists(1)
コード例 #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')
コード例 #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')
コード例 #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)
コード例 #13
0
 def test_plot_simple(self):
     lc = Lightcurve(self.times, self.counts)
     lc.plot()
     assert plt.fignum_exists(1)
コード例 #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)
コード例 #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)
コード例 #16
0
 def test_plot_title(self):
     lc = Lightcurve(self.times, self.counts)
     lc.plot(title="Test Lightcurve")
     assert plt.fignum_exists(1)
コード例 #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)