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
Code for the paper Learning the Predictability of the Future

Learning the Predictability of the Future Code from the paper Learning the Predictability of the Future. Website of the project in hyperfuture.cs.colu

Computer Vision Lab at Columbia University 139 Nov 18, 2022
Code repository for our paper regarding the L3D dataset.

The Large Labelled Logo Dataset (L3D): A Multipurpose and Hand-Labelled Continuously Growing Dataset Website: https://lhf-labs.github.io/tm-dataset Da

LHF Labs 9 Dec 14, 2022
JumpDiff: Non-parametric estimator for Jump-diffusion processes for Python

jumpdiff jumpdiff is a python library with non-parametric Nadaraya─Watson estimators to extract the parameters of jump-diffusion processes. With jumpd

Rydin 28 Dec 10, 2022
Implementation of Deep Deterministic Policy Gradiet Algorithm in Tensorflow

ddpg-aigym Deep Deterministic Policy Gradient Implementation of Deep Deterministic Policy Gradiet Algorithm (Lillicrap et al.arXiv:1509.02971.) in Ten

Steven Spielberg P 247 Dec 07, 2022
[BMVC'21] Official PyTorch Implementation of Grounded Situation Recognition with Transformers

Grounded Situation Recognition with Transformers Paper | Model Checkpoint This is the official PyTorch implementation of Grounded Situation Recognitio

Junhyeong Cho 18 Jul 19, 2022
This is an official implementation for "Exploiting Temporal Contexts with Strided Transformer for 3D Human Pose Estimation".

Exploiting Temporal Contexts with Strided Transformer for 3D Human Pose Estimation This repo is the official implementation of Exploiting Temporal Con

Vegetabird 241 Jan 07, 2023
Models Supported: AlbUNet [18, 34, 50, 101, 152] (1D and 2D versions for Single and Multiclass Segmentation, Feature Extraction with supports for Deep Supervision and Guided Attention)

AlbUNet-1D-2D-Tensorflow-Keras This repository contains 1D and 2D Signal Segmentation Model Builder for AlbUNet and several of its variants developed

Sakib Mahmud 1 Nov 15, 2021
Colour detection is necessary to recognize objects, it is also used as a tool in various image editing and drawing apps.

Colour Detection On Image Colour detection is the process of detecting the name of any color. Simple isn’t it? Well, for humans this is an extremely e

Astitva Veer Garg 1 Jan 13, 2022
[PNAS2021] The neural architecture of language: Integrative modeling converges on predictive processing

The neural architecture of language: Integrative modeling converges on predictive processing Code accompanying the paper The neural architecture of la

Martin Schrimpf 36 Dec 01, 2022
Official code repository for "Exploring Neural Models for Query-Focused Summarization"

Query-Focused Summarization Official code repository for "Exploring Neural Models for Query-Focused Summarization" This is a work in progress. Expect

Salesforce 29 Dec 18, 2022
DirectVoxGO reconstructs a scene representation from a set of calibrated images capturing the scene.

DirectVoxGO reconstructs a scene representation from a set of calibrated images capturing the scene. We achieve NeRF-comparable novel-view synthesis quality with super-fast convergence.

sunset 709 Dec 31, 2022
Automatically Build Multiple ML Models with a Single Line of Code. Created by Ram Seshadri. Collaborators Welcome. Permission Granted upon Request.

Auto-ViML Automatically Build Variant Interpretable ML models fast! Auto_ViML is pronounced "auto vimal" (autovimal logo created by Sanket Ghanmare) N

AutoViz and Auto_ViML 397 Dec 30, 2022
Python parser for DTED data.

DTED Parser This is a package written in pure python (with help from numpy) to parse and investigate Digital Terrain Elevation Data (DTED) files. This

Ben Bonenfant 12 Dec 18, 2022
No-Reference Image Quality Assessment via Transformers, Relative Ranking, and Self-Consistency

This repository contains the implementation for the paper: No-Reference Image Quality Assessment via Transformers, Relative Ranking, and Self-Consiste

Alireza Golestaneh 75 Dec 30, 2022
Pytorch implementation of the DeepDream computer vision algorithm

deep-dream-in-pytorch Pytorch (https://github.com/pytorch/pytorch) implementation of the deep dream (https://en.wikipedia.org/wiki/DeepDream) computer

102 Dec 05, 2022
Pixel-Perfect Structure-from-Motion with Featuremetric Refinement (ICCV 2021, Oral)

Pixel-Perfect Structure-from-Motion (ICCV 2021 Oral) We introduce a framework that improves the accuracy of Structure-from-Motion by refining keypoint

Computer Vision and Geometry Lab 831 Dec 29, 2022
Binary Stochastic Neurons in PyTorch

Binary Stochastic Neurons in PyTorch http://r2rt.com/binary-stochastic-neurons-in-tensorflow.html https://github.com/pytorch/examples/tree/master/mnis

Onur Kaplan 54 Nov 21, 2022
👨‍💻 run nanosaur in simulation with Gazebo/Ingnition

🦕 👨‍💻 nanosaur_gazebo nanosaur The smallest NVIDIA Jetson dinosaur robot, open-source, fully 3D printable, based on ROS2 & Isaac ROS. Designed & ma

nanosaur 9 Jul 19, 2022
A sequence of Jupyter notebooks featuring the 12 Steps to Navier-Stokes

CFD Python Please cite as: Barba, Lorena A., and Forsyth, Gilbert F. (2018). CFD Python: the 12 steps to Navier-Stokes equations. Journal of Open Sour

Barba group 2.6k Dec 30, 2022