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.pyplot as plt | |
| class bwdrawer: | |
| """Draw one pixel at a time on a black and white canvas. | |
| Usage (in a script or a repl): | |
| ``` | |
| drawer = bwdrawer(my_width, my_height) |
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 | |
| class _redder: | |
| """Syntactic sugar for reductions in numpy. | |
| Users interact with the global instance `rdr` defined below rather | |
| than using this class itself. | |
| Probably a dumb idea but whatever. Basically a sugar to batch out |
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
| #!/usr/bin/env python3 | |
| r"""teqn | |
| Quickly turn your math mode expression into cropped png, svg, or pdf. | |
| Then you can drag and drop it into slack or illustrator or whatever. | |
| This is basically just a wrapper around the standalone document class. | |
| Pass your math expression (in quotes) on the command line. It will be | |
| typeset in the align* environment by default, unless you pass --nomath, | |
| in which case you can put the environment in the expression too. |
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
| """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. |
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
| '''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 |
NewerOlder