def test_query_chart_by_indices(self, new_indices, result): bg = BaseGraph() bg.chart_type = "test" bg.x = "a" bg_1 = BaseGraph() bg_1.chart_type = "test" bg_1.x = "b" new_indices = new_indices df = cudf.DataFrame({"a": [1, 2, 3, 4], "b": [3, 4, 5, 6]}) bg.nodes = df self.result = None def t_func(data): self.result = data # creating a dummy reload chart fn as its not implemented in core # non aggregate chart class bg.reload_chart = t_func bg.query_chart_by_indices( active_chart=bg_1, old_indices=[], new_indices=new_indices, datatile=None, ) assert self.result.to_string() == result
def test_query_chart_by_range(self): bg = BaseGraph() bg.chart_type = "test" bg.x = "a" bg_1 = BaseGraph() bg_1.chart_type = "test" bg_1.x = "b" query_tuple = (4, 5) df = cudf.DataFrame({"a": [1, 2, 3, 4], "b": [3, 4, 5, 6]}) bg.nodes = df self.result = None def t_func(data): self.result = data # creating a dummy reload chart fn as its not implemented in core # non aggregate chart class bg.reload_chart = t_func bg.query_chart_by_range(active_chart=bg_1, query_tuple=query_tuple, datatile=None) assert self.result.to_string() == " a b\n1 2 4\n2 3 5"
def test_query_chart_by_indices(self, df_type, new_indices, result, index): bg = BaseGraph() bg.chart_type = "test" bg.x = "a" bg_1 = BaseGraph() bg_1.chart_type = "test" bg_1.x = "b" new_indices = new_indices df = initialize_df(df_type, {"a": [1, 2, 3, 4], "b": [3, 4, 5, 6]}) bg.nodes = df self.result = None def t_func(data): self.result = data # creating a dummy reload chart fn as its not implemented in core # non aggregate chart class bg.reload_chart = t_func bg.query_chart_by_indices( active_chart=bg_1, old_indices=[], new_indices=new_indices, datatile=None, ) result = initialize_df(df_type, result, index) assert df_equals(self.result, result)
def test_query_chart_by_range(self, df_type): bg = BaseGraph() bg.chart_type = "test" bg.x = "a" bg_1 = BaseGraph() bg_1.chart_type = "test" bg_1.x = "b" query_tuple = (4, 5) df = initialize_df(df_type, {"a": [1, 2, 3, 4], "b": [3, 4, 5, 6]}) bg.nodes = df self.result = None def t_func(data): self.result = data # creating a dummy reload chart fn as its not implemented in core # non aggregate chart class bg.reload_chart = t_func bg.query_chart_by_range( active_chart=bg_1, query_tuple=query_tuple, datatile=None ) assert df_equals( self.result, initialize_df(df_type, {"a": [2, 3], "b": [4, 5]}, [1, 2]), )
def test_add_reset_event(self): bg = BaseGraph() bg.edges = None bg.chart_type = "test" bg.x = "a" bg.x_range = (0, 2) bg.y_range = (3, 5) df = cudf.DataFrame({"a": [1, 2, 2], "b": [3, 4, 5]}) dashboard = DashBoard(dataframe=DataFrame.from_dataframe(df)) dashboard._active_view = "a_test" def t_func1(event, fn): fn("event") def reload_fn(nodes, edges=None, patch_update=False): pass bg.add_event = t_func1 bg.reload_chart = reload_fn bg.add_reset_event(dashboard) assert bg.x_range is None assert bg.y_range is None assert dashboard._active_view == "a_test"
def test_add_reset_event(self, df_type): bg = BaseGraph() bg.edges = None bg.chart_type = "test" bg.x = "a" bg.x_range = (0, 2) bg.y_range = (3, 5) bg.chart = hv.InteractiveDatashader() df = initialize_df(df_type, {"a": [1, 2, 2], "b": [3, 4, 5]}) dashboard = DashBoard(dataframe=DataFrame.from_dataframe(df)) dashboard._active_view = bg def t_func1(event, fn): fn("event") def reload_fn(data, edges=None, patch_update=False): pass bg.add_event = t_func1 bg.reload_chart = reload_fn bg.add_reset_event(dashboard) assert bg.selected_indices is None