Ejemplo n.º 1
0
    def test_lasso_selection_callback(self, df_type):
        bnac = BaseNonAggregate()
        bnac.x = "a"
        bnac.y = "b"
        bnac.chart_type = "temp"

        def t_function(data, patch_update=False):
            self.result = data

        bnac.reload_chart = t_function
        df = initialize_df(df_type, {"a": [0, 1, 1, 2], "b": [0, 1, 2, 0]})
        dashboard = DashBoard(dataframe=DataFrame.from_dataframe(df))

        geometry = np.array([[1, 1, 2], [1, 2, 1]])

        t = bnac.get_lasso_select_callback(dashboard)
        with mock.patch("cuspatial.point_in_polygon") as pip:
            if isinstance(df, dask_cudf.DataFrame):
                # point in polygon is called per partition,
                # in this case 2 partitions of length 2 each
                pip.return_value = cudf.DataFrame({"selection": [True, False]})
            else:
                pip.return_value = cudf.DataFrame(
                    {"selection": [True, False, True, False]})
            t(geometry)
            assert pip.called
            assert isinstance(self.result, df_type)
Ejemplo n.º 2
0
    def test_get_selection_geometry_callback(self, df_type):
        bnac = BaseNonAggregate()

        df = initialize_df(df_type, {"a": [1, 2, 2], "b": [3, 4, 5]})
        dashboard = DashBoard(dataframe=DataFrame.from_dataframe(df))

        assert callable(type(bnac.get_box_select_callback(dashboard)))
        assert callable(type(bnac.get_lasso_select_callback(dashboard)))