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 Graph-to-Tree Learning for Solving Math Word Problems (ACL 2020)

Graph-to-Tree Learning for Solving Math Word Problems PyTorch implementation of Graph based Math Word Problem solver described in our ACL 2020 paper G

Jipeng Zhang 66 Nov 23, 2022
MWPToolkit is a PyTorch-based toolkit for Math Word Problem (MWP) solving.

MWPToolkit is a PyTorch-based toolkit for Math Word Problem (MWP) solving. It is a comprehensive framework for research purpose that integrates popular MWP benchmark datasets and typical deep learning-based MWP algorithms.

null 119 Jan 4, 2023
Incomplete easy-to-use math solver and PDF generator.

Math Expert Let me do your work Preview preview.mp4 Introduction Math Expert is our (@salastro, @younis-tarek, @marawn-mogeb) math high school graduat

SalahDin Ahmed 22 Jul 11, 2022
tinykernel - A minimal Python kernel so you can run Python in your Python

tinykernel - A minimal Python kernel so you can run Python in your Python

fast.ai 37 Dec 2, 2022
Python-experiments - A Repository which contains python scripts to automate things and make your life easier with python

Python Experiments A Repository which contains python scripts to automate things

Vivek Kumar Singh 11 Sep 25, 2022
Crab is a flexible, fast recommender engine for Python that integrates classic information filtering recommendation algorithms in the world of scientific Python packages (numpy, scipy, matplotlib).

Crab - A Recommendation Engine library for Python Crab is a flexible, fast recommender engine for Python that integrates classic information filtering r

python-recsys 1.2k Dec 21, 2022
Python scripts to detect faces in Python with the BlazeFace Tensorflow Lite models

Python scripts to detect faces using Python with the BlazeFace Tensorflow Lite models. Tested on Windows 10, Tensorflow 2.4.0 (Python 3.8).

Ibai Gorordo 46 Nov 17, 2022
A fast python implementation of Ray Tracing in One Weekend using python and Taichi

ray-tracing-one-weekend-taichi A fast python implementation of Ray Tracing in One Weekend using python and Taichi. Taichi is a simple "Domain specific

null 157 Dec 26, 2022
Technical Indicators implemented in Python only using Numpy-Pandas as Magic - Very Very Fast! Very tiny! Stock Market Financial Technical Analysis Python library . Quant Trading automation or cryptocoin exchange

MyTT Technical Indicators implemented in Python only using Numpy-Pandas as Magic - Very Very Fast! to Stock Market Financial Technical Analysis Python

dev 34 Dec 27, 2022
This is an open source python repository for various python tests

Welcome to Py-tests This is an open source python repository for various python tests. This is in response to the hacktoberfest2021 challenge. It is a

Yada Martins Tisan 3 Oct 31, 2021
Composable transformations of Python+NumPy programsComposable transformations of Python+NumPy programs

Chex Chex is a library of utilities for helping to write reliable JAX code. This includes utils to help: Instrument your code (e.g. assertions) Debug

DeepMind 506 Jan 8, 2023
Automatic self-diagnosis program (python required)Automatic self-diagnosis program (python required)

auto-self-checker 자동으로 자가진단 해주는 프로그램(python 필요) 중요 이 프로그램이 실행될때에는 절대로 마우스포인터를 움직이거나 키보드를 건드리면 안된다(화면인식, 마우스포인터로 직접 클릭) 사용법 프로그램을 구동할 폴더 내의 cmd창에서 pip

null 1 Dec 30, 2021
POPPY (Physical Optics Propagation in Python) is a Python package that simulates physical optical propagation including diffraction

POPPY: Physical Optics Propagation in Python POPPY (Physical Optics Propagation in Python) is a Python package that simulates physical optical propaga

Space Telescope Science Institute 132 Dec 15, 2022
Space-invaders - Simple Game created using Python & PyGame, as my Beginner Python Project

Space Invaders This is a simple SPACE INVADER game create using PYGAME whihc hav

Gaurav Pandey 2 Jan 8, 2022
null 2 Jul 19, 2022
Yolov5-opencv-cpp-python - Example of using ultralytics YOLO V5 with OpenCV 4.5.4, C++ and Python

yolov5-opencv-cpp-python Example of performing inference with ultralytics YOLO V

null 183 Jan 9, 2023
Python-kafka-reset-consumergroup-offset-example - Python Kafka reset consumergroup offset example

Python Kafka reset consumergroup offset example This is a simple example of how

Willi Carlsen 1 Feb 16, 2022
Experimental Python implementation of OpenVINO Inference Engine (very slow, limited functionality). All codes are written in Python. Easy to read and modify.

PyOpenVINO - An Experimental Python Implementation of OpenVINO Inference Engine (minimum-set) Description The PyOpenVINO is a spin-off product from my

Yasunori Shimura 7 Oct 31, 2022