Beispiel #1
0
    def test_establish_symbols_text_true(self):
        from cupcake.smush.base import SmushPlotterBase

        symbol_kws = self.symbol_kws.copy()
        symbol_kws['text'] = True

        p = SmushPlotterBase()
        p.establish_variables(self.data)
        p.establish_symbols(**symbol_kws)

        pdt.assert_series_equal(p.symbol,
                                pd.Series(map(str, list(range(self.nrow))),
                                          index=self.data.index))
        assert p.text
Beispiel #2
0
    def test_establish_symbols_defaults(self):
        from cupcake.smush.base import SmushPlotterBase

        p = SmushPlotterBase()
        p.establish_variables(self.data)
        p.establish_symbols(**self.symbol_kws)

        pdt.assert_series_equal(p.symbol, pd.Series(['o']*self.nrow,
                                                    index=self.data.index))
        pdt.assert_series_equal(p.linewidth, pd.Series([1]*self.nrow,
                                                       index=self.data.index))
        pdt.assert_series_equal(p.edgecolor, pd.Series(['k']*self.nrow,
                                                       index=self.data.index))
        assert not p.text
Beispiel #3
0
    def test_establish_symbols_text_true(self):
        from cupcake.smush.base import SmushPlotterBase

        symbol_kws = self.symbol_kws.copy()
        symbol_kws['text'] = True

        p = SmushPlotterBase()
        p.establish_variables(self.data)
        p.establish_symbols(**symbol_kws)

        pdt.assert_series_equal(
            p.symbol,
            pd.Series(map(str, list(range(self.nrow))), index=self.data.index))
        assert p.text
Beispiel #4
0
    def test_establish_symbols_defaults(self):
        from cupcake.smush.base import SmushPlotterBase

        p = SmushPlotterBase()
        p.establish_variables(self.data)
        p.establish_symbols(**self.symbol_kws)

        pdt.assert_series_equal(
            p.symbol, pd.Series(['o'] * self.nrow, index=self.data.index))
        pdt.assert_series_equal(
            p.linewidth, pd.Series([1] * self.nrow, index=self.data.index))
        pdt.assert_series_equal(
            p.edgecolor, pd.Series(['k'] * self.nrow, index=self.data.index))
        assert not p.text
Beispiel #5
0
    def test_establish_symbols_text_series_ordered(self):
        from cupcake.smush.base import SmushPlotterBase

        symbol_kws = self.symbol_kws.copy()
        symbol_kws['text'] = self.groupby
        symbol_kws['text_order'] = self.order

        p = SmushPlotterBase()
        p.establish_variables(self.data)
        p.establish_symbols(**symbol_kws)

        symbol = pd.Series(pd.Categorical(self.groupby, ordered=True,
                                categories=self.order), index=self.data.index)
        pdt.assert_series_equal(p.symbol, symbol)
        assert p.text
Beispiel #6
0
    def test_establish_symbols_text_series_not_str(self):
        from cupcake.smush.base import SmushPlotterBase

        half = int(self.nrow/2.)
        text = pd.Series(([1] * half) + ([2] * half)).map(str)

        symbol_kws = self.symbol_kws.copy()
        symbol_kws['text'] = text

        p = SmushPlotterBase()
        p.establish_variables(self.data)
        p.establish_symbols(**symbol_kws)

        symbol = pd.Series(pd.Categorical(text, ordered=True,
                                categories=['1', '2']), index=self.data.index)
        pdt.assert_series_equal(p.symbol, symbol)
        assert p.text
Beispiel #7
0
    def test_establish_symbols_text_series_ordered(self):
        from cupcake.smush.base import SmushPlotterBase

        symbol_kws = self.symbol_kws.copy()
        symbol_kws['text'] = self.groupby
        symbol_kws['text_order'] = self.order

        p = SmushPlotterBase()
        p.establish_variables(self.data)
        p.establish_symbols(**symbol_kws)

        symbol = pd.Series(pd.Categorical(self.groupby,
                                          ordered=True,
                                          categories=self.order),
                           index=self.data.index)
        pdt.assert_series_equal(p.symbol, symbol)
        assert p.text
Beispiel #8
0
    def test_establish_symbols_text_series_not_str(self):
        from cupcake.smush.base import SmushPlotterBase

        half = int(self.nrow / 2.)
        text = pd.Series(([1] * half) + ([2] * half)).map(str)

        symbol_kws = self.symbol_kws.copy()
        symbol_kws['text'] = text

        p = SmushPlotterBase()
        p.establish_variables(self.data)
        p.establish_symbols(**symbol_kws)

        symbol = pd.Series(pd.Categorical(text,
                                          ordered=True,
                                          categories=['1', '2']),
                           index=self.data.index)
        pdt.assert_series_equal(p.symbol, symbol)
        assert p.text