Example #1
0
    def test_config(self):
        parser = ConfigParser()
        ps = PlotSettings()

        with TestAreaContext("plot_config"):
            with open("config_file", "w") as f:
                f.write("PLOT_SETTING PATH abc\n")
                f.write("PLOT_SETTING SHOW_REFCASE False\n")
                f.write("PLOT_SETTING UnknownKey Value\n")

            #_plot_settings_config( parser )
            content = parser.parse("config_file")
            ps.apply(content)
Example #2
0
    def test_plot_config_history(self):
        ps = PlotSettings()
        test_pc = PlotConfig(ps, title="test_1")
        history = PlotConfigHistory("test", test_pc)

        self.assertEqual(history.getPlotConfig().title(), test_pc.title())
        self.assertNotEqual(history.getPlotConfig(), test_pc)

        self.assertFalse(history.isUndoPossible())
        self.assertFalse(history.isRedoPossible())

        history.applyChanges(PlotConfig(ps, title="test_2"))
        self.assertTrue(history.isUndoPossible())
        self.assertFalse(history.isRedoPossible())
        self.assertEqual(history.getPlotConfig().title(), "test_2")

        history.undoChanges()
        self.assertFalse(history.isUndoPossible())
        self.assertTrue(history.isRedoPossible())
        self.assertEqual(history.getPlotConfig().title(), "test_1")

        history.redoChanges()
        self.assertTrue(history.isUndoPossible())
        self.assertFalse(history.isRedoPossible())
        self.assertEqual(history.getPlotConfig().title(), "test_2")

        history.resetChanges()
        self.assertTrue(history.isUndoPossible())
        self.assertFalse(history.isRedoPossible())
        self.assertEqual(history.getPlotConfig().title(), "test_1")

        history.undoChanges()
        self.assertTrue(history.isUndoPossible())
        self.assertTrue(history.isRedoPossible())
        self.assertEqual(history.getPlotConfig().title(), "test_2")
Example #3
0
    def test_set_get(self):
        ps = PlotSettings()
        with self.assertRaises(KeyError):
            ps["UNKNOWN_KEY"] = 1000

        with self.assertRaises(TypeError):
            ps["SHOW_REFCASE"] = "Don-know"

        ps["SHOW_REFCASE"] = False
        self.assertEqual(ps["SHOW_REFCASE"], False)

        ps["SHOW_REFCASE"] = True
        self.assertEqual(ps["SHOW_REFCASE"], True)
