Skip to content

Conversation

@jcheng5
Copy link
Collaborator

@jcheng5 jcheng5 commented Oct 30, 2023

Previously, default width/height value from render.plot (None) was passed to implicit plot output. With this fix, use MISSING as the default parameter value to make it clear that the default value is not set and shouldn't be passed through.

Previously, default width/height value from render.plot (None) was
passed to implicit plot output. With this fix, use MISSING as the
default parameter value to make it clear that the default value is not
set and shouldn't be passed through.
R = TypeVar("R")


def decorator_args_passthrough(
Copy link
Collaborator Author

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.

assert abs(rect["height"] - 200) <= tolerance


def test_decorator_passthrough_size():
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

assert rendered == str(ui.output_plot("foo", width=1280, height=960))


def test_decorator_plot_default():
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

Comment on lines 118 to 119
width: Optional[float] | MISSING_TYPE = MISSING,
height: Optional[float] | MISSING_TYPE = MISSING,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is None still a valid value?

If so, the intent would be clearer with float | None | MISSING_TYPE. Also, do the docs explain what None means?

Suggested change
width: Optional[float] | MISSING_TYPE = MISSING,
height: Optional[float] | MISSING_TYPE = MISSING,
width: float | None | MISSING_TYPE = MISSING,
height: float | None | MISSING_TYPE = MISSING,

If not, take out the Optional.

Suggested change
width: Optional[float] | MISSING_TYPE = MISSING,
height: Optional[float] | MISSING_TYPE = MISSING,
width: float | MISSING_TYPE = MISSING,
height: float | MISSING_TYPE = MISSING,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the difference only matters when you're using the implicit output. None means the implicit output shouldn't have any width/height attribute, MISSING means the implicit output should use its default width/height attribute. I can't really document that until we launch express mode, maybe for now I just say None or MISSING mean the same?

@wch wch self-requested a review October 30, 2023 19:48
@wch wch merged commit 6306632 into main Oct 30, 2023
@wch wch deleted the plot-implicit-default-sizing branch October 30, 2023 19:48
schloerke added a commit that referenced this pull request Nov 2, 2023
* main: (56 commits)
  Add actions step for nightly reporting -> Testrail (#774)
  Remove unused entry in manifest
  Bump version to 0.6.0.9000
  Use latest htmltools
  Bump version to v0.6.0; Rearrange news to have API changes last
  Tweaks from testing
  Fix default width/height with implicit plot output (#792)
  Update deps (#794)
  Remove deprecated 'name' parameter from `Outputs` (#791)
  api(ui): Drop `toggle_` methods. Consolidate update accordion methods. Stronger typing for `layout_sidebar(sidebar)` and `page_sidebar(sidebar)` (#788)
  bug(sidebar): Revert sidebar icon back to chevron (#789)
  For `input_action_button`, default to having whitespace around button (#758)
  Remove output from template app (#775)
  Add output_args and suspend_display decorators (#786)
  Update value_box; Update to bootstrap 5.3; Update htmldeps (#772)
  tests: add sidebar test (#787)
  Seaborn plots should fill their output_plot (#785)
  Kwargs to uvicorn run (#780)
  Add width and height arguments to `@render.plot` (#783)
  gitgnore dist/
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants