Visualization toolkit for Gnome Codes - scalar encoding using binary population codes.
This is a modernization and migration from the original legacy visual gallery and visualization code repositories.
This toolkit mostly makes use of the gnomecode package which implements detailed control of encoders and analysis of their properties. The visualization code provided here illustrates all of that information in interesting and insightful ways.
This repository provides comprehensive visualization tools across three main technologies:
- Manim: Animated educational content about encoder behavior
- Matplotlib: Static plots and quantitative analysis
- Dash/Plotly: Interactive web-based exploration
Browse the full gallery/ for all examples.
This package requires Python 3.8 or later and depends on the separate gnomecode package.
# Install gnomevisual in editable mode
pip install -e .
# If you're also developing the gnomecode package, install it in editable mode
pip install -e /path/to/gnomecodeFor development work with additional tools (testing, linting, profiling):
# Install with dev dependencies
pip install -e ".[dev]"
# Install gnomecode in editable mode for active development
pip install -e /path/to/gnomecode# Test imports
python -c "from gnomevisual.matplotlib import draw_multi_encoder_bins; print('Success!')"
python -c "from gnomevisual.manim import GnomeCode; print('Success!')"Create animated visualizations of encoder behavior:
# Run an experiment
manim experiments/encoder_basics/manim/render_bins.py
# Run a specific scene
manim experiments/encoder_basics/manim/encoder_folded.py EncoderFoldScene
# Start from a template
cp examples/templates/manim_template.py experiments/encoder_basics/manim/my_animation.py
manim experiments/encoder_basics/manim/my_animation.py MySceneOutput videos are saved to media/ or outputs/videos/.
Generate static plots for analysis:
# Run the main plotting script
python scripts/plot_encoders.py
# Start from a template
cp examples/templates/matplotlib_template.py my_analysis.py
python my_analysis.pyOutput images are saved to outputs/figures/.
Launch interactive web applications:
# Launch the encoder dashboard
cd apps/dash_encoder
python run_app.py
# Open browser to http://localhost:8050
# Custom port
python run_app.py --port 8080 --debuggnome_visuals/
├── gnomevisual/ # Core reusable package
│ ├── matplotlib/ # Matplotlib components (axesplots, layouts)
│ ├── manim/ # Manim components (GnomeCode, Synapse, etc.)
│ ├── plotly/ # Plotly/Dash components (early stage)
│ └── utils.py # General utilities
├── experiments/ # Topic-organized experiments
│ ├── encoder_basics/
│ ├── neural_networks/
│ ├── hypergrid_transform/
│ ├── discrete_neurons/
│ ├── similarity_analysis/ # placeholder, no experiments yet
│ └── parameter_sweeps/ # placeholder, no experiments yet
├── apps/ # Standalone applications
│ └── dash_encoder/
├── gallery/ # Example output images and animations
├── publications/ # Publication-specific projects
├── scripts/ # Utility scripts
├── examples/ # Templates
└── outputs/ # Generated content (gitignored)
See CLAUDE.md for detailed architecture documentation.
# Matplotlib visualization
from gnomecode.encoders import PeriodicScalarEncoder
from gnomevisual.matplotlib import draw_multi_encoder_bins, plot_code_heatmap
import matplotlib.pyplot as plt
encoder = PeriodicScalarEncoder(n=32, w=8, period=1.0)
fig, ax = plt.subplots()
draw_multi_encoder_bins(ax, encoder)
plt.show()
# Manim animation
from manim import *
from gnomevisual.manim import GnomeCode
class MyScene(Scene):
def construct(self):
gnome = GnomeCode(n=32, w=8, shape="square")
self.play(Create(gnome))Experiments are organized by research topic, with subdirectories for each technology:
# Add a new encoder visualization
cp examples/templates/manim_template.py experiments/encoder_basics/manim/my_experiment.py
# Edit and run
manim experiments/encoder_basics/manim/my_experiment.py# Run all tests
pytest
# Run with coverage
pytest --cov=gnomevisual --cov-report=html# Format code with black
black gnomevisual/
# Sort imports with isort
isort gnomevisual/
# Check style with flake8
flake8 gnomevisual/# Profile a script
python -m line_profiler_pycharm script.py- CLAUDE.md: Comprehensive architecture and development guide
- experiments/README.md: Guide to experiments organization
- Topic READMEs: Each experiment topic has its own README explaining research questions
- Follow the existing code structure
- Use templates from
examples/templates/for consistency - Import from
gnomevisualsubmodules (e.g.,from gnomevisual.manim import GnomeCode) - Place generated outputs in
outputs/directory - Run tests and formatters before committing
MIT License - see LICENSE file for details.
If you use this visualization toolkit in your research, please cite:
@software{gnome_visuals,
author = {Everist, Jacob},
title = {Gnome Visuals: Visualization Toolkit for Gnome Codes},
year = {2024},
url = {https://github.com/jacobeverist/gnome_visuals}
}




