예제 #1
0
    def test_font_scale(self):

        notebook_ref = rcmod.plotting_context("notebook")
        notebook_big = rcmod.plotting_context("notebook", 2)

        font_keys = [
            "font.size",
            "axes.labelsize", "axes.titlesize",
            "xtick.labelsize", "ytick.labelsize",
            "legend.fontsize", "legend.title_fontsize",
        ]

        for k in font_keys:
            assert notebook_ref[k] * 2 == notebook_big[k]
예제 #2
0
    def test_context_context_manager(self):

        rcmod.set_context("notebook")
        orig_params = rcmod.plotting_context()
        context_params = rcmod.plotting_context("paper")

        with rcmod.plotting_context("paper"):
            self.assert_rc_params(context_params)
        self.assert_rc_params(orig_params)

        @rcmod.plotting_context("paper")
        def func():
            self.assert_rc_params(context_params)
        func()
        self.assert_rc_params(orig_params)
예제 #3
0
    def test_set_context(self):

        for context in self.contexts:

            context_dict = rcmod.plotting_context(context)
            rcmod.set_context(context)
            self.assert_rc_params(context_dict)
예제 #4
0
    def test_rc_override(self):

        key, val = "grid.linewidth", 5
        rc = {key: val, "foo": "bar"}
        out = rcmod.plotting_context("talk", rc=rc)
        assert out[key] == val
        assert "foo" not in out
예제 #5
0
    def test_bad_context(self):

        with pytest.raises(ValueError):
            rcmod.plotting_context("i_am_not_a_context")
예제 #6
0
    def test_key_usage(self):

        _context_keys = set(rcmod._context_keys)
        for context in self.contexts:
            missing = set(rcmod.plotting_context(context)) ^ _context_keys
            assert not missing
예제 #7
0
    def test_default_return(self):

        current = rcmod.plotting_context()
        self.assert_rc_params(current)