Skip to content

Instantly share code, notes, and snippets.

Stephan Hoyer shoyer

Block or report user

Report or block shoyer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ipnbdoctest.py
#!/usr/bin/env python
"""
simple example script for running and testing notebooks.
Usage: `ipnbdoctest.py foo.ipynb [bar.ipynb [...]]`
Each cell is submitted to the kernel, and the outputs are compared with those stored in the notebook.
"""
import os,sys,time
@shoyer
shoyer / iris_rolling_window.py
Last active Jun 2, 2017
Faster rolling window operations for Iris using Bottleneck
View iris_rolling_window.py
import bottleneck
import iris
import numpy as np
import warnings
def _as_cube_coord(cube, name_or_coord):
"""
Returns the cube coordinate corresponding to given coordinate name or cube
"""
View convert_label_to_indexer.py
import numpy as np
def convert_label_to_indexer(index, label):
"""Given a pandas.Index and labels (e.g., from __getitem__) for one dimension,
return an indexer suitable for indexing an ndarray along that dimension
"""
if isinstance(label, slice):
indexer = index.slice_indexer(label.start, label.stop, label.step)
elif np.isscalar(label):
indexer = indexer.get_loc(label)
View xray-pydata-pv2014.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View xray-repr-examples.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View xray-demo-python-workers-party.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View urbanareas1_1.tsv
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 23 columns, instead of 19. in line 5.
"City" "City_Alternate" "Country" "Latitude" "Longitude" "Country_ISO3" "pop1950" "pop1955" "pop1960" "pop1965" "pop1970" "pop1975" "pop1980" "pop1985" "pop1990" "pop1995" "pop2000" "pop2005" "pop2010" "pop2015" "pop2020" "pop2025" "pop2050"
"Sofia" "" "Bulgaria" 42.70 23.33 "BGR" 520.00 620.00 710.00 810.00 890.00 980.00 1070.00 1180.00 1190.00 1170.00 1130.00 1170.00 1180.00 1210.00 1230.00 1240.00 1236
"Mandalay" "" "Myanmar" 21.97 96.08 "MMR" 170.00 200.00 250.00 310.00 370.00 440.00 500.00 560.00 640.00 720.00 810.00 920.00 960.00 1030.00 1170.00 1310.00 1446
"Nay Pyi Taw" "Myanmar" 19.75 96.10 "MMR" 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 60.00 930.00 1020.00 1180.00 1320.00 1461
"Yangon" "Rangoon" "Myanmar" 16.87 96.12 "MMR" 1300.00 1440.00 1590.00 1760.00 1950.00 2150.00 2380.00 2630.00 2910.00 3210.00 3550.00 3930.00 4090.00 4350.00 4840.00 5360.00 5869
"Minsk" "" "Belarus" 53.89 27.57 "BLR" 280.00 410.00 550.00 720.00 930.00 1120.00 1320.00 1470.00 1610.00 1650.00 1700.00 1780.00 180
View Faceted maps with Seaborn and Cartopy.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View numba ufunc for bottleneck.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View numba_ndreducers.py
"""Proof of concept for implementing bottleneck style aggregators with numba
These functions aggregate over any number of axes, just like the built-in
numpy functions, e.g.,
- nansum(x) # aggregates over all axes
- nansum(x, axis=1) # aggregates over axis 1
- nansum(x, axis=(0, 2)) # aggregtes over axes 0 and 2
"""
import functools
You can’t perform that action at this time.