-
Notifications
You must be signed in to change notification settings - Fork 117
Fix default width/height with implicit plot output #792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,16 +52,3 @@ def test_output_image_kitchen(page: Page, local_app: ShinyAppProc) -> None: | |
| tolerance += 2 | ||
| assert abs(rect["width"] - 300) <= tolerance | ||
| assert abs(rect["height"] - 200) <= tolerance | ||
|
|
||
|
|
||
| def test_decorator_passthrough_size(): | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved this from e2e test to regular pytest, since it didn't actually use any playwright logic. |
||
| """Make sure that render.plot width/height are passed through to implicit output""" | ||
| from shiny import render | ||
|
|
||
| @render.plot(width=1280, height=960) | ||
| def foo(): | ||
| ... | ||
|
|
||
| rendered = str(foo.tagify()) | ||
| assert "1280px" in rendered | ||
| assert "960px" in rendered | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| from shiny import render, ui | ||
| from shiny.express import output_args | ||
| from shiny.types import MISSING | ||
|
|
||
|
|
||
| def test_decorator_plot_sizing(): | ||
| """render.plot width/height are passed through to implicit output""" | ||
|
|
||
| @render.plot(width=1280, height=960) | ||
| def foo(): | ||
| ... | ||
|
|
||
| rendered = str(foo.tagify()) | ||
| assert "1280px" in rendered | ||
| assert "960px" in rendered | ||
| assert rendered == str(ui.output_plot("foo", width=1280, height=960)) | ||
|
|
||
|
|
||
| def test_decorator_plot_default(): | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the test case that reflects the issue the PR is meant to fix. |
||
| """render.plot default is the same as ui.output_plot default""" | ||
|
|
||
| @render.plot() | ||
| def foo(): | ||
| ... | ||
|
|
||
| rendered = str(foo.tagify()) | ||
| assert rendered == str(ui.output_plot("foo")) | ||
|
|
||
|
|
||
| def test_decorator_output_args(): | ||
| """@output_args is respected""" | ||
|
|
||
| @output_args(width="640px", height="480px") | ||
| @render.plot() | ||
| def foo(): | ||
| ... | ||
|
|
||
| rendered = str(foo.tagify()) | ||
| assert rendered == str(ui.output_plot("foo", width="640px", height="480px")) | ||
|
|
||
|
|
||
| def test_decorator_output_args_priority(): | ||
| """@output_args should override render.plot width/height""" | ||
|
|
||
| @output_args(width="640px", height=480) | ||
| @render.plot(width=1280, height=960) | ||
| def foo(): | ||
| ... | ||
|
|
||
| rendered = str(foo.tagify()) | ||
| # Note "640px" => 640 and 480 => "480px" | ||
| assert rendered == str(ui.output_plot("foo", width=640, height="480px")) | ||
|
|
||
|
|
||
| def test_decorator_output_args_MISSING(): | ||
| """Not saying we support this, but test how MISSING interacts""" | ||
|
|
||
| @output_args(width=MISSING) | ||
| @render.plot(width=1280, height=MISSING) | ||
| def foo(): | ||
| ... | ||
|
|
||
| rendered = str(foo.tagify()) | ||
| assert rendered == str(ui.output_plot("foo", width="1280px")) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an unused function, from an older implementation that I moved away from after @wch code review feedback.