Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@joezuntz
joezuntz / i3table.py
Last active December 31, 2015 03:48
Example of Table subclass helper for astropy. Uses our I3Table as an example.
import astropy.io.fits
import astropy.table
import astropy.io.registry
class I3Table(astropy.table.Table):
""" Im3shape table class. Same as a standard table except it supports
attribute style column access ("table.e1") and does not try to print itself
out when repr'd interactively.
"""
@minrk
minrk / nbstripout
Last active June 6, 2023 06:23
git pre-commit hook for stripping output from IPython notebooks
#!/usr/bin/env python
"""strip outputs from an IPython Notebook
Opens a notebook, strips its output, and writes the outputless version to the original file.
Useful mainly as a git filter or pre-commit hook for users who don't want to track output in VCS.
This does mostly the same thing as the `Clear All Output` command in the notebook UI.
LICENSE: Public Domain
@dfm
dfm / astrofrog.py
Created December 1, 2012 02:16
Stochastic gradient descent example
import numpy as np
N = 5000
I_true = np.random.randn(N)
D = I_true[:, None] - I_true[None, :]
I0 = np.zeros_like(I_true)
eta = 1.0 / N # Learning rate.
tol = 1.25e-11 # Error tolerance.