Skip to content

Instantly share code, notes, and snippets.

@joezuntz
joezuntz / mpi4py_trivial.py
Created February 5, 2015 15:41
Simplest possible mpi4py job splitting
#Suppose you have a collection of tasks, which in this example I'll assume is just running a function f.
#If these tasks are completely separate and independent the most then you can parallelize them easily.
#In this gist I'll show the simplest possible way to do this using mpi4py.
#There are better ways to do this, in particular if the tasks vary significantly in time taken to run.
import mpi4py.MPI
def f(i):
"A fake task - in this case let just open a file and write a number to it"
#open file with name based on task number
@joezuntz
joezuntz / valentine.py
Created February 14, 2015 18:41
A Short St. Valentine's Day Python Snippet
import pylab as pl
import numpy as np
Z=-1j*np.array([np.exp(1.j*2**i) for i in xrange(100)])
pl.plot(0.5*Z.real, Z.imag, '-', color='#FF69B4')
pl.show()
{
"metadata": {
"kernelspec": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"display_name": "IPython (Python 2)",
"language": "python",
"name": "python2"
@joezuntz
joezuntz / extract_deliverables.py
Created October 12, 2015 12:38
Parser for the LSST DESC SRM
import glob
import re
import pyparsing as pp
import collections
def parse_projects(text):
#the list which will contain the located projects
projects = []
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@joezuntz
joezuntz / im3shape-psfex-example.ipynb
Created July 12, 2016 16:23
im3shape psfex example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# PSFEx Im3shape Example"
]
},
{

Some guidelines for statisticians/mathematicians writing samplers and minimizers if they want them to be useful to scientists.

  • We don't need bespoke, highly-trained algorithms: we need general methods that need minimal human supervision.
  • If your algorithm isn't parallel then it is unlikely to be useful (we have a lot of CPUs).
  • We don't have the derivative of the likelihood in most cases. It's hard enough calculating the likelihood itself.
  • Dumb down the paper a little for us; we spend most of our time doing other things.
  • If you supply some code along with your algorithm we are vastly more likely to at least give it a try.
  • Write your code in Python or C (or maybe C++ if you must). We need to integrate your it into more general frameworks, not statistical toolboxes.
  • Write your code as a library that we can call from our own programmes, not as a top-level program on its own.
  • Don't do I/O yourself in your code. We'll handle that, just return some samples/values/metadata/whatever.