def test_get_selection_geometry_callback(self, df_type): bg = BaseGraph() df = initialize_df(df_type, {"a": [1, 2, 2], "b": [3, 4, 5]}) dashboard = DashBoard(dataframe=DataFrame.from_dataframe(df)) assert callable(type(bg.get_box_select_callback(dashboard))) assert callable(type(bg.get_lasso_select_callback(dashboard)))
def test_lasso_selection_callback(self, df_type): nodes = initialize_df( df_type, {"vertex": [0, 1, 2, 3], "x": [0, 1, 1, 2], "y": [0, 1, 2, 0]}, ) edges = initialize_df( df_type, {"source": [1, 1, 1, 1], "target": [0, 1, 2, 3]} ) dashboard = DashBoard(dataframe=DataFrame.load_graph((nodes, edges))) bg = BaseGraph() bg.chart_type = "temp" bg.nodes = nodes bg.edges = edges bg.inspect_neighbors = CustomInspectTool(_active=False) def t_function(data, edges=None, patch_update=False): self.result = data bg.reload_chart = t_function geometry = np.array([[1, 1, 2], [1, 2, 1]]) t = bg.get_lasso_select_callback(dashboard) with mock.patch("cuspatial.point_in_polygon") as pip: if isinstance(nodes, 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)