This file contains hidden or 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
| class Rx: | |
| "has the nums of a treatment, its name and rank" | |
| def __init__(i,lst): | |
| i.rx, i.lst = lst[0], lst[1:] | |
| i.mean = sum(i.lst)/len(i.lst) | |
| i.rank = 0 | |
| def __repr__(i): | |
| return 'rank #%s %s at %s'%(i.rank,i.rx,i.mean) | |
| def a12s(lst,rev=True,enough=0.66): |
This file contains hidden or 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
| """ | |
| --- | |
| title: chunk.py | |
| author: Tim Menzies, [email protected] | |
| --- | |
| (Can be view as | |
| [html](http://menzies.us/cs472/?niching) or [raw | |
| Python](http://unbox.org/open/trunk/472/14/spring/src/where.py).) |
This file contains hidden or 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
| from __future__ import division | |
| def cliffsDelta(lst1,lst2, | |
| dull = [0.147, # small | |
| 0.33, # medium | |
| 0.474 # large | |
| ][0] ): | |
| "Returns true if there are more than 'dull' differences" | |
| m, n = len(lst1), len(lst2) | |
| lst2 = sorted(lst2) |
This file contains hidden or 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
| page 1 | |
| page 2 | |
| page 3 | |
| page 4 | |
| page 5 | |
| page 6 | |
| page 7 | |
| page 8 | |
| page 9 | |
| page 10 |
This file contains hidden or 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
| """ | |
| ok : a simple python unit test engine | |
| Copyright (c) Tim Menzies, 2015, WTFPL http://www.wtfpl.net/ | |
| Inspired by Kent Beck's video | |
| https://www.youtube.com/watch?v=nIonZ6-4nuU. | |
| For example usage, see the _ok function (at end). | |
| For help, see [email protected]. | |
| """ |
This file contains hidden or 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
| #!/bin/bash | |
| uniques() { | |
| gawk --source 'BEGIN { RS="" | |
| split("",seen,"") } | |
| { copy = tolower($0) | |
| gsub(/(--|::).*\n/,"",copy) | |
| gsub(/[^a-z0-9]/,"",copy) | |
| if ( ! (copy in seen) ) | |
| print("\n" $0) |
This file contains hidden or 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
| mock () | |
| { | |
| root=$(git rev-parse --show-toplevel); | |
| if [ -d "$root" ]; then | |
| ( cd $root; | |
| make $* ); | |
| else | |
| echo "mock: nothing to do"; | |
| fi | |
| } |
This file contains hidden or 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
| class Abcd: | |
| def __init__(i,db="all",rx="all"): | |
| i.db = db; i.rx=rx; | |
| i.yes = i.no = 0 | |
| i.known = {}; i.a= {}; i.b= {}; i.c= {}; i.d= {} | |
| def __call__(i,actual=None,predicted=None): | |
| return i.keep(actual,predicted) | |
| def tell(i,actual,predict): |
This file contains hidden or 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
| """ | |
| #<< | |
| ################################################### | |
| CHUNK: near-linear time recursive clustering. | |
| Copyright (c) 2014, Tim Menzies, [email protected] | |
| All rights reserved. | |
| For details on this code, see chapter 12 of |
This file contains hidden or 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/python | |
| # Knights tour with Warnsdorf's rule | |
| # copyright (c) 2016 Tim Menzies [email protected], MIT (2 clause) | |
| # usage python knightstour.py [BOARDSIZE] [seed] [x0] [y0] | |
| # suggested usage: | |
| # for((i=1;i<30;i++)); do python knightstour.py 30 $RANDOM; done | |
| # On failure, it retries up to 20 times, picking new x0,y0 each tie. | |
| # Usually gets it right first time, very rarely needs than 5 retries. | |
| # Works fine up to boards of size 50. Starts to crawl a bit at size 100 |