Loading poetry.lock +791 −632 File changed.Preview size limit exceeded, changes collapsed. Show changes pyproject.toml +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ packages = [{include = "nova", from = "src"}] altair = "*" libsass = "*" mergedeep = "*" mpld3 = "^0.5.11" python = ">=3.10,<4.0" tomli = "*" tornado = ">=6.5.0" Loading src/nova/trame/_internal/utils.py +8 −1 Original line number Diff line number Diff line Loading @@ -7,6 +7,13 @@ from trame_server.core import State from nova.mvvm._internal.utils import rgetdictvalue, rsetdictvalue # Trame state handlers don't work on nested properties. When writing Trame state handlers (e.g. flushState, dirty, or # change), we instead use the name of the top-level property. For example, "config.parameter_group_a.option_x" becomes # "config". def get_state_name(name: str) -> str: return name.split(".")[0] # Reads a state parameter from Trame. For internal use only, if you're using this in your application you're violating # the MVVM framework. :) def get_state_param(state: State, value: Union[Any, Tuple]) -> Any: Loading @@ -25,6 +32,6 @@ def set_state_param(state: State, value: Union[Any, Tuple], new_value: Any = Non rsetdictvalue(state, value[0], new_value) elif len(value) > 1: rsetdictvalue(state, value[0], value[1]) state.dirty(value[0].split(".")[0]) state.dirty(get_state_name(value[0])) return get_state_param(state, value) src/nova/trame/view/components/visualization/interactive_2d_plot.py +4 −2 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ class Interactive2DPlot(vega.Figure): Parameters ---------- figure : `altair.Chart <https://altair-viz.github.io/user_guide/generated/toplevel/altair.Chart.html#altair.Chart>`_ figure : `altair.Chart <https://altair-viz.github.io/user_guide/generated/toplevel/altair.Chart.html#altair.Chart>`__, optional Altair chart object kwargs Arguments to be passed to `AbstractElement <https://trame.readthedocs.io/en/latest/core.widget.html#trame_client.widgets.core.AbstractElement>`_ Loading @@ -38,7 +38,7 @@ class Interactive2DPlot(vega.Figure): Returns ------- None """ """ # noqa: E501 self._initialized = False super().__init__(figure=figure, **kwargs) Loading Loading @@ -83,3 +83,5 @@ class Interactive2DPlot(vega.Figure): if hasattr(self, "_start_update_handlers"): self._start_update_handlers() self.server.state.flush() src/nova/trame/view/components/visualization/matplotlib_figure.py +9 −5 Original line number Diff line number Diff line Loading @@ -200,18 +200,20 @@ class MatplotlibFigure(matplotlib.Figure): Parameters ---------- figure : `altair.Chart <https://altair-viz.github.io/user_guide/generated/toplevel/altair.Chart.html#altair.Chart>`_ Altair chart object webagg : bool figure : `matplotlib.figure.Figure <https://matplotlib.org/stable/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure>`__, optional Initial Matplotlib figure. webagg : bool, optional If true, then the WebAgg backend for Matplotlib is used. If not, then the default Trame matplotlib plugin is used. is used. Note that this parameter does not supporting Trame bindings since the user experiences are fundamentally different between the two options and toggling them is not considered a good idea by the author of this component. kwargs Arguments to be passed to `AbstractElement <https://trame.readthedocs.io/en/latest/core.widget.html#trame_client.widgets.core.AbstractElement>`_ Returns ------- None """ """ # noqa: E501 self._webagg = webagg if webagg: self._port = MatplotlibFigure._get_free_port() Loading Loading @@ -253,6 +255,8 @@ class MatplotlibFigure(matplotlib.Figure): else: super().update(figure) self._server.state.flush() def _setup_figure_websocket(self) -> None: thread = Thread(target=self._mpl_run_ws_server, daemon=True) thread.start() Loading Loading
pyproject.toml +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ packages = [{include = "nova", from = "src"}] altair = "*" libsass = "*" mergedeep = "*" mpld3 = "^0.5.11" python = ">=3.10,<4.0" tomli = "*" tornado = ">=6.5.0" Loading
src/nova/trame/_internal/utils.py +8 −1 Original line number Diff line number Diff line Loading @@ -7,6 +7,13 @@ from trame_server.core import State from nova.mvvm._internal.utils import rgetdictvalue, rsetdictvalue # Trame state handlers don't work on nested properties. When writing Trame state handlers (e.g. flushState, dirty, or # change), we instead use the name of the top-level property. For example, "config.parameter_group_a.option_x" becomes # "config". def get_state_name(name: str) -> str: return name.split(".")[0] # Reads a state parameter from Trame. For internal use only, if you're using this in your application you're violating # the MVVM framework. :) def get_state_param(state: State, value: Union[Any, Tuple]) -> Any: Loading @@ -25,6 +32,6 @@ def set_state_param(state: State, value: Union[Any, Tuple], new_value: Any = Non rsetdictvalue(state, value[0], new_value) elif len(value) > 1: rsetdictvalue(state, value[0], value[1]) state.dirty(value[0].split(".")[0]) state.dirty(get_state_name(value[0])) return get_state_param(state, value)
src/nova/trame/view/components/visualization/interactive_2d_plot.py +4 −2 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ class Interactive2DPlot(vega.Figure): Parameters ---------- figure : `altair.Chart <https://altair-viz.github.io/user_guide/generated/toplevel/altair.Chart.html#altair.Chart>`_ figure : `altair.Chart <https://altair-viz.github.io/user_guide/generated/toplevel/altair.Chart.html#altair.Chart>`__, optional Altair chart object kwargs Arguments to be passed to `AbstractElement <https://trame.readthedocs.io/en/latest/core.widget.html#trame_client.widgets.core.AbstractElement>`_ Loading @@ -38,7 +38,7 @@ class Interactive2DPlot(vega.Figure): Returns ------- None """ """ # noqa: E501 self._initialized = False super().__init__(figure=figure, **kwargs) Loading Loading @@ -83,3 +83,5 @@ class Interactive2DPlot(vega.Figure): if hasattr(self, "_start_update_handlers"): self._start_update_handlers() self.server.state.flush()
src/nova/trame/view/components/visualization/matplotlib_figure.py +9 −5 Original line number Diff line number Diff line Loading @@ -200,18 +200,20 @@ class MatplotlibFigure(matplotlib.Figure): Parameters ---------- figure : `altair.Chart <https://altair-viz.github.io/user_guide/generated/toplevel/altair.Chart.html#altair.Chart>`_ Altair chart object webagg : bool figure : `matplotlib.figure.Figure <https://matplotlib.org/stable/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure>`__, optional Initial Matplotlib figure. webagg : bool, optional If true, then the WebAgg backend for Matplotlib is used. If not, then the default Trame matplotlib plugin is used. is used. Note that this parameter does not supporting Trame bindings since the user experiences are fundamentally different between the two options and toggling them is not considered a good idea by the author of this component. kwargs Arguments to be passed to `AbstractElement <https://trame.readthedocs.io/en/latest/core.widget.html#trame_client.widgets.core.AbstractElement>`_ Returns ------- None """ """ # noqa: E501 self._webagg = webagg if webagg: self._port = MatplotlibFigure._get_free_port() Loading Loading @@ -253,6 +255,8 @@ class MatplotlibFigure(matplotlib.Figure): else: super().update(figure) self._server.state.flush() def _setup_figure_websocket(self) -> None: thread = Thread(target=self._mpl_run_ws_server, daemon=True) thread.start() Loading