# Matplotlib depends on a few libraries that seem to be missing. Run the following commands to get them.
sudo apt-get install libsm6
sudo apt-get install libxrender1
# Zappa depends on these.
sudo apt-get install libffi-dev
sudo apt-get install libssl-dev
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
figsize(10,5) | |
x = np.linspace(-10,10,10000) | |
y1 = x.astype(np.float32) | |
y2 = x.astype(np.float16) | |
# plt.semilogy(np.abs(x - x)) | |
plt.semilogy(np.abs(x - y1)) | |
plt.semilogy(np.abs(x - y2)) | |
plt.legend(['32','16']) | |
label('Original value','Error','Error when reducing precision of 64-bit floats') |
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
import matplotlib.pyplot as plt | |
import numpy as np | |
%matplotlib inline | |
x = np.arange(256).astype(np.uint8) | |
y = np.array(map(lambda x: np.unpackbits([x]).sum(), x)) | |
figsize(10,5) | |
plt.step(x,y,'k', linewidth = 1) | |
plt.axis([-2,257,0,8.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
import Time exposing (Time) | |
import Graphics.Element exposing (show, image) | |
import Graphics.Collage exposing (collage, path, solid, traced, defaultLine, toForm, move) | |
import Signal | |
import Window | |
import Color exposing (..) | |
import String | |
duration = 60 * 5 | |
multiplier = 0.95 |
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 hashlib | |
def create_block(parent_block, value, hashfunc): | |
""" ------------------------------------------------ | |
String -> Block -> (Block -> String) -> Block | |
------------------------------------------------ | |
Produce a new block from a string value and a hash | |
of its parent block. In this case, a block is also a string. | |
""" |
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 Html exposing (Html, Attribute, text, toElement, fromElement, div, span, input, textarea) | |
import Html.Attributes exposing (placeholder, value, style) | |
import Html.Events exposing (on, targetValue, onClick, onDoubleClick, onMouseDown) | |
import Signal exposing (Address) | |
import String | |
import Array exposing (Array) | |
import Json.Decode as Json | |
import StartApp as StartApp | |
import Dict exposing (Dict) |
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
execfile('/home/bioage/utils/utils.py') | |
import xmltodict #https://github.com/martinblech/xmltodict | |
drugbank_xml_file = "path/to/xml/file" | |
drugbank_json_file = "path/to/json/file" # save json here | |
drugbank_csv_file = "path/to/csv/file" # save csv here | |
# Convert XML to JSON and save | |
drugbank_dict = xmltodict.parse(read_file(drugbank_xml_file)) # takes around 6 minutes | |
write_file(drugbank_json_file, json.dumps(drugbank_dict)) |
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
execfile('viridis.py') | |
from matplotlib.colors import ListedColormap | |
import matplotlib.pyplot as plt | |
import numpy as np | |
%matplotlib inline | |
from PIL import Image | |
def image2array(filename): | |
im = Image.open('logo.jpg') |
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 matplotlib.colors import ListedColormap | |
import matplotlib.pyplot as plt | |
import numpy as np | |
%matplotlib inline | |
# Manuall add Viridis colormap | |
viridis = ListedColormap(_viridis_data, name='viridis') | |
viridis_r = ListedColormap(viridis.colors[::-1]) #reversed | |
def updatePosition(position, direction): |