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 | |
def your_function(x): | |
return x * np.random.rand() | |
# Repeatedly calling this, | |
# pytest --caprng-global-np | |
# from the command line will fail with the same values | |
# over and over again until it passes. |
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
def portray_neighborhood_offsets(C, origin, dist_func=None): | |
C = C.copy() | |
C[origin] = 2 | |
fig, ax = plt.subplots(1, 1) | |
ax.imshow(C, | |
interpolation='nearest', # Not 'none'! | |
aspect='equal', | |
cmap=plt.cm.Purples) | |
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 sys, locale | |
exprs = """ | |
locale.getpreferredencoding() | |
type(fp) | |
fp.encoding | |
sys.stdout.isatty() | |
sys.stdout.encoding | |
sys.stdin.isatty() |
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 matplotlib.pyplot as plt | |
from ipykernel.pylab.backend_inline import flush_figures | |
from IPython.display import display, clear_output, SVG | |
def replot_as_svg(fig=None, **adjustments): | |
""" | |
Take a given matplotlib figure and write it as an embeddable SVG. | |
:param fig: the matplotlib figure or None for implicit use of plt.gcf() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
from lxml.etree import fromstring, tostring | |
def hatch_safe_svg(data): | |
# rsvg-convert doesn't resolve <pattern> fills from #fragment | |
# URIs if they occur downfile from the usage. This makes sure | |
# definitions come first. | |
doc = fromstring(data) | |
defs = [el for el in doc.getchildren() | |
if el.tag == "{http://www.w3.org/2000/svg}defs"] |
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
geo $congress { | |
# See: @congressedits | |
} | |
server { | |
if ($congress) { | |
rewrite ^ http://www.example.com/meta_random_refresh_original.html; | |
} | |
} |
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
#!/bin/bash | |
############################################################################### | |
# setUp | |
############################################################################### | |
# Fail on first non-zero return value. | |
set -ev | |
# Ensure a pristine environment. |
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
language: python | |
python: | |
- "2.7" | |
- "3.3" | |
- "3.4" | |
- "3.5" | |
install: | |
- "pip install -r requirements.txt" | |
- "pip install coveralls nose" | |
script: |
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ |