Skip to content

Commit

Permalink
Merge branch 'handle-value-setter' into value-as-fields
Browse files Browse the repository at this point in the history
  • Loading branch information
YooSunYoung authored Dec 12, 2024
2 parents 27b7b8a + 8970630 commit 18b2eb1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ess/reduce/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def run_workflow(_: widgets.Button) -> None:
result_registry.clear()
result_registry.update(compute_result)
for i in compute_result.values():
display.display(display.HTML(i._repr_html_()))
display.display(i)

def clear_output(_: widgets.Button) -> None:
self.output.clear_output()
Expand Down
23 changes: 22 additions & 1 deletion tests/widget_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from contextlib import contextmanager
from typing import Any, NewType

import pytest
import sciline as sl
import scipp as sc
from ipywidgets import FloatText, IntText
Expand All @@ -14,7 +15,7 @@
Vector3dParameter,
parameter_registry,
)
from ess.reduce.ui import WorkflowWidget, workflow_widget
from ess.reduce.ui import ResultBox, WorkflowWidget, workflow_widget
from ess.reduce.widgets import OptionalWidget, SwitchWidget, create_parameter_widget
from ess.reduce.widgets._base import WidgetWithFieldsProtocol, get_fields, set_fields
from ess.reduce.workflow import register_workflow, workflow_registry
Expand Down Expand Up @@ -446,3 +447,23 @@ def test_bin_edges_widget_with_default_values() -> None:
assert param_widget.fields['stop'].value == 0.6
assert param_widget.fields['nbins'].value == 150
assert param_widget.fields['spacing'].value == 'linear'


@pytest.mark.parametrize(
'output',
[
(sc.scalar(1), sc.scalar(2)),
'Test with a string',
sc.data.binned_xy(100, 10, 10),
],
)
def test_result_box_can_handle_different_outputs(output):
was_called = False

def run_workflow():
nonlocal was_called
was_called = True
return dict(enumerate(output))

ResultBox(run_workflow).run_button.click()
assert was_called

0 comments on commit 18b2eb1

Please sign in to comment.