END=" ; " END="\n" ORIGINAL = { "A": -100, "B": 500, "C": -300, "D": 400 } def test_series() : from geo import series t1 = [ 2, 5 ] t2 = [ 3, 4 ] tests = [ t1, t2 ] for test in tests : x, n = test g = series( x, n ) print( "series(", x, ",", n, "):", g, end=END ) def test_up() : from grow import up s1 = "abc" s2 = "woah!" tests = [ s1, s2 ] for s in tests : g = up( s ) print( "up(", s, "):", g, end=END ) def test_conv() : from stray import conv s1 = "apple" s2 = "banana" g1 = conv( s1 ) g2 = conv( s2 ) print( "conv(", s1, "):", g1, end=END ) print( "conv(", s2, "):", g2, end=END ) def test_swap() : from case import swap s1 = "ee cummings" s2 = "CS 1112" s3 = "aBcD" g1 = swap( s1 ) g2 = swap( s2 ) g3 = swap( s3 ) print( "swap(", s1, "):", g1, end=END ) print( "swap(", s2, "):", g2, end=END ) print( "swap(", s3, "):", g3, end=END ) def test_dare() : from truth import dare r = dare() print( "dare():", r, end=END ) def copy( d ) : cp = {} for k in d : cp[ k ] = d[ k ] return cp def canonical( d ) : keys = [] for k in d : keys.append( k ) keys.sort() form = "{ " n = len( keys ) for i in range( 0, n-1 ) : k = keys[ i ] v = d[ k ] form = form + str( k ) + ": " + str( v ) + ", " k = keys[ n-1 ] v = d[ k ] form = form + str( k ) + ": " + str( v ) + " }" return form def test_uniq() : from icto import uniq d = { "A": 1, "B": 2, "C": 2, "D": 4 } d1 = copy( d ) d2 = copy( d ) k1 = "A" k2 = "C" g1 = uniq( d1, k1 ) g2 = uniq( d2, k2 ) print( "uniq(", d, ",", k1, "):", g1, end=END ) print( "uniq(", d, ",", k2, "):", g2, end=END ) def test_square() : from tab import square d1 = [ [2] ] d2 = [ [2, 4, 6] ] d3 = [ [2], [ 4 ], [ 6 ] ] d4 = [ [2, 4, 6], [ 1, 3, 5 ], [ 7, 8, 9 ] ] tests = [ d1, d2, d3, d4 ] for d in tests : g = square( d ) print( "square(", d, "):", g, end=END ) def test_avg() : from date import avg d1 = [ [1, 2] ] d2 = [ [2, 4, 6], [ 8 ], [ 10, 12 ] ] g1 = avg( d1 ) g2 = avg( d2 ) print( "avg(", d1, "):", g1, end=END ) print( "avg(", d2, "):", g2, end=END ) def test_audit( ) : from accts import audit d = { "A": 1, "B": 0, "C": -3, "D": 4, "E": 0, "F": 0, "G": 1, "H": 5 } d1 = copy( d ) d2 = copy( d ) d3 = copy( d ) d4 = copy( d ) tests = [ [d1, "-"], [d2, "+"], [d3, "0"], [ d4, "*"] ] for test in tests : d, c = test g = audit( d, c ) if ( type( g ) == type( ["A", "B" ] ) ) : g.sort() print( "audit( d, " + c, "):", g, end=END ) def test_look( ) : from riches import look d = copy( ORIGINAL ) g = look( d ) print( "look(", ORIGINAL, "):", g, end=END ) odd = { "A": -100, "B": -1000, "C": -50, "D": -100000000 } d = copy( odd ) g = look( d ) print( "look(", odd, "):", g, end=END ) from PIL import Image def manip( original, f ) : w, h = original.size new_image = Image.new( 'RGB', ( w, h ) ) for x in range( 0, w ) : for y in range( 0, h ) : spot = ( x, y ) opixel = original.getpixel( spot ) npixel = f( opixel ) new_image.putpixel( spot, npixel ) return new_image def manip2( w, h, f ) : new_image = Image.new( 'RGB', ( w, h ) ) for x in range( 0, w ) : for y in range( 0, h ) : spot = ( x, y ) pixel = f( x, y ) new_image.putpixel( spot, pixel ) return new_image def test_rgb() : URL="http://www.cs.virginia.edu/~cs1112/images/mandrill.jpg" from picmax import rgb from url import get_image o = get_image( URL ) n = manip( o, rgb ) n.show() def test_rotate() : URL="http://www.cs.virginia.edu/~cs1112/images/mandrill.jpg" from picspin import rotate from url import get_image o = get_image( URL ) n = manip( o, rotate ) n.show() def test_gradient() : URL="http://www.cs.virginia.edu/~cs1112/images/mandrill.jpg" from picroll import gradient from url import get_image n = manip2( 450, 450, gradient ) n.show() def test_chomp(): from ring import chomp s3 = [ "ABCDEFGHIJ", 2, 6 ] tests = [ s3 ] for test in tests : s, a, b = test g = chomp( s, a, b ) print( "chomp(", s, ",", a, ",", b, "):", g, end=END )