Beispiel #1
0
 def tearDown(self):
     import psyplot.project as psy
     self.window.close()
     del self.window
     psy.close('all')
     rcParams.update_from_defaultParams()
     psy_rcParams.update_from_defaultParams()
     rcParams.disconnect()
     psy_rcParams.disconnect()
Beispiel #2
0
 def tearDownClass(cls):
     if not running_in_gui:
         import psyplot_gui.main as main
         cls.window.close()
         rcParams.update_from_defaultParams()
         psy_rcParams.update_from_defaultParams()
         rcParams.disconnect()
         psy_rcParams.disconnect()
         main._set_mainwindow(None)
         del cls.window, cls.straditizer_widgets
Beispiel #3
0
 def tearDown(self):
     import psyplot.project as psy
     import matplotlib.pyplot as plt
     if not running_in_gui:
         import psyplot_gui.main as main
         self.window.close()
         rcParams.update_from_defaultParams()
         psy_rcParams.update_from_defaultParams()
         rcParams.disconnect()
         psy_rcParams.disconnect()
         main._set_mainwindow(None)
     del self.window
     psy.close('all')
     plt.close('all')
Beispiel #4
0
    def tearDown(self):
        from psyplot import rcParams
        if self.remove_at_cleanup:
            if osp.exists(self.test_dir):
                shutil.rmtree(self.test_dir)
            if osp.exists(self.config_dir):
                shutil.rmtree(self.config_dir)
            if self.use_db:
                self._clear_db()
        rcParams.update_from_defaultParams(plotters=False)

        del self.organizer
        del self.test_dir
        del self.config_dir
Beispiel #5
0
 def tearDown(self):
     import psyplot.project as psy
     import matplotlib.pyplot as plt
     if not running_in_gui:
         import psyplot_gui.main as main
         self.window.close()
         rcParams.update_from_defaultParams()
         psy_rcParams.update_from_defaultParams()
         rcParams.disconnect()
         psy_rcParams.disconnect()
         main._set_mainwindow(None)
     del self.window
     psy.close('all')
     plt.close('all')
Beispiel #6
0
    def test_rc(self):
        """Test whether the rcParams are interpreted correctly"""
        checks = []

        def validate(val):
            checks.append(val)
            return val

        def validate_false(val):
            if val == 4:
                raise ValueError("Expected ValueError")
            return val

        try:

            class RcTestPlotter(TestPlotter):
                _rcparams_string = ['plotter.test.data.']

            # delete the validation
            del TestFormatoption._validate
            rcParams.defaultParams['plotter.test.data.fmt1'] = (1, validate)
            rcParams.defaultParams['plotter.test.data.fmt3'] = (3,
                                                                validate_false)
            rcParams.update_from_defaultParams()
            plotter = RcTestPlotter(xr.DataArray([]))

            self.assertEqual(checks, [1],
                             msg='Validation function has not been called!')
            # test general functionality
            self.assertEqual(plotter.fmt1.default_key,
                             'plotter.test.data.fmt1')
            self.assertEqual(plotter.fmt3.default_key,
                             'plotter.test.data.fmt3')
            if six.PY3:
                with self.assertRaisesRegex(KeyError, 'fmt2'):
                    plotter.fmt2.default_key
            self.assertEqual(plotter['fmt1'], 1)
            self.assertEqual(plotter.fmt1.default, 1)
            self.assertFalse(plotter.fmt2.value)
            self.assertIs(plotter.fmt1.validate, validate)
            # test after update
            plotter.update(fmt1=8)
            self.assertEqual(checks, [1, 8],
                             msg='Validation function has not been called!')
            self.assertEqual(plotter.fmt1.value, 8)
            self.assertEqual(plotter['fmt1'], 8)
            self.assertEqual(plotter.fmt1.default, 1)
            # test false validation
            if six.PY3:
                with self.assertWarnsRegex(
                        RuntimeWarning, "Could not find a validation "
                        "function"):
                    plotter.fmt2.validate
                with self.assertRaisesRegex(ValueError, 'Expected ValueError'):
                    plotter.update(fmt3=4)
                plotter.update(fmt3=3)
            plotter.fmt2.validate = validate
            plotter.update(fmt2=9)
            self.assertEqual(checks, [1, 8, 9])
            self.assertEqual(plotter.fmt2.value, 9)
        except:
            raise
        finally:
            TestFormatoption._validate = str
Beispiel #7
0
 def tearDown(self):
     results.clear()
     rcParams.clear()
     rcParams.defaultParams = psyc.rcsetup.defaultParams
     rcParams.update_from_defaultParams()