Skip to content

Instantly share code, notes, and snippets.

View bgailleton's full-sized avatar
🦕
🦕 🦕 🦕 🦕 🦕 🦕

Boris Gailleton bgailleton

🦕
🦕 🦕 🦕 🦕 🦕 🦕
View GitHub Profile
@kbarbary
kbarbary / cpptest.pyx
Created May 11, 2017 15:29
Example: Using cython, convert numpy.ndarray to C++ std::valarray and back (using copies)
"""example of converting a numpy array to a C++ valarray and back in cython
using copies.
Compile with `python setup.py build_ext --inplace`
Example
-------
>>> import cpptest, numpy as np
>>> x = np.array([0., 1., 2.])
@jakevdp
jakevdp / discrete_cmap.py
Last active June 1, 2025 11:15
Small utility to create a discrete matplotlib colormap
# By Jake VanderPlas
# License: BSD-style
import matplotlib.pyplot as plt
import numpy as np
def discrete_cmap(N, base_cmap=None):
"""Create an N-bin discrete colormap from the specified input map"""