View spline_interpolation.py
This file contains 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 | |
from scipy import ndimage | |
SPLINE_ORDER = 3 | |
def b_spline(x): | |
"""Computes 3rd order B-spline at x.""" | |
x = np.fabs(x) | |
b_spline = np.zeros_like(x, dtype=float) | |
mask = x < 1.0 |
View dtype_compat.py
This file contains 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 __future__ import division, print_function | |
from numpy import object_ | |
from fractions import gcd | |
def get_object_offsets(dtype, base_offset=0): | |
offsets = [] | |
if dtype.fields is not None: | |
for field in dtype.fields.values(): |
View gist:8743836
This file contains 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
-------------+---------+-----------------+----------------- | |
bins len | old | new (naive) | new (opt.) | |
-------------+---------+-----------------+----------------- | |
3 3 | 8.2e-07 | 8.2e-07 (1.00x) | 8.2e-07 (1.00x) | |
3 10 | 8.2e-07 | 8.2e-07 (1.00x) | 8.2e-07 (1.00x) | |
3 30 | 8.2e-07 | 8.2e-07 (1.00x) | 8.2e-07 (1.00x) | |
3 100 | 9.8e-07 | 8.3e-07 (1.18x) | 8.2e-07 (1.20x) | |
3 300 | 1.6e-06 | 1.2e-06 (1.33x) | 1.2e-06 (1.33x) | |
3 1000 | 3.0e-06 | 2.5e-06 (1.20x) | 2.5e-06 (1.20x) | |
3 3000 | 7.3e-06 | 6.3e-06 (1.16x) | 7.9e-06 (0.92x) |
View gist:8704101
This file contains 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
-----------------+------------------------+------------------------ | |
searchsorted | floats | ints | |
-----------------+------------------------+------------------------ | |
haystack needle | old new gain | old new gain | |
-----------------+------------------------+------------------------ | |
5 2 | 1.60e-06 1.64e-06 1.0x | 1.64e-06 1.64e-06 1.0x | |
5 10 | 1.65e-06 1.65e-06 1.0x | 1.64e-06 1.64e-06 1.0x | |
5 50 | 2.21e-06 2.03e-06 1.1x | 2.11e-06 1.69e-06 1.2x | |
5 200 | 4.98e-06 3.05e-06 1.6x | 4.53e-06 2.56e-06 1.8x | |
5 1000 | 2.54e-05 1.03e-05 2.5x | 2.12e-05 8.39e-06 2.5x |
View gist:8424247
This file contains 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 __future__ import division | |
import numpy as np | |
import timeit | |
import matplotlib.pyplot as plt | |
haystack_sizes = np.linspace(2, 250, num=20, endpoint=True) | |
needle_sizes = np.array([10, 20, 50, 100, 200, 500 ,1000, 10000, 20000]) | |
codes = ['np.searchsorted(haystack, needle)', | |
'np.fastsearchsorted(haystack, needle)', |
View whats_new_numpy_1.8
This file contains 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
{ | |
"metadata": { | |
"name": "What's new in numpy 1.8" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |