Skip to content

Instantly share code, notes, and snippets.

View sbrugman's full-sized avatar

Simon Brugman sbrugman

View GitHub Profile
@sbrugman
sbrugman / janyes_9_12.py
Created March 21, 2021 16:53
Probability Theory: The Logic of Science, chapter 9.12 example
import numpy as np
H1 = [0.499, 0.499, 0.002]
H2 = [0.3333333333, 0.3333333333, 0.3333333333]
obs = [14, 14, 1]
def psi(hypothesis, observed):
assert np.isclose(sum(hypothesis), 1)
@sbrugman
sbrugman / testable_tread.py
Last active September 7, 2021 08:44
Wrapper around Python's thread that propages exceptions (pytest).
import threading
class TestableThread(threading.Thread):
"""Wrapper around `threading.Thread` that propagates exceptions."""
def __init__(self, target, args):
super().__init__(self, target=target, args=args)
self.exc = None