From 04bc4e730562e6fc3c55b6f5b19d19867abeb68c Mon Sep 17 00:00:00 2001 From: Maxime Liquet <35924738+maximlt@users.noreply.github.com> Date: Tue, 26 Nov 2024 19:47:31 +0100 Subject: [PATCH] fix the strange attractors app (#457) --- attractors/anaconda-project.yml | 7 +++++-- attractors/attractors.py | 2 +- attractors/attractors_panel.ipynb | 16 +++++++++++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/attractors/anaconda-project.yml b/attractors/anaconda-project.yml index 9f1953c58..646c7527d 100644 --- a/attractors/anaconda-project.yml +++ b/attractors/anaconda-project.yml @@ -38,12 +38,15 @@ dependencies: *pkgs commands: dashboard: - unix: panel serve --rest-session-info --session-history -1 *_panel.ipynb --show + unix: panel serve --rest-session-info --session-history -1 attractors_panel.ipynb clifford_panel.ipynb --show supports_http_options: true notebook: notebook: index.ipynb -variables: {} +variables: + # Avoid "Dask dataframe query planning is disabled because dask-expr is not installed." + DASK_DATAFRAME__QUERY_PLANNING: "False" + downloads: {} platforms: diff --git a/attractors/attractors.py b/attractors/attractors.py index ae2f441f2..4e3148980 100644 --- a/attractors/attractors.py +++ b/attractors/attractors.py @@ -274,7 +274,7 @@ def _save(self): if self.output_examples_filename == self.param.input_examples_filename.default: raise FileExistsError('Cannot override the default attractors file.') with open(Path('data', self.output_examples_filename), "w") as f: - yaml.dump(self.param.example.objects,f) + yaml.dump(list(self.param.example.objects), f) def __call__(self): return self.example diff --git a/attractors/attractors_panel.ipynb b/attractors/attractors_panel.ipynb index 6b44684f9..ba103b763 100644 --- a/attractors/attractors_panel.ipynb +++ b/attractors/attractors_panel.ipynb @@ -162,6 +162,7 @@ "source": [ "import param, panel as pn\n", "from panel.pane import LaTeX\n", + "\n", "pn.extension('katex', sizing_mode='stretch_width')\n", "\n", "pn.Param.margin = 0\n", @@ -170,7 +171,7 @@ "class Attractors(pn.viewable.Viewer):\n", " attractor_type = param.Selector(objects=params.attractors, default=params.attractors[\"Clifford\"], precedence=0.9)\n", "\n", - " parameters = param.Selector(objects=params.attractors, precedence=-0.5, readonly=True)\n", + " parameters = param.Parameter(params, precedence=-0.5, readonly=True)\n", "\n", " plot_type = param.Selector(\n", " precedence=0.8, objects=['points', 'line'],\n", @@ -182,7 +183,7 @@ "\n", " @param.depends(\"parameters.param\", watch=True)\n", " def _update_from_parameters(self):\n", - " a = params.attractor(*self.attractor_type())\n", + " a = params.attractor(*self.parameters())\n", " if a is not self.attractor_type:\n", " self.param.update(attractor_type=a)\n", "\n", @@ -200,7 +201,7 @@ "\n", "ats = Attractors(name=\"Options\")\n", "params.current = lambda: ats.attractor_type\n", - "ats # Uncomment to see a plot of the current attractor" + "# ats # Uncomment to see a plot of the current attractor" ] }, { @@ -257,6 +258,15 @@ "Ok, now we are ready to put everything together into a dashboard using one of the available panel templates, which we will mark `.servable()` to indicate that the dashboard should be displayed if this notebook is run using `panel serve`:" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pn.Row(plot, widgets)" + ] + }, { "cell_type": "code", "execution_count": null,