Skip to content

Instantly share code, notes, and snippets.

View nkeim's full-sized avatar

Nathan Keim nkeim

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nkeim
nkeim / imap_throttled.py
Last active December 13, 2015 00:21
imap_throttled()
def imap_throttled(func, iterable, load_balanced_view=None,
wait_interval=0.05, buffer_factor=3):
"""Asynchronous parallel "imap()" with bounded buffer.
The accumulation of computed results in memory is limited
to 'buffer_factor' times the number of nodes.
Parameters:
func : function
func(x) will be called for each input item, as in map().
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
make notebooks
make -C tutorial notebooks
ipython nbconvert --to rst ../../../trackpy-examples/notebooks/walkthrough.ipynb
[NbConvertApp] Using existing profile dir: u'/Users/nkeim/.ipython/profile_default'
[NbConvertApp] Converting notebook ../../../trackpy-examples/notebooks/walkthrough.ipynb to rst
[NbConvertApp] Support files will be in walkthrough_files/
Traceback (most recent call last):
File "/Users/nkeim/anaconda/bin/ipython", line 6, in <module>
sys.exit(start_ipython())
File "/Users/nkeim/anaconda/lib/python2.7/site-packages/IPython/__init__.py", line 120, in start_ipython
@nkeim
nkeim / fast_hist.py
Created January 4, 2013 20:20
Fast numpy histograms in 1 and 2 dimensions, extensible to n.
import numpy as np
def fast_hist(data, bin_edges):
"""Fast 1-dimensional histogram. Comparable to numpy.histogram(), but careless.
'bin_edges' should encompass all values in 'data'; the first and last elements
in 'bin_edges' are ignored, and are effectively (-infinity, infinity).
Returns the histogram array only.
"""