Skip to content

Instantly share code, notes, and snippets.

@cwindolf
cwindolf / noint.py
Last active February 23, 2020 21:12 — forked from tcwalther/delayedinterrupt.py
Interrupt-atomic decorator / context manager
"""noint: Shield a code block or function from SIGINT.
Based on: http://stackoverflow.com/a/21919644/487556.
Useful for running training loops in Jupyter: if your learning
step is inside a `with noint:`, when you want to interrupt your
training routine, you can do that without getting halfway through
some set of operations and leaving the model state inconsistent,
which would make it impossible to rerun the cell without
restarting the whole training loop.
@cwindolf
cwindolf / whiten.py
Last active July 13, 2021 15:30 — forked from joelouismarino/whiten.py
Python library for whitening and coloring data
'''Python library for decorrelating and correlating data
Forked from joelouismarino/whiten.py.
Also based on R's rdrr.io/cran/whitening/src/R/whiteningMatrix.R,
and an SAS blog post:
blogs.sas.com/content/iml/2012/02/08/use-the-cholesky-
transformation-to-correlate-and-uncorrelate-variables.html
'''
import numpy as np
import scipy.linalg as la