Skip to content

Commit

Permalink
chore: Cosmetic code changes (#1734)
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke authored Oct 11, 2024
1 parent e88bec4 commit c1949dd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/penguins/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
def server(input: Inputs, output: Outputs, session: Session):
@reactive.calc
def filtered_df() -> pd.DataFrame:
"""Returns a Pandas data frame that includes only the desired rows"""
"""Returns a pandas data frame that includes only the desired rows"""

# This calculation "req"uires that at least one species is selected
req(len(input.species()) > 0)
Expand Down
2 changes: 1 addition & 1 deletion examples/static_plots/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
ui.input_slider("cov", "Co-variance", min=0, max=1, value=0.4),
),
),
ui.nav_panel("Pandas", ui.output_plot("pandas")),
ui.nav_panel("pandas", ui.output_plot("pandas")),
ui.nav_panel("Holoviews", ui.output_plot("holoviews", height="600px")),
ui.nav_panel("xarray", ui.output_plot("xarray")),
ui.nav_panel("geopandas", ui.output_plot("geopandas")),
Expand Down
10 changes: 6 additions & 4 deletions shiny/render/_data_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,9 @@ def data_view_rows(self) -> tuple[int, ...]:
The row numbers of the data frame that are currently being viewed in the browser
after sorting and filtering has been applied.
"""
id_data_view_rows = f"{self.output_id}_data_view_rows"
input_data_view_rows = self._get_session().input[id_data_view_rows]()
input_data_view_rows = self._get_session().input[
f"{self.output_id}_data_view_rows"
]()
return tuple(input_data_view_rows)

# @reactive_calc_method
Expand Down Expand Up @@ -1015,11 +1016,12 @@ async def render(self) -> JsonifiableDict | None:
async def _send_message_to_browser(self, handler: str, obj: dict[str, Any]):

session = self._get_session()
id = session.ns(self.output_id)
await session.send_custom_message(
"shinyDataFrameMessage",
{
"id": id,
# Custom message handlers are never namespaced for modules.
# Must provide a unique name to avoid conflicts between modules.
"id": session.ns(self.output_id),
"handler": handler,
"obj": obj,
},
Expand Down
7 changes: 4 additions & 3 deletions shiny/render/_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,9 @@ def __init__(

async def render(self) -> dict[str, Jsonifiable] | Jsonifiable | None:
is_userfn_async = self.fn.is_async()
name = self.output_id
session = require_active_session(None)
# Module support
name = session.ns(name)
output_name = session.ns(self.output_id)
width = self.width
height = self.height
alt = self.alt
Expand All @@ -296,7 +295,9 @@ async def render(self) -> dict[str, Jsonifiable] | Jsonifiable | None:
# you're asking for. It takes a reactive dependency. If the client hasn't reported
# the requested dimension, you'll get a SilentException.
def container_size(dimension: Literal["width", "height"]) -> float:
result = inputs[ResolvedId(f".clientdata_output_{name}_{dimension}")]()
result = inputs[
ResolvedId(f".clientdata_output_{output_name}_{dimension}")
]()
return typing.cast(float, result)

non_missing_size = (
Expand Down

0 comments on commit c1949dd

Please sign in to comment.