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
| Type: IPython Notebook Extension | |
| Compatibility: 3.x 4.x | |
| Main: main.js | |
| Name: Hide cell number | |
| Description: "toggle number of all cells" |
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
| __all__ = ['recordtype'] | |
| import sys | |
| from textwrap import dedent | |
| from keyword import iskeyword | |
| def recordtype(typename, field_names, verbose=False, **default_kwds): | |
| '''Returns a new class with named fields. |
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 rand_rotmat(n): | |
| # http://www.realtimerendering.com/resources/GraphicsGems/gemsiii/rand_rotation.c | |
| import numpy as np | |
| theta, phi, z = np.random.rand(3, n) * 2 | |
| theta *= np.pi | |
| phi *= np.pi | |
| r = np.sqrt(z) | |
| Vx = np.sin(phi) * r |
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 __future__ import division, print_function, absolute_import | |
| import numpy as np | |
| from matplotlib import pyplot as plt | |
| def steps(x, y, *args, **kwargs): | |
| '''steps(x, y, *args, style='line', bottom=0, **kwargs) | |
| Make a step plot. | |
| The interval from x[i] to x[i+1] has level y[i] | |
| This function is useful for show the results of np.histogram. |
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 scipy.stats.mvn import mvnun as mvn_cdf | |
| from scipy.stats import kstwobign, pearsonr | |
| from __future__ import division | |
| def quadct(xx, yy): | |
| n = len(xx) | |
| res = np.empty((n, 4), 'float') | |
| for i in range(n): | |
| ix1, ix2 = xx <= xx[i], yy <= yy[i] | |
| a = np.sum( ix1 & ix2) |
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 | |
| from scipy.stats import gaussian_kde | |
| def denscatter(x, y, xsacle=1, yscale=1, sort=False, **kwargs): | |
| kwargs.setdefault('edgecolor', 'none') | |
| if xscale != 1: | |
| x = x / xscale | |
| if yscale != 1: | |
| y = y / yscale |
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
| #!/usr/bin/env python | |
| import sys | |
| import bibtexparser | |
| if len(sys.argv) == 2: | |
| fn = sys.argv[-1] | |
| fout = None | |
| elif len(sys.argv) == 3 and sys.argv[1] == "-i": | |
| fn = sys.argv[-1] | |
| fout = fn |
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 plot_binquantile(x, y, bins=10, weights=None, nmin=3, nanas=None, | |
| kwargs_sig2=None, **kwargs): | |
| from .stats import binquantile, mid | |
| from .helper import errorbar2 | |
| nsig = [0, -1, 1, -2, 2] | |
| quantile = binquantile(x, y, bins=bins, weights=weights, | |
| nsig=nsig, nmin=nmin, nanas=nanas, | |
| shape='stats') | |
| stats, edges, count = quantile |
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 | |
| cimport numpy as np | |
| np.import_array() | |
| cimport cython | |
| from libc.stdlib cimport malloc, free | |
| cdef extern from "numpy/arrayobject.h": | |
| void PyArray_ENABLEFLAGS(np.ndarray arr, int flags) |
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
| # cython: boundscheck=False, wraparound=False | |
| # distutils: extra_compile_args = -fopenmp | |
| # distutils: extra_link_args = -fopenmp | |
| from cython.parallel import prange | |
| from libc.math cimport exp, sqrt | |
| import numpy as np | |
| cdef double pi = np.pi | |
| cdef double tau = np.pi * 2 |