Skip to content

Instantly share code, notes, and snippets.

View howardhamilton's full-sized avatar
💭
Still here...

Howard Hamilton howardhamilton

💭
Still here...
  • Atlanta, GA, USA
View GitHub Profile
@howardhamilton
howardhamilton / pitch.py
Last active January 4, 2021 13:06
Normalized football pitch written with matplotlib package
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as pch
import matplotlib.image as img
def create_normalized_pitch(size=(12.5, 8.0), pcolor='none', ecolor='black'):
"""
Create figure that has football pitch lines drawn on it. Figure coordinates are normalized to a 100x100 grid.
If aspect ratio of figure is not equal to 1.5625 (12.5 in / 8.0 in), the figure width is
@howardhamilton
howardhamilton / hinton.py
Created July 25, 2018 21:51
Hinton diagram on a football pitch
import numpy as n
import pylab as p
from matplotlib.patches import Rectangle
from matplotlib.collections import PatchCollection
from pitch import create_normalized_pitch
def _add_centered_square(xy, area):
size = n.sqrt(area)
@howardhamilton
howardhamilton / multipro.py
Created October 3, 2018 20:29
Multiprocessing pattern
import multiprocessing
class Consumer(multiprocessing.Process):
"""Consumer processes. Subclassed from Process in multiprocessing."""
def __init__(self, task_queue, result_queue):
multiprocessing.Process.__init__(self)
self.task_queue = task_queue
self.result_queue = result_queue