Beispiel #1
0
def action_apply_labels(annotator):
    apply_event = ButtonClick(annotator.annotator_apply)
    annotator.annotator_apply._trigger_event(apply_event)
    labeled_slice = annotator.dfs["raw"][
        annotator.dfs["raw"]["label"] != module_config.ABSTAIN_DECODED
    ]
    return labeled_slice
Beispiel #2
0
    def test_labeling(example_raw_df):
        feature = random.choice(MAIN_FEATURES)
        explorer = get_explorer_class("annotator", feature)({"raw": example_raw_df})

        # empty click
        apply_event = ButtonClick(explorer.annotator_apply)
        explorer.annotator_apply._trigger_event(apply_event)

        # test non-cumulative selection
        explorer.sources["raw"].selected.indices = [0]
        explorer._store_selection()
        assert explorer.sources["raw"].selected.indices == [0]
        explorer.sources["raw"].selected.indices = [1]
        explorer._store_selection()
        assert explorer.sources["raw"].selected.indices == [1]

        # test cumulative selection
        explorer.selection_option_box.active = [0]
        explorer.sources["raw"].selected.indices = [0]
        explorer._store_selection()
        assert explorer.sources["raw"].selected.indices == [0, 1]

        # actual labeling
        explorer.annotator_input.value = "A"
        explorer.annotator_apply._trigger_event(apply_event)
Beispiel #3
0
 def test_notify_event(self) -> None:
     d = Document()
     cm = bdc.DocumentCallbackManager(d)
     reported_curdoc = None
     reported_foo = None
     def invoker() -> None:
         nonlocal reported_curdoc
         nonlocal reported_foo
         reported_curdoc = curdoc()
         reported_foo = 10
     m = Button()
     cm.notify_event(m, ButtonClick(m), invoker)
     assert reported_curdoc is d
     assert reported_foo == 10
Beispiel #4
0
def test_button_event(document, comm):
    button = Button(name='Button')

    widget = button.get_root(document, comm=comm)

    events = []

    def callback(event):
        events.append(event.new)

    button.param.watch(callback, 'value')

    assert button.value == False
    button._process_event(ButtonClick(widget))
    assert events == [True]
    assert button.value == False
Beispiel #5
0
def action_view_selection(dataset):
    view_event = ButtonClick(dataset.selection_viewer)
    dataset.selection_viewer._trigger_event(view_event)
    # dataset.sel_table.source.data is a {"field": []}-like dict
    view_data = dataset.sel_table.source.data
    return view_data
Beispiel #6
0
def action_push_data(dataset):
    push_event = ButtonClick(dataset.update_pusher)
    dataset.update_pusher._trigger_event(push_event)
Beispiel #7
0
def action_deduplicate(dataset):
    dedup_event = ButtonClick(dataset.dedup_trigger)
    dataset.dedup_trigger._trigger_event(dedup_event)
    return dataset