Skip to content

Instantly share code, notes, and snippets.

View KristianHolsheimer's full-sized avatar

Kristian Holsheimer KristianHolsheimer

View GitHub Profile
@KristianHolsheimer
KristianHolsheimer / reload_recursive.py
Last active April 12, 2024 17:36
Recursive reload function (and ipython magic) that does a depth-first search through all sub-modules and reloads them in the correct order of dependence.
import logging
from types import ModuleType
from importlib import reload, import_module
from IPython.core.magic import register_line_magic, register_cell_magic
logger = logging.getLogger(__name__)
def _reload(module, reload_all, reloaded):
if isinstance(module, ModuleType):
@KristianHolsheimer
KristianHolsheimer / running_times_plots.py
Last active March 16, 2020 02:34
Code for generating plots running times for PR
from random import randint
from timeit import timeit
import pandas as pd
import numpy as onp
import matplotlib.pyplot as plt
def unzip(tuples):
return tuple(zip(*tuples))
#/usr/bin/env python2.7
import numpy as np
import gym
def value(observation):
"""
This value function is just the (negative) Lagrangian: