def test_update_dimensions(self, width, height, result1, result2):
        vd = ViewDataFrame()
        vd.initiate_chart(self.dashboard)
        vd.width, vd.height = 400, 400
        vd.update_dimensions(width=width, height=height)

        assert vd.chart.width == result1
        assert vd.chart.height == result2
Exemple #2
0
    def test_initiate_chart(self, dashboard):
        vd = ViewDataFrame()
        assert vd.columns is None

        vd.initiate_chart(dashboard)

        assert str(vd.chart) == str(
            pn.pane.HTML(
                dashboard._cuxfilter_df.data,
                css_classes=["panel-df"],
                style={
                    "width": "100%",
                    "height": "100%",
                    "overflow-y": "auto",
                    "font-size": "0.5vw",
                    "overflow-x": "auto",
                },
            ))
        assert vd.columns == list(dashboard._cuxfilter_df.data.columns)
    def test_variables(self):
        vd = ViewDataFrame()

        vd.columns is None
        vd._width == 400
        vd._height == 400
        vd.use_data_tiles is False
        vd.source is None
        vd.chart is None
        vd.drop_duplicates is False
Exemple #4
0
    def test_initiate_chart(self):
        vd = ViewDataFrame()
        assert vd.columns is None

        vd.initiate_chart(self.dashboard)

        assert str(vd.chart.objects[0]) == str(
            pn.pane.HTML(
                self.df,
                style={
                    "width": "100%",
                    "height": "100%",
                    "overflow-y": "auto",
                    "font-size": "0.5vw",
                    "overflow-x": "auto",
                },
            ))
        assert vd.chart.sizing_mode == "scale_both"
        assert vd.columns == list(self.df.columns)
Exemple #5
0
    def test_variables(self):
        vd = ViewDataFrame()

        vd.chart_type == "view_dataframe"
        vd.columns is None
        vd._width == 400
        vd._height == 400
        vd.use_data_tiles is False
        vd.source is None
        vd.chart is None
        vd.name == "view_dataframe"
    def test_query_chart_by_indices(self, new_indices, result):
        bsl = ViewDataFrame()
        bsl_1 = BaseStackedLine("b", ["a"])
        new_indices = new_indices
        df = cudf.DataFrame({"a": [1, 2, 3, 4], "b": [3, 4, 5, 6]})
        bsl.source = df
        self.result = None
        self.patch_update = None

        def t_func(data, patch_update):
            self.result = data
            self.patch_update = patch_update

        # creating a dummy reload chart fn as its not implemented in core
        # non aggregate chart class
        bsl.reload_chart = t_func
        bsl.query_chart_by_indices(
            active_chart=bsl_1,
            old_indices=[],
            new_indices=new_indices,
            data=df,
        )

        assert self.result.to_string() == result
        assert self.patch_update is False
Exemple #7
0
    def test_query_chart_by_range(self, df_type):
        bsl = ViewDataFrame()
        bsl_1 = BaseStackedLine("b", ["a"])
        query_tuple = (4, 5)
        df = initialize_df(df_type, {"a": [1, 2, 3, 4], "b": [3, 4, 5, 6]})
        bsl.source = df
        self.result = None
        self.patch_update = None

        def t_func(data, patch_update):
            self.result = data
            self.patch_update = patch_update

        # creating a dummy reload chart fn as its not implemented in core
        # non aggregate chart class
        bsl.reload_chart = t_func
        bsl.query_chart_by_range(active_chart=bsl_1,
                                 query_tuple=query_tuple,
                                 data=df)

        assert df_equals(
            self.result,
            initialize_df(df_type, {
                "a": [2, 3],
                "b": [4, 5]
            }, [1, 2]),
        )
        assert self.patch_update is False
Exemple #8
0
    def test_query_chart_by_indices(self, df_type, new_indices, result, index):
        bsl = ViewDataFrame()
        bsl_1 = BaseStackedLine("b", ["a"])
        new_indices = new_indices
        df = initialize_df(df_type, {"a": [1, 2, 3, 4], "b": [3, 4, 5, 6]})
        bsl.source = df
        self.result = None
        self.patch_update = None

        def t_func(data, patch_update):
            self.result = data
            self.patch_update = patch_update

        # creating a dummy reload chart fn as its not implemented in core
        # non aggregate chart class
        bsl.reload_chart = t_func
        bsl.query_chart_by_indices(
            active_chart=bsl_1,
            old_indices=[],
            new_indices=new_indices,
            data=df,
        )
        result = initialize_df(df_type, result, index)

        assert df_equals(self.result, result)
        assert self.patch_update is False
Exemple #9
0
    def test_reload_chart(self, drop_duplicates):
        vd = ViewDataFrame()
        vd.drop_duplicates = drop_duplicates
        vd.initiate_chart(self.dashboard)

        vd.reload_chart(self.df_duplicates, patch_update=False)

        if drop_duplicates:
            assert vd.chart[0].object.equals(
                self.df_duplicates.drop_duplicates())
        else:
            assert vd.chart[0].object.equals(self.df_duplicates)
Exemple #10
0
    def test_reload_chart(self, dashboard, df_duplicate, drop_duplicates):
        vd = ViewDataFrame(drop_duplicates=drop_duplicates)
        vd.initiate_chart(dashboard)

        vd.reload_chart(df_duplicate, patch_update=False)

        if drop_duplicates:
            assert df_equals(vd.chart[0].object,
                             df_duplicate.drop_duplicates())
        else:
            assert df_equals(vd.chart[0].object, df_duplicate)
    def test_query_chart_by_range(self):
        bsl = ViewDataFrame()
        bsl_1 = BaseStackedLine("b", ["a"])
        query_tuple = (4, 5)
        df = cudf.DataFrame({"a": [1, 2, 3, 4], "b": [3, 4, 5, 6]})
        bsl.source = df
        self.result = None
        self.patch_update = None

        def t_func(data, patch_update):
            self.result = data
            self.patch_update = patch_update

        # creating a dummy reload chart fn as its not implemented in core
        # non aggregate chart class
        bsl.reload_chart = t_func
        bsl.query_chart_by_range(
            active_chart=bsl_1, query_tuple=query_tuple, data=df
        )

        assert self.result.to_string() == "   a  b\n1  2  4\n2  3  5"
        assert self.patch_update is False
    def test_view(self, chart, _chart):
        vd = ViewDataFrame()
        vd.chart = chart

        assert str(vd.view()) == str(chart_view(_chart, width=vd.width))
Exemple #13
0
    def test_reload_chart(self):
        vd = ViewDataFrame()
        vd.initiate_chart(self.dashboard)
        vd.reload_chart(self.df, patch_update=False)

        assert vd.chart[0].object.equals(self.df)
Exemple #14
0
    def test_view(self, chart, _chart):
        vd = ViewDataFrame()
        vd.chart = chart

        assert vd.view() == _chart