def test_add_range_slider_filter(self): bb = BaseBar(x="key") bb.min_value = self.dashboard._data[bb.x].min() bb.max_value = self.dashboard._data[bb.x].max() if bb.data_points > self.dashboard._data[bb.x].shape[0]: bb.data_points = self.dashboard._data[bb.x].shape[0] bb.add_range_slider_filter(self.dashboard) assert type(bb.filter_widget) == pn.widgets.RangeSlider assert bb.filter_widget.value == (0, 4)
def test_compute_query_dict(self, range, query): bb = BaseBar(x="key") bb.min_value = self.dashboard._data[bb.x].min() bb.max_value = self.dashboard._data[bb.x].max() if bb.data_points > self.dashboard._data[bb.x].shape[0]: bb.data_points = self.dashboard._data[bb.x].shape[0] bb.add_range_slider_filter(self.dashboard) self.dashboard.add_charts([bb]) bb.filter_widget.value = range # test the following function behavior bb.compute_query_dict(self.dashboard._query_str_dict) assert self.dashboard._query_str_dict["key_bar"] == query
def test_query_chart_by_range(self, query_tuple, result): dashboard = self.cux_df.dashboard(charts=[]) active_chart = BaseBar(x="key") active_chart.stride = 1 active_chart.min_value = 0 bdsi = dashboard._charts["_datasize_indicator"] self.result = "" def reset_chart(datatile_result): self.result = datatile_result bdsi.reset_chart = reset_chart datatile = pd.DataFrame({0: {0: 1.0, 1: 2.0, 2: 3.0, 3: 4.0, 4: 5.0}}) bdsi.query_chart_by_range(active_chart, query_tuple, datatile) assert result == self.result
def test_query_chart_by_indices(self, old_indices, new_indices, prev_value, result): active_chart = BaseBar(x="key") active_chart.stride = 1 active_chart.min_value = 0 self.result = "" dashboard = self.cux_df.dashboard(charts=[active_chart]) dashboard._active_view = active_chart.name dashboard._calc_data_tiles(cumsum=False) bdsi = dashboard._charts["_datasize_indicator"] bdsi.chart.value = prev_value def reset_chart(datatile_result): self.result = datatile_result bdsi.reset_chart = reset_chart datatile = pd.DataFrame({0: {0: 1.0, 1: 1.0, 2: 1.0, 3: 1.0, 4: 1.0}}) bdsi.query_chart_by_indices(active_chart, old_indices, new_indices, datatile) assert result == self.result