This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun arrow-right-xpm (color1 color2) | |
"Return an XPM right arrow string representing." | |
(format "/* XPM */ | |
static char * arrow_right[] = { | |
\"12 18 2 1\", | |
\". c %s\", | |
\" c %s\", | |
\". \", | |
\".. \", | |
\"... \", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2016 Nicolas P. Rougier - BSD License | |
# SI prefixes as name:value | |
SI_prefix_name_value = { | |
"yocto": 10e-24, "zepto": 10e-21, "atto": 10e-18, "femto": 10e-15, | |
"pico": 10e-12, "nano": 10e-9, "micro": 10e-6, "milli": 10e-3, | |
"centi": 10e-2, "deci": 10e-1, "deca": 10e1, "hecto": 10e2, | |
"kilo": 10e3, "mega": 10e6, "giga": 10e9, "tera": 10e12, | |
"peta": 10e15, "exa": 10e18, "zetta": 10e21, "yotta": 10e24 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------------------------------------------------------- | |
# Copyright (c) 2016 Nicolas P. Rougier. All rights reserved. | |
# Distributed under the (new) BSD License. | |
# ----------------------------------------------------------------------------- | |
import sys | |
import math | |
import ctypes | |
import numpy as np | |
import OpenGL.GL as gl | |
import OpenGL.GLUT as glut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------------------------------------------------------- | |
# Copyright (c) 2016, Nicolas P. Rougier | |
# Distributed under the (new) BSD License. | |
# ----------------------------------------------------------------------------- | |
import sys, math | |
def progress(value, length=40, title = " ", vmin=0.0, vmax=1.0): | |
""" | |
Text progress bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def binomial(n, k): | |
""" | |
A fast way to calculate binomial coefficients by Andrew Dalke. | |
See http://stackoverflow.com/questions/3025162/statistics-combinations-in-python | |
""" | |
if 0 <= k <= n: | |
ntok = 1 | |
ktok = 1 | |
for t in xrange(1, min(k, n - k) + 1): | |
ntok *= n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(make-face 'face-admonition) | |
(set-face-attribute 'face-admonition nil | |
:height 120 | |
:weight 'regular | |
:foreground "white" | |
:background "light gray" | |
:box '(:line-width 1 :color "light gray")) | |
(defvar face-admonition 'face-admonition) | |
(make-face 'face-admonition-note) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
def maze(shape=(64,64), complexity=.95, density = 1): | |
# Only odd shapes | |
shape = ((shape[0]//2)*2+1, (shape[1]//2)*2+1) | |
# Adjust complexity and density relative to maze size | |
complexity = int(complexity*(5*(shape[0]+shape[1]))) | |
density = int(density*(shape[0]//2*shape[1]//2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------------------------------------------------------- | |
# From https://en.wikipedia.org/wiki/Minkowski–Bouligand_dimension: | |
# | |
# In fractal geometry, the Minkowski–Bouligand dimension, also known as | |
# Minkowski dimension or box-counting dimension, is a way of determining the | |
# fractal dimension of a set S in a Euclidean space Rn, or more generally in a | |
# metric space (X, d). | |
# ----------------------------------------------------------------------------- | |
import scipy.misc | |
import numpy as np |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_view(base, view): | |
""" | |
Given an array that is a `view` of a `base`, find an index such that | |
`base[index] is view` | |
""" | |
if not isinstance(view, np.ndarray): | |
return "..." | |
itemsize = view.itemsize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy.spatial import Voronoi | |
def voronoi_finite_polygons_2d(vor, radius=None): | |
""" | |
Reconstruct infinite voronoi regions in a 2D diagram to finite | |
regions. | |
Parameters |
OlderNewer