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 itertools | |
import matplotlib.pyplot as plt | |
from matplotlib.patches import Rectangle | |
from matplotlib.collections import PatchCollection | |
import numpy as np | |
np.random.seed(1977) | |
def main(): | |
azi = np.random.normal(20, 40, 1000) |
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 | |
import cPickle as pickle | |
def main(): | |
fig, ax = plt.subplots() | |
ax.plot(range(10)) | |
ax.bar(range(10), range(10)) | |
fig2 = copy_figure(fig) | |
fig2.axes[0].plot(range(10)[::-1], color='red') |
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 | |
import h5py | |
def main(): | |
data = read() | |
if sys.argv[1] == 'x': | |
x_slice(data) | |
elif sys.argv[1] == 'z': | |
z_slice(data) |
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 | |
from matplotlib.axes import Axes | |
from matplotlib.patches import Circle | |
from matplotlib.path import Path | |
from matplotlib.ticker import NullLocator, Formatter, FixedLocator | |
from matplotlib.transforms import Affine2D, BboxTransformTo, Transform | |
from matplotlib.projections import register_projection | |
import matplotlib.spines as mspines | |
import matplotlib.axis as maxis | |
import matplotlib.pyplot as plt |
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 | |
x, y = np.mgrid[:10, :10] | |
z = np.hypot(x - 4.5, y - 4.5) | |
#-- Create two masked arrays, one with the upper region and one with the lower. | |
z1 = np.ma.masked_where(y > 5, z) | |
# If we just invert the previous masked region, we'll have a gap. There are | |
# better ways to do this, but for simple cases, we can just ensure a one-pixel |
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
pipeline = sklearn.pipeline.Pipeline([ | |
('Replace nans', | |
preprocessing.Imputer(strategy='mean')), | |
('Scale data', | |
preprocessing.StandardScaler()), | |
('Feature Selection', | |
SelectPercentile(f_regression, percentile=60)), | |
('Regression', | |
ensemble.ExtraTreesRegressor( | |
n_estimators=550, |
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
# -*- coding: utf-8 -*- | |
""" | |
Benchmark for spline interpolation of a 3D wind field, using the function map_coordinates. | |
The spline interpolation is about 46000 times slower than a linear interpolation. | |
It is also about 10000 times slower than an equivalent program, written in the programming | |
language Julia. | |
""" | |
import time | |
import numpy as np | |
from scipy import ndimage |
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 scipy.ndimage as ndimage | |
import numpy as np | |
import matplotlib.pyplot as plt | |
data = np.zeros((40,40), dtype=bool) | |
data[5:20, 5:20] = True | |
data[15:35, 15:35] = True | |
footprint = np.ones((3,3)) | |
outside = ndimage.binary_dilation(data, structure=footprint) - data |
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
931 | Oxfordshire | 9314125 | 123255 | Larkmead School | Abingdon | 125 | 124 | 20 | SUPP | 8 | |
---|---|---|---|---|---|---|---|---|---|---|---|
931 | Oxfordshire | 9314126 | 123256 | John Mason School | Abingdon | 164 | 164 | 25 | 6 | 16 | |
931 | Oxfordshire | 9314127 | 123257 | Fitzharrys School | Abingdon | 150 | 149 | 9 | 0 | 11 | |
931 | Oxfordshire | 9316076 | 123298 | Our Lady's Abingdon | Abingdon | 57 | 57 | SUPP | SUPP | 16 |
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 | |
import numpy as np | |
def main(): | |
t = np.linspace(0, 4*np.pi, 1000) | |
fig, ax = plt.subplots() | |
ax.plot(t, np.cos(t)) | |
ax.plot(t, np.sin(t)) | |
inception(inception(inception(fig))) |