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
| # Copyright (c) 2016 Nicolas P. Rougier - BSD License | |
| # SI prefixes as name:value | |
| SI_prefix_name_value = { | |
| "yocto": 10e-24, "zepto": 10e-21, "atto": 10e-18, "femto": 10e-15, | |
| "pico": 10e-12, "nano": 10e-9, "micro": 10e-6, "milli": 10e-3, | |
| "centi": 10e-2, "deci": 10e-1, "deca": 10e1, "hecto": 10e2, | |
| "kilo": 10e3, "mega": 10e6, "giga": 10e9, "tera": 10e12, | |
| "peta": 10e15, "exa": 10e18, "zetta": 10e21, "yotta": 10e24 } |
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 find_view(base, view): | |
| """ | |
| Given an array that is a `view` of a `base`, find an index such that | |
| `base[index] is view` | |
| """ | |
| if not isinstance(view, np.ndarray): | |
| return "..." | |
| itemsize = view.itemsize |
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
| # Copyright (2017) Nicolas P. Rougier - BSD license | |
| # Twitter version (140 characters) | |
| # -------------------------------- | |
| _='0' | |
| R,C="{:08b}".format(30),_*9+'1'+_*9 | |
| for k in range(9): | |
| print(C) | |
| C = _+''.join([R[7-eval('0b'+C[i:i+3])] for i in range(len(C)-2)])+_ |
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 numpy import * | |
| from scipy.stats import beta | |
| class BetaBandit(object): | |
| def __init__(self, num_options=2, prior=(1.0,1.0)): | |
| self.trials = zeros(shape=(num_options,), dtype=int) | |
| self.successes = zeros(shape=(num_options,), dtype=int) | |
| self.num_options = num_options | |
| self.prior = prior |
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
| # Author: Jake VanderPlas | |
| # LICENSE: MIT | |
| from __future__ import division | |
| import numpy as np | |
| def convolution_matrix(x, N=None, mode='full'): | |
| """Compute the Convolution Matrix |
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 matplotlib.pyplot as plt | |
| import pandas as pd | |
| import datashader as ds | |
| import datashader.transfer_functions as tf | |
| from datashader.colors import Hot | |
| time_period = 60 |
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
| # ----------------------------------------------------------------------------- | |
| # Copyright (c) 2016 Nicolas P. Rougier. All rights reserved. | |
| # Distributed under the (new) BSD License. | |
| # ----------------------------------------------------------------------------- | |
| import sys | |
| import math | |
| import ctypes | |
| import numpy as np | |
| import OpenGL.GL as gl | |
| import OpenGL.GLUT as glut |
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 json | |
| palettes = json.load(open("material-colors.json")) | |
| levels = [ "L50", "L100", "L200", "L300", "L400", | |
| "L500", "L600", "L700", "L800", "L900", | |
| "A100", "A200", "A400", "A700"] | |
| def enriched_text(t, fg_color, bg_color, space, bold=False): | |
| if bold: u0, u1 = "<bold>", "</bold>" | |
| else: u0, u1 = "", "" | |
| print(f"<x-bg-color><param>{bg_color}</param>" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| (require 'svg) | |
| ;; Rounded boxes using SVG: | |
| ;; This could be made into a function but size of text needs to be computed | |
| (defun tag (text &optional foreground background font-size) | |
| (let* ((font-size (or font-size 12)) | |
| ;; The char-width ratio depends on the font family | |
| (char-width (* font-size 0.58)) | |
| (char-height (+ font-size 1)) |
OlderNewer