Skip to content

Instantly share code, notes, and snippets.

View bolverk's full-sized avatar

Almog Yalinewich bolverk

View GitHub Profile
@bolverk
bolverk / ellipse_approximation.py
Last active February 2, 2025 16:21
numerical optimal experimental design with three replicas
import sympy
alpha, beta, x, y, A, B, s, mu = sympy.symbols('alpha beta x y A B s mu', real=True)
A, B = sympy.symbols('A B', positive=True)
sin_vec = [sympy.sin(alpha)+sympy.sin(alpha-beta),
sympy.sin(beta)+sympy.sin(beta-alpha)]
symmetric_component = sin_vec[0] + sin_vec[1]
antisymmetric_component = sin_vec[0] - sin_vec[1]
e1 = sympy.Matrix([1,1])
@bolverk
bolverk / debris_scatter.py
Created January 1, 2025 07:25
debris scatter
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import matplotlib
from tqdm import tqdm
matplotlib.rcParams.update({'font.size': 22})
@bolverk
bolverk / stone_game.py
Created November 13, 2024 19:07
stone game
from functools import cache
def play_left(board):
return board[0], board[1:]
def play_right(board):
return board[-1], board[:-1]
@bolverk
bolverk / load_call_tree_from_tables.py
Last active May 9, 2024 05:43
Visualise graphs using plotly
import igraph as ig
def load_call_tree_from_tables(nodes, methods):
method_id2method_name = methods.set_index('method_id')['method_name'].to_dict()
vertices = list(map(str, nodes['node_id'].values))
children = list(map(str, nodes['node_id'].iloc[1:]))
parents = list(map(str, nodes['parent_id'].iloc[1:]))
g = ig.Graph(directed=True)
g.add_vertices(vertices)
g.add_edges(zip(parents, children))
@bolverk
bolverk / diffusion_animation.ipynb
Created July 13, 2022 19:53
diffusion animation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bolverk
bolverk / housing_competition.ipynb
Created July 13, 2022 18:58
housing kaggle competition
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bolverk
bolverk / dark_dimension.py
Created June 29, 2022 10:58
A demonstration of pdb's interact command with the Dormammu scene from Dr. Strange
from fake_typing import fake_typing
class Dormammu:
def __init__(self):
self.name = 'Dormammu'
self.counter = 0
def consider(self):
@bolverk
bolverk / brute_force.py
Last active May 8, 2022 12:20
fizz buzz without conditionals
class Naturals:
def __init__(self):
self.n = 1
def next(self):
res = self.n
self.n += 1
return res
@bolverk
bolverk / go_fish.py
Created March 12, 2022 03:58
Go fish monte carlo simulator
"""
Simulate a go fish game
"""
import random
def make_deck(n):
"""
Create and shuffle a deck of cards
@bolverk
bolverk / funcquery.py
Created February 17, 2022 19:51
Display output of internal functions
import sympy
from argparse import ArgumentParser
def get_input():
parser = ArgumentParser(description='show output of void function')
parser.add_argument('fname',
type=str,
help='name of function')
args = parser.parse_args()