Skip to content

Instantly share code, notes, and snippets.

Values are as per listings on http://www.thewhiskyexchange.com/ where possible or as priced by a source linked with the entry as I don't have records of the purchase of all of these. ABVs are as on the bottle.

  • Babicka wormwood vodka: 40% ABV, 700ml, £28.05
  • Green Chartreuse: 55% ABV, 700ml, £35.45
  • Adnams Longshore Vodka, 48% ABV, 700ml, £29.95
  • Glenrothes Select Reserve: 43% ABV, 700ml, £34.95
  • Nolet's silver dry gin: 47.6% ABV, 750ml, List price is $52.99 according to http://www.drinkupny.com/Nolets_Silver_Dry_Gin_p/s0669.htm which is £31.83 at current exchange rate
  • Tanqueray No. 10: 47.3% ABV, 700ml, £29.85
  • No. 3 Gin: 46% ABV, 700ml, £32.45
  • Bols Corenwyn Genever: 40% ABV, 1000ml, £38.85
execute pathogen#infect()
set tabstop=2
set shiftwidth=2
set expandtab
set mouse=
:map <ScrollWheelUp> <nop>
:map <S-ScrollWheelUp> <nop>
:map <ScrollWheelDown> <nop>
:map <S-ScrollWheelDown> <nop>
"""
Bayesian Data Analysis 3rd Edition, Exercise 10.3
Just doing the hierarchical model because I CBA with the rest.
Here's some example output:
Machine 6 mean
Mean: 87.63
Standard deviation: 6.02

An election with a lot of different outcomes depending on which voting system you use. Votes are full ranks from most preferred to least preferred. A vote followed by [n] is repeated n times.

Where multiple winners are listed, this is interpreted as a tie between those candidates.

Votes

1, 4, 3, 2 [2]
2, 1, 4, 3 [2]
2, 4, 1, 3

3, 2, 1, 4

{-# LANGUAGE ExistentialQuantification, RankNTypes #-}
{-
Monadic generation and simplification of examples
It's easy to generate data monadically (that's just a Random monad) but it's
less obvious how to proceed in a way that allows you to simplify the generated
data. It's not even obvious how to do it functorially.
from contextlib import contextmanager
@contextmanager
def foo():
yield
class Hello():
# Hey look we're defining a method in a context manager
ThaiLangModel = (
0,1,3,3,3,3,0,0,3,3,0,3,3,0,3,3,3,3,3,3,3,3,0,0,3,3,3,0,3,3,3,3,
0,3,3,0,0,0,1,3,0,3,3,2,3,3,0,1,2,3,3,3,3,0,2,0,2,0,0,3,2,1,2,2,
3,0,3,3,2,3,0,0,3,3,0,3,3,0,3,3,3,3,3,3,3,3,3,0,3,2,3,0,2,2,2,3,
0,2,3,0,0,0,0,1,0,1,2,3,1,1,3,2,2,0,1,1,0,0,1,0,0,0,0,0,0,0,1,1,
3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,3,3,2,3,2,3,3,2,2,2,
3,1,2,3,0,3,3,2,2,1,2,3,3,1,2,0,1,3,0,1,0,0,1,0,0,0,0,0,0,0,1,1,
3,3,2,2,3,3,3,3,1,2,3,3,3,3,3,2,2,2,2,3,3,2,2,3,3,2,2,3,2,3,2,2,
3,3,1,2,3,1,2,2,3,3,1,0,2,1,0,0,3,1,2,1,0,0,1,0,0,0,0,0,0,1,0,1,
3,3,3,3,3,3,2,2,3,3,3,3,2,3,2,2,3,3,2,2,3,2,2,2,2,1,1,3,1,2,1,1,
"""
This file demonstrates an interesting quirk of cpython behaviour with
weak references which go through sufficiently long reference chains.
Above a certain depth of reference a GC fails to clear weakrefs. This happens
even if you run it multiple times. However allocating an object that is
immediately freed appears to be enough to do it.
"""
import weakref

You start with a code base, a test suite, and an empty directory that will be where you're going to put the "core" test suite.

You run the following in a loop:

  1. Mutate the code. See if the original test suite now fails and the current core test suite passes.
  2. Minimize a version of the original test suite subject to the constraints that it passes on the unmutated code and fails on the mutated code, using something like http://www.drmaciver.com/2015/03/27-bugs-in-24-hours/
  3. Once you have a minimal example, add it to the core.

Continue this loop until you stop finding examples.

david@volcano-base ~/projects/hypothesis $ PYTHONPATH=src python -m cosmic_ray.app hypothesis tests/test_descriptortests.py 
Traceback (most recent call last):
  File "/home/david/.pyenv/versions/3.4.3/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/david/.pyenv/versions/3.4.3/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/david/.pyenv/versions/3.4.3/lib/python3.4/site-packages/cosmic_ray-0.0.0-py3.4.egg/cosmic_ray/app.py", line 114, in <module>
    main()
  File "/home/david/.pyenv/versions/3.4.3/lib/python3.4/site-packages/cosmic_ray-0.0.0-py3.4.egg/cosmic_ray/app.py", line 95, in main