Skip to content

Instantly share code, notes, and snippets.

View fperez's full-sized avatar

Fernando Perez fperez

View GitHub Profile
"""Callable object, to test various parts of ipython's info system.
Run this file and then do f(, g( or c( or c.method( in the qt gui to see the
various tooltips.
"""
class Call(object):
"""This is the class docstring."""
def __init__(self, x, y=1):
@fperez
fperez / bin_perm_rep.py
Created February 13, 2011 23:57
Permutations with repetitions
import numpy as np
def bin_perm_rep(ndim,a=0,b=1):
"""bin_perm_rep(ndim) -> ndim permutations with repetitions of (a,b).
Returns an array with all the possible permutations with repetitions of
(0,1) in ndim dimensions. The array is shaped as (2**ndim,ndim), and is
ordered with the last index changing fastest. For examble, for ndim=3:
Examples:
// Another change
// Testing gists on the web
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google AJAX Language API - Basic Transliteration</title>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript">
@fperez
fperez / lp2gh-issues.py
Created February 20, 2011 01:14
Conversion from Launchpad bugs to GitHub ones
#!/usr/bin/env python
"""Launchpad to github bug migration script.
There's a ton of code from Hydrazine copied here:
https://launchpad.net/hydrazine
WARNING: this code was written for the Github issues v2 API, and has *not* been ported to v3. If anyone finds it useful and ports it, please drop me a pull request.
Usage
-----
@fperez
fperez / contour_overlap.py
Created March 9, 2011 20:23
Matplotlib contours with overlap control
"""Contours with overlap control.
This script generates widely spaced black contours, with a gray patch in a
subregion where more finely-spaced colored contours are visible. The gray
patch covers the black contours.
"""
import numpy as np
import matplotlib.mlab as mlab
from matplotlib.patches import Rectangle
@fperez
fperez / unicode.py
Created March 25, 2011 02:44 — forked from minrk/unicode.py
#!/usr/bin/env python
# -*- encoding: utf-8
#from IPython.external
import sys
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
paa = parser.add_argument
@fperez
fperez / gist:912014
Created April 10, 2011 03:19
test failures
======================================================================
ERROR: test pushing and pulling functions
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/fperez/usr/lib/python2.6/site-packages/IPython/parallel/tests/test_view.py", line 92, in test_push_pull_function
self.assertEqual(r(1.0), testf(1.0))
TypeError: 'AsyncResult' object is not callable
======================================================================
FAIL: test_queue_status (IPython.parallel.tests.test_client.TestClient)
@fperez
fperez / param2normal.py
Created May 31, 2011 22:52
Convert nose parametric tests to normal ones
#!/usr/bin/env python
"""Simple script to remove nose-style parametric tests and turn them into
normal ones.
Usage:
param2normal.py file1.py file2.py ...
By default it overwrites the files in-place, you can change that below in the
__main__ section.
@fperez
fperez / error.py
Created November 15, 2011 18:38
A simple file with an error for testing interactive debugging
#!/usr/bin/env python
"""
file with deliberate errors to check IPython.
"""
from numpy import *
import time,sys
import sys
@fperez
fperez / mpl_test.log
Created December 7, 2011 00:18
Log of matplotlib test run
longs[junk]> nosetests matplotlib
/home/fperez/usr/opt/lib/python2.7/site-packages/matplotlib/__init__.py:923: UserWarning: This call to matplotlib.use() has no effect
because the the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
if warn: warnings.warn(_use_error_msg)
/home/fperez/usr/opt/lib/python2.7/site-packages/matplotlib/font_manager.py:1210: UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to Bitstream Vera Sans
(prop.get_family(), self.defaultFamily[fontext]))