This file contains hidden or 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
# Experimental Python implementation of Poisson disk sampling with O(n) space and time complexity. | |
# Reference: https://www.cs.ubc.ca/~rbridson/docs/bridson-siggraph07-poissondisk.pdf | |
import random | |
import numpy as np | |
import matplotlib.pyplot as plt | |
S2 = np.sqrt(2) | |
def runit(r, shape, k=10): |
This file contains hidden or 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
extern crate cpal; | |
extern crate hound; | |
use std::f32; | |
use std::sync::{Arc, Mutex}; | |
use std::sync::atomic::{AtomicBool, Ordering}; | |
use std::thread; | |
use std::ops; | |
use cpal::{StreamData, UnknownTypeOutputBuffer}; |
This file contains hidden or 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
use std::ops::{Add, Mul}; | |
use std::fmt::{self, Debug}; | |
trait Expression: Sized + Clone { | |
fn add<Other: Expression>(self, rhs: Other) -> Addition<Self, Other> { | |
Addition { | |
lhs: self, | |
rhs, | |
} | |
} |
This file contains hidden or 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
use std::ops::{Add, Sub, Mul, Div}; | |
use std::fmt::{self, Debug}; | |
#[derive(Clone)] | |
enum Expression { | |
Zero, | |
One, | |
Constant(f64), | |
Variable(&'static str), | |
Add(Box<Expression>, Box<Expression>), |
This file contains hidden or 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 itertools | |
import functools | |
class FriendlyIter: | |
def __init__(self, it): | |
self.it = iter(it) | |
def __iter__(self): | |
return self | |
This file contains hidden or 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 scipy.ndimage as ndimage | |
import random | |
import matplotlib.pyplot as plt | |
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA | |
from sklearn.tree import DecisionTreeClassifier | |
from sklearn.naive_bayes import GaussianNB | |
from sklearn.neural_network import MLPClassifier |
This file contains hidden or 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 collections import Counter | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy import ndimage | |
from heapq import * | |
from scipy.optimize import linear_sum_assignment | |
MOVE_FACTOR = 10 |
This file contains hidden or 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
use num::complex::Complex; | |
use std::f64; | |
fn ditfft2(x: &[Complex<f64>], n: usize, s: usize) -> Vec<Complex<f64>> { | |
if n == 1 { | |
return vec![x[0]]; | |
} | |
let mut out: Vec<_> = ditfft2(x, n / 2, s * 2) | |
.into_iter() |
This file contains hidden or 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 | |
import scipy as sp | |
from scipy import integrate as spi | |
from scipy import signal | |
DIFFUSION_COEFFICIENT = 10 | |
EVAPORATION_RATE = 1 | |
DECAY_RATE = 0.25 |
This file contains hidden or 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
// `error_chain!` can recurse deeply | |
#![recursion_limit = "1024"] | |
#[macro_use] | |
extern crate error_chain; | |
use std::collections::HashMap; | |
use std::fmt::Debug; | |
use std::rc::Rc; |