Table of Contents
I have always been fascinated by patterns, fractals and attractors. So when attractors display a particular pattern with a fractal structure, the so-called strange attractors, I tend to be even more attracted to them.
It turns out I am not the only one interested in those strange mathematical objects and one of the most effective
ways to explore various types of attractors and their parameters
is to use the attractors_panel
interactive dashboard developed a
few years ago by the nice people of HoloViz. The dashboard is powered
by panel and makes heavy use of numba
and Datashader to speed up calculations and rendering.
This project, Attractor Explorer, has two objectives:
- to provide an updated version of the original dashboard
- to provide a new dashboard that allows users to animate the plots by automatically varying parameters within a certain range
My contribution has first consisted in re-organising the original code into a proper Python package, with unit tests and documentation.
This project is still work in progress and has not been released as a distributed package yet. So it is necessary to first clone the Git repo before installing the library.
First create a virtual environment (local or not) using your favourite environment manager (hatch, poetry, conda). Once this is done, simply install the package (in editable mode or not) with:
pip install -e .
Alternatively, you can also create a local environment and install all the dependencies by using uv:
uv run panel serve src/attractor_explorer/attractors_explorer.py
This would also start the dashboard (see below).
Two panel
webapps or "dashboards" are available. The first one is a modified version of attractors_panel
and
it can be launched with:
panel serve src/attractor_explorer/attractors_explorer.py
It should work similarly to the original one: select the type of attractor, the resolution (the number of points calculated), and then use the cursors to play with the parameters.
Each attractor has:
- Executable Python code for calculating trajectories, optimized using Numba.
- Readable equations displayable with KaTeX
- Examples of interesting patterns stored in a separate
attractors.yml
file
Support is provided for reading the attractors.yml
file and working with the examples in it.
The changes I have introduced compared to the original HoloViz version include:
- linting and formatting with Ruff
- data folder for storing parameters
- renaming of attractor classes to follow CapWords convention (
Fractal_Dream
->FractalDream
) - use
item_type
instead ofclass_
attribute inparam.List()
- rename
.sig()
method.signature()
- use
np.random.default_rng()
instead ofnumpy.random.seed()
- move
trajectory_coords()
andtrajectory()
functions to newmaths.py
module - unit tests and Github actions
attractor-explorer
is distributed under the terms of the MIT license.