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
$ pip install pytetgen | |
Collecting pytetgen | |
Using cached pytetgen-0.1.4.tar.gz (392 kB) | |
Building wheels for collected packages: pytetgen | |
Building wheel for pytetgen (setup.py) ... error | |
ERROR: Command errored out with exit status 1: | |
command: 'C:\Users\thomasaar\Miniconda3\envs\py38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\thomasaar\\AppData\\Local\\Temp\\pip-install-xphrb4j7\\pytetgen_dc8134ee876b4f18b1a1373353bd0c09\\setup.py'"'"'; __file__='"'"'C:\\Users\\thomasaar\\AppData\\Local\\Temp\\pip-install-xphrb4j7\\pytetgen_dc8134ee876b4f18b1a1373353bd0c09\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\thomasaar\AppData\Local\Temp\pip-wheel-igdis3c8' | |
cwd: C:\Users\thomasaar\AppData\Local\Temp\pip-install-xphrb4j7\pytetgen_dc8134ee876b4f18b1a1373353bd0c09\ | |
Complete output (339 lines): | |
running bdist_whee |
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 | |
import matplotlib.pyplot as plt | |
Arc = matplotlib.patches.Arc | |
def halfangle(a, b): | |
"Gets the middle angle between a and b, when increasing from a to b" | |
if b < a: | |
b += 360 | |
return (a + b)/2 % 360 |
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
def row_roll(arr, shifts, axis=1, fill=np.nan): | |
"""Apply an independent roll for each dimensions of a single axis. | |
Parameters | |
---------- | |
arr : np.ndarray | |
Array of any shape. | |
shifts : np.ndarray, dtype int. Shape: `(arr.shape[:axis],)`. | |
Amount to roll each row by. Positive shifts row right. |
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 sympy as sp | |
import matplotlib.pyplot as plt | |
import numpy as np | |
def Gaussian(x, a, xc, sigma): | |
return a*sp.exp(-((x-xc)**2)/(2*sigma**2)) | |
x, i, n = sp.symbols('x i n') # x is our main independent variable. i and n are indices | |
a, xc, sigma = sp.symbols('A xc sigma', cls=sp.IndexedBase) # parameters that are held in arrays | |
symbols = (x, a, xc, sigma, n) |
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
export PROMPT_DIRTRIM=2 | |
export PS1="\[\e[0m\](\[\e[32;40m\]\$CONDA_DEFAULT_ENV\[\e[0m\]) \[\e[36;40m\]\w: \[\e[0m\]" |
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
// Uses the cargo-aoc crate to help take care of inputs and benchmarks | |
use aoc_runner_derive::{aoc, aoc_generator}; | |
use std::num::ParseIntError; | |
#[aoc_generator(day1)] | |
fn parse_input_day1(input: &str) -> Result<Vec<i32>, ParseIntError> { | |
input.lines().map(|l| l.parse()).collect() | |
} | |
#[aoc(day1, part1)] |
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 | |
with open("input01.txt") as f: | |
a = f.read() | |
data = np.array([int(n) for n in a.split("\n")[:-1]]) | |
def first(data): | |
for i, number in enumerate(data): | |
for number2 in data[i:]: | |
if number + number2 == 2020: |
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
%matplotlib qt | |
import numpy as np | |
import matplotlib.pyplot as plt | |
fig, ax1 = plt.subplots(ncols=1) | |
fig2, ax2 = plt.subplots(ncols=1) | |
imdata = np.random.random((20,20)) | |
im = ax1.imshow(imdata, animated=True) |
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
ffmpeg -r 20 -i img_%03d.png -c:v libx264 -pix_fmt yuv420p -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -y out.mp4 |
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 | |
from scipy.constants import electron_mass, elementary_charge, c, hbar, h | |
def relativistic_wavelength(kV=300): | |
"Returns relativistic wavelength in meters" | |
V = 1e3 * kV | |
top = h * c | |
bottom = np.sqrt( | |
elementary_charge * V * (2 * electron_mass * c ** 2 + elementary_charge * V) | |
) |