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
#include <math.h> | |
#include <iostream> | |
#include <vector> | |
template <class Part> | |
struct PartScorer { | |
struct PartAdapter { | |
double PartArea(const Part& part) = delete; | |
}; |
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
def pretty_data(d): | |
return '\n'.join(data_lines(d)) | |
def data_lines(d, prefix='', last=True, add_bookends=True): | |
def ground(d): | |
return isinstance(d, (str, float, int)) or ground_list(d) or ground_dict(d) | |
def ground_list(d): | |
return isinstance(d, list) and len(d) < 6 and all([isinstance(el, (str, float, int)) for el in d]) |
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
""" | |
Utilities for printing out a nice looking file tree, e.g | |
pretty_tree(('root', [ | |
('a', [ | |
'file1.txt', | |
'file2.txt', | |
]), | |
('b', [ | |
'file1.json', |
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/python3 | |
import argparse | |
import os | |
import subprocess | |
import sys | |
def main(): | |
parser = argparse.ArgumentParser('mirrors an s3 object to local root (~/local-data/s3)') |
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
def summarize_data_shape(example): | |
""" | |
Given some (json serializeable) example, provide a concise summary of its structure | |
by pruning it down to e.g one item per list. | |
like https://github.com/krosaen/data-shapy/blob/master/data_shapy/data_shape.py | |
but handles a best effort summary of class objects and tuples too | |
""" | |
def is_ground(item): |
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
def count_kps_within_poly(polygon, keypoints): | |
from matplotlib.collections import PolyCollection | |
path = PolyCollection([polygon]).get_paths()[0] | |
return np.sum(path.contains_points(keypoints)) | |
assert 2 == count_kps_within_poly( | |
[(0, 0), (100, 0), (200, 100), (100, 100), (0, 100)], | |
[(50, 50), (200, 0), (1, 1)] | |
) |
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 tensorflow as tf | |
def test_feed_independent_graph(): | |
""" | |
Example of a computation graph that depends on a placeholder. | |
How can we feed in values from a queue? As it turns out, you need separate | |
sess.run calls to deq and then feed the graph. | |
""" |