Example #4
0
    def test_plot_config(self):
        ps = PlotSettings( )
        plot_config = PlotConfig(ps , "Golden Sample", x_label="x", y_label="y")

        limits = PlotLimits()
        limits.count_limits = 1, 2
        limits.depth_limits = 3, 4
        limits.density_limits = 5, 6
        limits.date_limits = datetime.date(2005, 2, 5), datetime.date(2006, 2, 6)
        limits.index_limits = 7, 8
        limits.value_limits = 9.0, 10.0

        plot_config.limits = limits
        self.assertEqual(plot_config.limits, limits)

        plot_config.setDistributionLineEnabled(True)
        plot_config.setLegendEnabled(False)
        plot_config.setGridEnabled(False)
        plot_config.setRefcaseEnabled(False)
        plot_config.setObservationsEnabled(False)

        style = PlotStyle("test_style", line_style=".", marker="g", width=2.5, size=7.5)

        plot_config.setDefaultStyle(style)
        plot_config.setRefcaseStyle(style)
        plot_config.setStatisticsStyle("mean", style)
        plot_config.setStatisticsStyle("min-max", style)
        plot_config.setStatisticsStyle("p50", style)
        plot_config.setStatisticsStyle("p10-p90", style)
        plot_config.setStatisticsStyle("p33-p67", style)
        plot_config.setStatisticsStyle("std", style)

        copy_of_plot_config = PlotConfig(ps , "Copy of Golden Sample")
        copy_of_plot_config.copyConfigFrom(plot_config)

        self.assertEqual(plot_config.isLegendEnabled(), copy_of_plot_config.isLegendEnabled())
        self.assertEqual(plot_config.isGridEnabled(), copy_of_plot_config.isGridEnabled())
        self.assertEqual(plot_config.isObservationsEnabled(), copy_of_plot_config.isObservationsEnabled())
        self.assertEqual(plot_config.isDistributionLineEnabled(), copy_of_plot_config.isDistributionLineEnabled())

        self.assertEqual(plot_config.refcaseStyle(), copy_of_plot_config.refcaseStyle())
        self.assertEqual(plot_config.observationsStyle(), copy_of_plot_config.observationsStyle())

        self.assertEqual(plot_config.histogramStyle(), copy_of_plot_config.histogramStyle())
        self.assertEqual(plot_config.defaultStyle(), copy_of_plot_config.defaultStyle())
        self.assertEqual(plot_config.currentColor(), copy_of_plot_config.currentColor())

        self.assertEqual(plot_config.getStatisticsStyle("mean"), copy_of_plot_config.getStatisticsStyle("mean"))
        self.assertEqual(plot_config.getStatisticsStyle("min-max"), copy_of_plot_config.getStatisticsStyle("min-max"))
        self.assertEqual(plot_config.getStatisticsStyle("p50"), copy_of_plot_config.getStatisticsStyle("p50"))
        self.assertEqual(plot_config.getStatisticsStyle("p10-p90"), copy_of_plot_config.getStatisticsStyle("p10-p90"))
        self.assertEqual(plot_config.getStatisticsStyle("p33-p67"), copy_of_plot_config.getStatisticsStyle("p33-p67"))
        self.assertEqual(plot_config.getStatisticsStyle("std"), copy_of_plot_config.getStatisticsStyle("std"))

        self.assertEqual(plot_config.title(), copy_of_plot_config.title())

        self.assertEqual(plot_config.limits, copy_of_plot_config.limits)


        plot_config.currentColor()  # cycle state will not be copied
        plot_config.nextColor()

        copy_of_plot_config = PlotConfig(ps, "Another Copy of Golden Sample")
        copy_of_plot_config.copyConfigFrom(plot_config)

        self.assertEqual(plot_config.refcaseStyle(), copy_of_plot_config.refcaseStyle())
        self.assertEqual(plot_config.observationsStyle(), copy_of_plot_config.observationsStyle())

        self.assertNotEqual(plot_config.histogramStyle(), copy_of_plot_config.histogramStyle())
        self.assertNotEqual(plot_config.defaultStyle(), copy_of_plot_config.defaultStyle())
        self.assertNotEqual(plot_config.currentColor(), copy_of_plot_config.currentColor())

        self.assertNotEqual(plot_config.getStatisticsStyle("mean"), copy_of_plot_config.getStatisticsStyle("mean"))
        self.assertNotEqual(plot_config.getStatisticsStyle("min-max"), copy_of_plot_config.getStatisticsStyle("min-max"))
        self.assertNotEqual(plot_config.getStatisticsStyle("p50"), copy_of_plot_config.getStatisticsStyle("p50"))
        self.assertNotEqual(plot_config.getStatisticsStyle("p10-p90"), copy_of_plot_config.getStatisticsStyle("p10-p90"))
        self.assertNotEqual(plot_config.getStatisticsStyle("p33-p67"), copy_of_plot_config.getStatisticsStyle("p33-p67"))
        self.assertNotEqual(plot_config.getStatisticsStyle("std"), copy_of_plot_config.getStatisticsStyle("std"))
Example #5
0
 def test_keys(self):
     ps = PlotSettings()
     keys = ps.keys()
     self.assertFalse("XXX" in keys)
     self.assertTrue("PATH" in keys)
     self.assertTrue("SHOW_REFCASE" in keys)
Example #6
0
 def test_create(self):
     ps = PlotSettings()