From 24cc3ff9d9f9f50461ee43cf071ea62357615b64 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Fri, 11 Oct 2024 11:02:55 -0400 Subject: [PATCH 1/3] lowercase `Pandas` to `pandas` --- examples/penguins/app.py | 2 +- examples/static_plots/app.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/penguins/app.py b/examples/penguins/app.py index 378f49cea..22c370508 100644 --- a/examples/penguins/app.py +++ b/examples/penguins/app.py @@ -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) diff --git a/examples/static_plots/app.py b/examples/static_plots/app.py index b5c928169..7f17fb460 100644 --- a/examples/static_plots/app.py +++ b/examples/static_plots/app.py @@ -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")), From da12162382a6894fc69b999a1e2890041169e8b6 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Fri, 11 Oct 2024 11:03:16 -0400 Subject: [PATCH 2/3] Shuffle code for consistent variable names --- shiny/render/_render.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shiny/render/_render.py b/shiny/render/_render.py index feda9b03f..b3513db4b 100644 --- a/shiny/render/_render.py +++ b/shiny/render/_render.py @@ -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 @@ -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 = ( From f645670b4a4f5089513a41a1a581d053bdcd17b4 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Fri, 11 Oct 2024 11:13:56 -0400 Subject: [PATCH 3/3] Cosmetic --- shiny/render/_data_frame.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/shiny/render/_data_frame.py b/shiny/render/_data_frame.py index c8085c32e..b70534c1c 100644 --- a/shiny/render/_data_frame.py +++ b/shiny/render/_data_frame.py @@ -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 @@ -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, },