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
[CVPR'2020] DeepDeform: Learning Non-rigid RGB-D Reconstruction with Semi-supervised Data

DeepDeform (CVPR'2020) DeepDeform is an RGB-D video dataset containing over 390,000 RGB-D frames in 400 videos, with 5,533 optical and scene flow imag

Aljaz Bozic 165 Jan 09, 2023
Improving Factual Consistency of Abstractive Text Summarization

Improving Factual Consistency of Abstractive Text Summarization We provide the code for the papers: "Entity-level Factual Consistency of Abstractive T

61 Nov 27, 2022
This is a computer vision based implementation of the popular childhood game 'Hand Cricket/Odd or Even' in python

Hand Cricket Table of Content Overview Installation Game rules Project Details Future scope Overview This is a computer vision based implementation of

Abhinav R Nayak 6 Jan 12, 2022
Source code for paper "Deep Superpixel-based Network for Blind Image Quality Assessment"

DSN-IQA Source code for paper "Deep Superpixel-based Network for Blind Image Quality Assessment" Requirements Python =3.8.0 Pytorch =1.7.1 Usage wit

7 Oct 13, 2022
PyTorch implementation of normalizing flow models

PyTorch implementation of normalizing flow models

Vincent Stimper 242 Jan 02, 2023
A PyTorch Implementation of Gated Graph Sequence Neural Networks (GGNN)

A PyTorch Implementation of GGNN This is a PyTorch implementation of the Gated Graph Sequence Neural Networks (GGNN) as described in the paper Gated G

Ching-Yao Chuang 427 Dec 13, 2022
An evaluation toolkit for voice conversion models.

Voice-conversion-evaluation An evaluation toolkit for voice conversion models. Sample test pair Generate the metadata for evaluating models. The direc

30 Aug 29, 2022
Neuralnetwork - Basic Multilayer Perceptron Neural Network for deep learning

Neural Network Just a basic Neural Network module Usage Example Importing Module

andreecy 0 Nov 01, 2022
A plug-and-play library for neural networks written in Python

A plug-and-play library for neural networks written in Python!

Dimos Michailidis 2 Jul 16, 2022
A Context-aware Visual Attention-based training pipeline for Object Detection from a Webpage screenshot!

CoVA: Context-aware Visual Attention for Webpage Information Extraction Abstract Webpage information extraction (WIE) is an important step to create k

Keval Morabia 41 Jan 01, 2023
Official code for 'Weakly-supervised Video Anomaly Detection with Robust Temporal Feature Magnitude Learning' [ICCV 2021]

RTFM This repo contains the Pytorch implementation of our paper: Weakly-supervised Video Anomaly Detection with Robust Temporal Feature Magnitude Lear

Yu Tian 242 Jan 08, 2023
A no-BS, dead-simple training visualizer for tf-keras

A no-BS, dead-simple training visualizer for tf-keras TrainingDashboard Plot inter-epoch and intra-epoch loss and metrics within a jupyter notebook wi

Vibhu Agrawal 3 May 28, 2021
Gym-TORCS is the reinforcement learning (RL) environment in TORCS domain with OpenAI-gym-like interface.

Gym-TORCS Gym-TORCS is the reinforcement learning (RL) environment in TORCS domain with OpenAI-gym-like interface. TORCS is the open-rource realistic

naoto yoshida 400 Dec 27, 2022
Deeplab-resnet-101 in Pytorch with Jaccard loss

Deeplab-resnet-101 Pytorch with Lovász hinge loss Train deeplab-resnet-101 with binary Jaccard loss surrogate, the Lovász hinge, as described in http:

Maxim Berman 95 Apr 15, 2022
Bachelor's Thesis in Computer Science: Privacy-Preserving Federated Learning Applied to Decentralized Data

federated is the source code for the Bachelor's Thesis Privacy-Preserving Federated Learning Applied to Decentralized Data (Spring 2021, NTNU) Federat

Dilawar Mahmood 25 Nov 30, 2022
Distributed Evolutionary Algorithms in Python

DEAP DEAP is a novel evolutionary computation framework for rapid prototyping and testing of ideas. It seeks to make algorithms explicit and data stru

Distributed Evolutionary Algorithms in Python 4.9k Jan 05, 2023
Feup-csr - Repository holding my group's submission to the CSR project competition

CSR Competições de Swarm Robotics Swarm Robotics Competitions This repository holds the files submitted for the CSR project competition. Project group

Nuno Pereira 1 Jan 04, 2022
Code for EMNLP'21 paper "Types of Out-of-Distribution Texts and How to Detect Them"

ood-text-emnlp Code for EMNLP'21 paper "Types of Out-of-Distribution Texts and How to Detect Them" Files fine_tune.py is used to finetune the GPT-2 mo

Udit Arora 19 Oct 28, 2022
A Pytorch Implementation of a continuously rate adjustable learned image compression framework.

GainedVAE A Pytorch Implementation of a continuously rate adjustable learned image compression framework, Gained Variational Autoencoder(GainedVAE). N

39 Dec 24, 2022
It helps user to learn Pick-up lines and share if he has a better one

Pick-up-Lines-Generator(Open Source) It helps user to learn Pick-up lines Share and Add one or many to the DataBase Unique SQLite DataBase AI Undercon

knock_nott 0 May 04, 2022