Supplies control elements for dashboards
INFO     - The mmdet config folder already exists. No need to downloaded it. Path : /home/frederik/.icevision/mmdetection_configs/mmdetection_configs-2.16.0/configs | icevision.models.mmdet.download_configs:download_mmdet_configs:17

class Filter[source]

Filter(data, width=500, height=500)

Abstract base class for filters.

Abstract baseclass for a filter. A filter requires three methods to be implemented

  1. build_gui: Defines the gui elements of the filter (slider, checkboxes etc.)
  2. get_selection: Returns a binary mask indicating which elements of the data are selected and which not
  3. show: Returns the gui of the filter
  4. register_callback: Handels the registration of callbacks. This function should contain the following line callback = self.maks_callback(callback) to ensure that the callback receives the current selection of the filter instead of an event or attr, old and new

All callbacks registered to a filter will receive the current selection of the fitler as argument. To ensure this behaviour inside the register_callback function the callback needs to be masked with the mask_callback method. If a different behaviour is need it should be sufficient to change the mask_callback method.

class RangeFilter[source]

RangeFilter(data:ndarray, name:str, bins:int=20, steps:int=50, with_hist:bool=True, width:int=500, height:int=500) :: Filter

Abstract base class for filters.

A filter that uses a range slider for selection. Best used for continuous values.

def test_callback(selection):
    if not isinstance(selection, np.ndarray):
        raise ValueError("Selection should be array")
data = np.array([0, 10, 1, 2, 3, 6, 7])
test_range_filter = RangeFilter(data, "Values", width=600)
test_range_filter.register_callback(test_callback)
display(test_range_filter.show())
test_range_filter.update_with_mask(data<6)
test_range_filter.update_self(None)
test_range_filter.get_selection()

class CategoricalFilter[source]

CategoricalFilter(data:ndarray, name:str, width:int=500, height:int=500) :: Filter

A multi select based filter for categorical data

A filter for categorical data.

test_categorical_filter = CategoricalFilter(np.array(["a", "b", "c", "d"]), "test_filter", height=100)
test_categorical_filter.get_selection()
test_categorical_filter.register_callback(lambda x: None)
test_categorical_filter.show()

class TimeFilter[source]

TimeFilter(start_times:Iterable[datetime], end_times:Iterable[datetime], start_time_label:str='Start', end_time_label:str='End', width:int=500, height:int=500) :: Filter

A filter for time data with a start and an end date

This filter is for time information with a start and an end date. It has two range selectors one for the selection of the start time and one for the end time. The start and end time of a data point are represented by an arc plot.

def test_callback(selection):
    if not isinstance(selection, np.ndarray):
        raise ValueError("Selection should be array")
test_start_times = np.array([datetime.datetime(2020, 1, 1) + datetime.timedelta(days=i) for i in range(10)])
test_end_times = np.array([datetime.datetime(2020, 3, 1) + datetime.timedelta(days=i) for i in range(10)])
test_time_filter = TimeFilter(test_start_times, test_end_times)
test_time_filter.end_time_slider.value = (test_end_times[-4], test_end_times[-1]+datetime.timedelta(1))
assert test_time_filter.get_selection().sum() == 3
test_time_filter.register_callback(test_callback)
test_time_filter.show()

class ScatterFilter[source]

ScatterFilter(x, y, x_label:str='', y_label:str='', width:int=500, height:int=500) :: Filter

A filter based on a scatter plot with a lasso selection.

scatter_select = ScatterFilter([1,2,3], [1,3,1])
scatter_select.register_callback(lambda x: None)
scatter_select.get_selection()
scatter_select.show()

class GenericMulitScatterFilter[source]

GenericMulitScatterFilter(data, columns:Optional[List[str]]=None, mode:str='symmetric', width:int=500, height:int=500) :: Filter

A generic filter base on the scatter plot filter, that provides additional inputs for column selection and how the selections over the different columns should be combined.

test_multi_scatter_filter = GenericMulitScatterFilter(pd.DataFrame({"x": [1,2,3,4,5,6,7,8], "y": [1,1,3,5,5,5,2,4]}))
test_multi_scatter_filter.get_selection()
test_multi_scatter_filter.register_callback(lambda x: None)
test_multi_scatter_filter.update_selection(None, None, [1,2,3])
test_multi_scatter_filter.show()
test_multi_scatter_filter = GenericMulitScatterFilter(pd.DataFrame({"x": [1,2,3,4,5,6,7,8], "y": [1,1,3,5,5,5,2,4]}))
test_multi_scatter_filter.combine_selections.value = "Or"
test_multi_scatter_filter.get_selection()
test_multi_scatter_filter.mode = "symmetric"
test_multi_scatter_filter.update_selection(None, None, [1,2,3])
test_multi_scatter_filter.show()
test_multi_scatter_filter = GenericMulitScatterFilter(pd.DataFrame({"x": [1,2,3,4,5,6,7,8], "y": [1,1,3,5,5,5,2,4]}))
test_multi_scatter_filter.combine_selections.value = "And"
test_multi_scatter_filter.get_selection()
test_multi_scatter_filter.show()