Skip to content

Instantly share code, notes, and snippets.

View marcelcaraciolo's full-sized avatar
💭
Coding !

Marcel Caraciolo marcelcaraciolo

💭
Coding !
View GitHub Profile
import itertools
import matplotlib.pyplot as plt
import numpy as np
colors = itertools.cycle(['r','g','b','c','y','m','k'])
markers = itertools.cycle(['o','s','v'])
fig = plt.figure()
ax = fig.add_subplot(111)
for i in range(5):
@marcelcaraciolo
marcelcaraciolo / scatter.py
Created August 28, 2013 13:59
Sample example of tagging labels each point on ScatterPlot
y=[2.56422, 3.77284,3.52623,3.51468,3.02199]
z=[0.15, 0.3, 0.45, 0.6, 0.75]
n=[58,651,393,203,123]
fig, ax = plt.subplots()
ax.scatter(z, y)
for i, txt in enumerate(n):
ax.annotate(txt, (z[i],y[i]))
def _save_categories(curso_id_in_supplier, category):
from shop.models import Category, CourseCategories, Course
c_c = CourseCategories()
c_c.course = Course.objects.get(id_in_supplier=curso_id_in_supplier, supplier=IOB)
try:
c_c.category = Category.objects.get(slug=category)
except Category.DoesNotExist:
ct = Category()
ct = category
def _save_curso(id_in_supplier, name, description, periodo_acesso):
from shop.models import Course
from product.models import Price, Product
try:
return Course.objects.get(id_in_supplier=id_in_supplier, supplier=IOB)
except Course.DoesNotExist:
try:
p = Product.objects.get(name=name)
p.delete()
except Product.DoesNotExist:
common_setup = """
import numpy
from crab.metrics import cosine_distances
X = numpy.random.uniform(1,5,(1000,))
"""
bench = Benchmark(statement, setup_bk1, name="Crab Cosine")
suite = BenchmarkSuite()
suite.append(bench)
import sqlite3
class BenchmarkDb(object):
"""
Persistence handler for bechmark results
"""
def _create_tables(self):
self._cursor.execute("drop table if exists benchmarksuites")
self._cursor.execute("drop table if exists benchmarks")
class BenchmarkRepository(object):
"""
Manage an isolated copy of a repository for benchmarking
"""
...
def _copy_repo(self):
if os.path.exists(self.target_dir):
print 'Deleting %s first' % self.target_dir
# response = raw_input('%s exists, delete? y/n' % self.target_dir)
class BenchmarkGitRunner(object):
...
def run(self):
revisions = self._get_revisions_to_run()
for rev in revisions:
any_succeeded, n_active = self._run_and_write_results(rev)
if not any_succeeded and n_active > 0:
class GitRepository(Repository):
"""
Read some basic statistics about a git repository
"""
def __init__(self, repo_path):
self.repo_path = repo_path
self.git = _git_command(self.repo_path)
(self.shas, self.messages,
import re import math
def getwords(doc):
splitter=re.compile('\\W*') # Split the words by non-alpha characters
words=[s.lower() for s in splitter.split(doc) if len(s)>2 and len(s)<20]
# Return the unique set of words only
return dict([(w,1) for w in words])