Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the strange attractors app #457

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading