Pywonderland - A tour in the wonderland of math with python.

Overview

A Tour in the Wonderland of Math with Python

A collection of python scripts for drawing beautiful figures and animating interesting algorithms in mathematics.

About this repo

The purpose of this project is to show the beauty of math with python by rendering high quality images, videos and animations. It consists of several independent projects with each one illustrates a special object/algorithm in math. The current list contains:

  • Aperiodic tilings like Penrose tiling, Ammann-Beenker tiling, etc.
  • Triology on perfectly random sampling algorithms.
    1. Domino shuffling algorithm on Aztec diamonds.
    2. Wilson's uniform spanning tree algorithm on 2d grids.
    3. Coupling from the past algorithm on lozenge tilings.
  • Hopf fibration.
  • 3D and 4D Uniform polytopes.
  • 2D uniform tilings and 3D uniform honeycombs in Euclidean, spherical and hyperbolic spaces.
  • Make gif animations of various algorithms.
  • Lots of shader animations.
  • Miscellaneous scripts like E8 root system, Mandelbrot set, Newton's fractal, Lorenz attractor, etc.

These topics are chosen largely due to my personal taste:

  1. They must produce appealing results.
  2. There must be some non-trivial math behind them.
  3. The code should be as simple as possible.

I'll use only popular python libs and build all math stuff by hand (tools like sage, sympy, mathemetica will not be used here).

Gallery

The code for some of the images are not in the master branch, they can be found in the released version.

  • Uniform 3D and 4D polytopes

  • Möbius transformations

  • 3D Euclidean uniform honeycombs and their duals

  • Gray-Scott simulation

  • 3D hyperbolic uniform honeycombs

  • Limit set of rank 4 Coxeter groups

  • Aperiodic tilings

  • 3D Fractals

  • Coxeter automata and 2D Uniform tilings

  • GIF animations of various algorithms

  • Others

Many more to be comtinued ...

How to use

All projects here are implemented in a ready-to-use manner for new comers. You can simply run the examples without tweaking any parameters once you have the dependencies installed correctly.

Dependencies

The recommended way to install all dependencies is simply running the bash script install_dependencies.sh.

sudo bash install_dependencies.sh

Or you can install the python libs by pip:

pip install -r requirements.txt

Open source softwares required:

  • python3-tk (for file dialog)
  • ImageMagick (for making gif animations)
  • FFmpeg (for saving animations to video files)
  • POV-Ray (for generating high quality raytracing results)
  • graphviz (for drawing automata of Coxeter groups)
  • Inkscape (optional, for convering large svg files to png)

They can all be installed via command-line:

sudo apt-get install python3-tk imagemagick ffmpeg povray graphviz inkscape

Note pygraphviz also requires libgraphviz-dev:

sudo apt-get install libgraphviz-dev

In the scripts these softwares are called in command line as povray, ffmpeg, convert (from ImageMagick), etc. For Windows users you should add the directories contain these .exe files to the system Path environment variables to let the system know what executables these commands refer to. For example on Windows the default location of POV-Ray's exe file is C:\Program Files\POV-Ray\v3.7\bin\pvengine64.exe, so you should add C:\Program Files\POV-Ray\v3.7\bin to system Path and rename pvengine64.exe to povray.exe, then you can run the scripts without any changes and everything works fine.

Thanks

I have learned a lot from the following people:

License

see the LICENSE file.

Comments
  • Run pywonderland inside a Docker container

    Run pywonderland inside a Docker container

    Q: How can I work with pywonderland on my computer without installing all of the required libraries and modules into my operating system?

    A: Docker will allow you to create a Linux container running Python 3 where we can install pywonderland and all of its dependencies.

    opened by cclauss 19
  • Define raw_input() for Python 3

    Define raw_input() for Python 3

    input() is a different built-in function in Python 2 so we should not overwrite it. Also used strip() to eliminate leading or trailing whitespace in user input.

    opened by cclauss 6
  • Question about gifmaze module and pypi

    Question about gifmaze module and pypi

    Hello.

    I would lile to contribute to the gifmaze module, but I am a bit lost between the various versions of this code.

    So :

    • is this the "official" gifmaze.py source code repository ? :)
    • do you plan on publishing new version of gifmaze on pypi.org ?
    • are you willing to accept pull requests ?

    Regards

    opened by Lucas-C 4
  • [Feature request]Universal Random Structures in 2D

    [Feature request]Universal Random Structures in 2D

    Hi there, Really nice animations and super cool project! I am wondering if there is any plan to add Universal Random Structures in 2D (work by Scott Sheffield and Jason Miller). This Quanta article gives some good introduction, and there are more demo images here: http://statslab.cam.ac.uk/~jpm205/images.html

    opened by junpenglao 2
  • Suggestion: Conway's Game of Life

    Suggestion: Conway's Game of Life

    Suggesting another example. Here is a good reference for Python code implementing and explaining Conway's Game of Life: https://jakevdp.github.io/blog/2013/08/07/conways-game-of-life/

    opened by yoavram 2
  • Make fractal3d.py Python 3.8 ready

    Make fractal3d.py Python 3.8 ready

    The script fractal3d.py fails with Python 3.8, because time.clock() was removed from the Python API. (https://docs.python.org/3/whatsnew/3.8.html#api-and-feature-removals)

    In this PR i replaced time.clock() with time.process_time()

    opened by gsilvan 1
  • Use dictionary for parse_image to speed up image parsing.

    Use dictionary for parse_image to speed up image parsing.

    In parse_image, we do a membership check on colors, which is a list, and takes O(n) time. Using a dictionary is effectively a drop in replacement, but reduces lookup time to O(1), and offers a 5x speedup for the image for example4() in gifmaze/example_maze_animations (1.1421077s to 0.213111s)

    (Note that in Python 3.6+, dictionaries are ordered by default, but if you want to support 3.5 and below, OrderedDict is need)

    opened by philippeitis 1
  • Fix some bug risks and code quality issues

    Fix some bug risks and code quality issues

    Changes:

    • Remove unnecessary list comprehension
    • Make valid method a staticmethod
    • Remove unnecessary elif after return statement
    • Fix dangerous default argument.
    • Add .deepsource.toml file to file to run continuous static analysis on the repository with DeepSource

    This PR also adds .deepsource.toml configuration file to run static analysis continuously on the repo with DeepSource. Upon enabling DeepSource, quality and security analysis will be run on every PR to detect 500+ types of problems in the changes — including bug risks, anti-patterns, security vulnerabilities, etc.

    DeepSource is free to use for open-source projects, and is used by teams at NASA, Uber, Slack among many others, and open-source projects like ThoughtWorks/Gauge, Masonite Framework, etc.

    To enable DeepSource analysis after merging this PR, please follow these steps:

    • Sign up on DeepSource with your GitHub account and grant access to this repo.
    • Activate analysis on this repo here.
    • You can also look at the docs for more details. Do let me know if I can be of any help!
    opened by mohi7solanki 1
  • Error when runing e8.py

    Error when runing e8.py

    ---> 14 import cairocffi as cairo 15 import numpy as np 16 from palettable.colorbrewer.qualitative import Set1_8

    C:\Localdata\Software\PythonAnaconda\lib\site-packages\cairocffi_init_.py in () 14 import ctypes.util 15 ---> 16 from . import constants 17 from .compat import FileNotFoundError 18 from ._ffi import ffi

    ImportError: cannot import name constants

    opened by xhtp2000 1
  • docs: fix simple typo, representaion -> representation

    docs: fix simple typo, representaion -> representation

    There is a small typo in src/polytopes/polytopes/models.py.

    Should read representation rather than representaion.

    Semi-automated pull request generated by https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

    opened by timgates42 0
  • Add flake8 testing to Travis CI

    Add flake8 testing to Travis CI

    Each time someone adds code to this repo, CI automatically can run tests on it. The owner of the this repo would need to go to https://travis-ci.org/profile and flip the repository switch on to enable free automated flake8 testing on each pull request.

    opened by cclauss 0
  • (PYL-R1723) Unnecessary `else` / `elif` used after `break`

    (PYL-R1723) Unnecessary `else` / `elif` used after `break`

    Description

    The use of else or elif becomes redundant and can be dropped if the last statement under the leading if / elif block is a break statement. In the case of an elif after break, it can be written as a separate if block. For else blocks after break, the …

    Occurrences

    There is 1 occurrence of this issue in the repository.

    See all occurrences on DeepSource → deepsource.io/gh/neozhaoliang/pywonderland/issue/PYL-R1723/occurrences/

    opened by mayankgoyal-13 0
Releases(0.1.0)
Owner
Zhao Liang
My name is 赵亮 (Zhao Liang), since it's used by too many people I have to add a 'neo' prefix to sign up websites. I study and code math stuff.
Zhao Liang
Implementation of experiments in the paper Clockwork Variational Autoencoders (project website) using JAX and Flax

Clockwork VAEs in JAX/Flax Implementation of experiments in the paper Clockwork Variational Autoencoders (project website) using JAX and Flax, ported

Julius Kunze 26 Oct 05, 2022
Benchmarks for semi-supervised domain generalization.

Semi-Supervised Domain Generalization This code is the official implementation of the following paper: Semi-Supervised Domain Generalization with Stoc

Kaiyang 49 Dec 10, 2022
load .txt to train YOLOX, same as Yolo others

YOLOX train your data you need generate data.txt like follow format (per line- one image). prepare one data.txt like this: img_path1 x1,y1,x2,y2,clas

LiMingf 18 Aug 18, 2022
This repo contains implementation of different architectures for emotion recognition in conversations.

Emotion Recognition in Conversations Updates 🔥 🔥 🔥 Date Announcements 03/08/2021 🎆 🎆 We have released a new dataset M2H2: A Multimodal Multiparty

Deep Cognition and Language Research (DeCLaRe) Lab 1k Dec 30, 2022
Code, pre-trained models and saliency results for the paper "Boosting RGB-D Saliency Detection by Leveraging Unlabeled RGB Images".

Boosting RGB-D Saliency Detection by Leveraging Unlabeled RGB This repository is the official implementation of the paper. Our results comming soon in

Xiaoqiang Wang 8 May 22, 2022
Air Quality Prediction Using LSTM

AirQualityPredictionUsingLSTM In this Repo, i present to you the winning solution of smart gujarat hackathon 2019 where the task was to predict the qu

Deepak Nandwani 2 Dec 13, 2022
(Preprint) Official PyTorch implementation of "How Do Vision Transformers Work?"

(Preprint) Official PyTorch implementation of "How Do Vision Transformers Work?"

xxxnell 656 Dec 30, 2022
An AFL implementation with UnTracer (our coverage-guided tracer)

UnTracer-AFL This repository contains an implementation of our prototype coverage-guided tracing framework UnTracer in the popular coverage-guided fuz

113 Dec 17, 2022
DIVeR: Deterministic Integration for Volume Rendering

DIVeR: Deterministic Integration for Volume Rendering This repo contains the training and evaluation code for DIVeR. Setup python 3.8 pytorch 1.9.0 py

64 Dec 27, 2022
The official implementation of NeurIPS 2021 paper: Finding Optimal Tangent Points for Reducing Distortions of Hard-label Attacks

Introduction This repository includes the source code for "Finding Optimal Tangent Points for Reducing Distortions of Hard-label Attacks", which is pu

machen 11 Nov 27, 2022
FluxTraining.jl gives you an endlessly extensible training loop for deep learning

A flexible neural net training library inspired by fast.ai

86 Dec 31, 2022
Tensorflow solution of NER task Using BiLSTM-CRF model with Google BERT Fine-tuning And private Server services

Tensorflow solution of NER task Using BiLSTM-CRF model with Google BERT Fine-tuning

MaCan 4.2k Dec 29, 2022
I will implement Fastai in each projects present in this repository.

DEEP LEARNING FOR CODERS WITH FASTAI AND PYTORCH The repository contains a list of the projects which I have worked on while reading the book Deep Lea

Thinam Tamang 43 Dec 20, 2022
Paddle-Skeleton-Based-Action-Recognition - DecoupleGCN-DropGraph, ASGCN, AGCN, STGCN

Paddle-Skeleton-Action-Recognition DecoupleGCN-DropGraph, ASGCN, AGCN, STGCN. Yo

Chenxu Peng 3 Nov 02, 2022
Code of 3D Shape Variational Autoencoder Latent Disentanglement via Mini-Batch Feature Swapping for Bodies and Faces

3D Shape Variational Autoencoder Latent Disentanglement via Mini-Batch Feature Swapping for Bodies and Faces Installation After cloning the repo open

37 Dec 03, 2022
PyTorch implementation of Masked Autoencoders Are Scalable Vision Learners for self-supervised ViT.

MAE for Self-supervised ViT Introduction This is an unofficial PyTorch implementation of Masked Autoencoders Are Scalable Vision Learners for self-sup

36 Oct 30, 2022
Roach: End-to-End Urban Driving by Imitating a Reinforcement Learning Coach

CARLA-Roach This is the official code release of the paper End-to-End Urban Driving by Imitating a Reinforcement Learning Coach by Zhejun Zhang, Alexa

Zhejun Zhang 118 Dec 28, 2022
Resources for our AAAI 2022 paper: "LOREN: Logic-Regularized Reasoning for Interpretable Fact Verification".

LOREN Resources for our AAAI 2022 paper (pre-print): "LOREN: Logic-Regularized Reasoning for Interpretable Fact Verification". DEMO System Check out o

Jiangjie Chen 37 Dec 27, 2022
Winners of the Facebook Image Similarity Challenge

Winners of the Facebook Image Similarity Challenge

DrivenData 111 Jan 05, 2023
Clairvoyance: a Unified, End-to-End AutoML Pipeline for Medical Time Series

Clairvoyance: A Pipeline Toolkit for Medical Time Series Authors: van der Schaar Lab This repository contains implementations of Clairvoyance: A Pipel

van_der_Schaar \LAB 89 Dec 07, 2022