Skip to content

Commit

Permalink
fix the strange attractors app (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt authored Nov 26, 2024
1 parent 9d8bccc commit 04bc4e7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
7 changes: 5 additions & 2 deletions attractors/anaconda-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion attractors/attractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions attractors/attractors_panel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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"
]
},
{
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 04bc4e7

Please sign in to comment.