35 lines
857 B
Python
Raw Normal View History

2024-07-10 07:43:50 +02:00
import os
import matplotlib.pyplot as plt
import numpy as np
import math
import scipy as scp
outdir = "../img/"
filetype = ".pdf"
skipasserts = False
full = 8
size_half_half = (full/2, full/2)
size_third_half = (full/3, full/2)
size_half_third = (full/2, full/3)
def texvar(var, val, math=True):
s = "$" if math else ""
s += f"\\{var} = {val}"
if math: s += "$"
return s
def export(fig, name):
if not skipasserts:
assert os.path.abspath(".").endswith("scripts"), "Please run from the `scripts` directory"
filename = os.path.join(outdir, name + filetype)
fig.savefig(filename, bbox_inches="tight")
@np.vectorize
def smooth_step(x: float, left_edge: float, right_edge: float):
x = (x - left_edge) / (right_edge - left_edge)
if x <= 0: return 0.
elif x >= 1: return 1.
else: return 3*(x**2) - 2*(x**3)