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 random | |
def sailor_legend(color, text): | |
text = Text(text, color=BLACK, font_size=24) | |
sailor = ImageMobject(f"sailor-{color}.png").scale(0.15) | |
return Group(sailor, text).arrange(RIGHT) | |
rng = np.random.RandomState(2029) #1989 #2019 | |
class ShipScene(SpaceScene): |
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 scipy.cluster import hierarchy | |
def tree2newick(node, newick, parentdist, leaf_names): | |
if node.is_leaf(): | |
return f"{leaf_names[node.id]}:{parentdist - node.dist:.2f}{newick}" | |
else: | |
if len(newick) > 0: | |
newick = f"):{parentdist - node.dist:.2f}{newick}" | |
else: | |
newick = ");" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 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 | |
class InteractivePlot(object): | |
def __init__(self, id, xlabel, ylabel): | |
self.id = id | |
plt.figure(id) | |
plt.ion() | |
self.xlabel = xlabel | |
self.ylabel = ylabel |
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
#! /usr/bin/env python | |
import numpy as np | |
from heapq import nlargest | |
from itertools import izip | |
from sklearn.feature_extraction.text import CountVectorizer | |
old_settings = np.seterr(all='ignore') | |
def logsum(x): |