summon.util
index
/home/raz/projects/summon/lib/summon/util.py

Common Utilities
 
file: util.py 
authors: Matt Rasmussen
date: 11/30/05
 
Provides basic functional programming functions for manipulating lists and 
dicts.  Also provides common utilities (timers, plotting, histograms)

 
Modules
       
copy
getopt
math
os
re
shlex
rasmus.svg
sys
tempfile
time
traceback

 
Classes
       
__builtin__.dict(__builtin__.object)
Bundle
Dict
__builtin__.float(__builtin__.object)
Percent
__builtin__.object
PushIter
DelimReader
IndentStream
SafeReadIter

 
class Bundle(__builtin__.dict)
    A small class for creating a closure of variables
handy for nested functions that need to assign to variables in an 
outer scope
 
Example:
 
def func1():
    this = Bundle(var1 = 0, var2 = "hello")
    def func2():
        this.var1 += 1
    func2()
    print this.var1   
func1()
 
will produce:
1
 
 
Method resolution order:
Bundle
__builtin__.dict
__builtin__.object

Methods defined here:
__init__(self, **variables)
__setitem__(self, key, val)

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Bundle' objects>
list of weak references to the object (if defined)

Methods inherited from __builtin__.dict:
__cmp__(...)
x.__cmp__(y) <==> cmp(x,y)
__contains__(...)
D.__contains__(k) -> True if D has a key k, else False
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
clear(...)
D.clear() -> None.  Remove all items from D.
copy(...)
D.copy() -> a shallow copy of D
get(...)
D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.
has_key(...)
D.has_key(k) -> True if D has a key k, else False
items(...)
D.items() -> list of D's (key, value) pairs, as 2-tuples
iteritems(...)
D.iteritems() -> an iterator over the (key, value) items of D
iterkeys(...)
D.iterkeys() -> an iterator over the keys of D
itervalues(...)
D.itervalues() -> an iterator over the values of D
keys(...)
D.keys() -> list of D's keys
pop(...)
D.pop(k[,d]) -> v, remove specified key and return the corresponding value
If key is not found, d is returned if given, otherwise KeyError is raised
popitem(...)
D.popitem() -> (k, v), remove and return some (key, value) pair as a
2-tuple; but raise KeyError if D is empty
setdefault(...)
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
update(...)
D.update(E, **F) -> None.  Update D from E and F: for k in E: D[k] = E[k]
(if E has keys else: for (k, v) in E: D[k] = v) then: for k in F: D[k] = F[k]
values(...)
D.values() -> list of D's values

Data and other attributes inherited from __builtin__.dict:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T
fromkeys = <built-in method fromkeys of type object>
dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.
v defaults to None.

 
class DelimReader
    Reads delimited files
 
  Methods defined here:
__init__(self, filename, delim=None)
Constructor for DelimReader
 
arguments:
filename  - filename or stream to read from
delim     - delimiting character
__iter__(self)
next(self)
split(self, line)

 
class Dict(__builtin__.dict)
    My personal nested Dictionary (with default values)
 
 
Method resolution order:
Dict
__builtin__.dict
__builtin__.object

Methods defined here:
__getitem__(self, i)
__init__(self, items=None, dim=1, default=None, insert=True)
items   -- items to initialize Dict (can be dict, list, iter)
dim     -- number of dimensions of the dictionary
default -- default value of a dictionary item
has_keys(self, *keys)
write(self, out=<open file '<stdout>', mode 'w'>)

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Dict' objects>
list of weak references to the object (if defined)

Methods inherited from __builtin__.dict:
__cmp__(...)
x.__cmp__(y) <==> cmp(x,y)
__contains__(...)
D.__contains__(k) -> True if D has a key k, else False
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
clear(...)
D.clear() -> None.  Remove all items from D.
copy(...)
D.copy() -> a shallow copy of D
get(...)
D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.
has_key(...)
D.has_key(k) -> True if D has a key k, else False
items(...)
D.items() -> list of D's (key, value) pairs, as 2-tuples
iteritems(...)
D.iteritems() -> an iterator over the (key, value) items of D
iterkeys(...)
D.iterkeys() -> an iterator over the keys of D
itervalues(...)
D.itervalues() -> an iterator over the values of D
keys(...)
D.keys() -> list of D's keys
pop(...)
D.pop(k[,d]) -> v, remove specified key and return the corresponding value
If key is not found, d is returned if given, otherwise KeyError is raised
popitem(...)
D.popitem() -> (k, v), remove and return some (key, value) pair as a
2-tuple; but raise KeyError if D is empty
setdefault(...)
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
update(...)
D.update(E, **F) -> None.  Update D from E and F: for k in E: D[k] = E[k]
(if E has keys else: for (k, v) in E: D[k] = v) then: for k in F: D[k] = F[k]
values(...)
D.values() -> list of D's values

Data and other attributes inherited from __builtin__.dict:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T
fromkeys = <built-in method fromkeys of type object>
dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.
v defaults to None.

 
class IndentStream
    Makes any stream into an indent stream.
 
Indent stream auto indents every line written to it
 
  Methods defined here:
__init__(self, stream)
dedent(self, num=2)
indent(self, num=2)
write(self, text)

 
class Percent(__builtin__.float)
    
Method resolution order:
Percent
__builtin__.float
__builtin__.object

Methods defined here:
__repr__(self)
__str__(self)

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Percent' objects>
list of weak references to the object (if defined)
digits = 1

Methods inherited from __builtin__.float:
__abs__(...)
x.__abs__() <==> abs(x)
__add__(...)
x.__add__(y) <==> x+y
__coerce__(...)
x.__coerce__(y) <==> coerce(x, y)
__div__(...)
x.__div__(y) <==> x/y
__divmod__(...)
x.__divmod__(y) <==> divmod(x, y)
__eq__(...)
x.__eq__(y) <==> x==y
__float__(...)
x.__float__() <==> float(x)
__floordiv__(...)
x.__floordiv__(y) <==> x//y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getnewargs__(...)
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__int__(...)
x.__int__() <==> int(x)
__le__(...)
x.__le__(y) <==> x<=y
__long__(...)
x.__long__() <==> long(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mod__(...)
x.__mod__(y) <==> x%y
__mul__(...)
x.__mul__(y) <==> x*y
__ne__(...)
x.__ne__(y) <==> x!=y
__neg__(...)
x.__neg__() <==> -x
__nonzero__(...)
x.__nonzero__() <==> x != 0
__pos__(...)
x.__pos__() <==> +x
__pow__(...)
x.__pow__(y[, z]) <==> pow(x, y[, z])
__radd__(...)
x.__radd__(y) <==> y+x
__rdiv__(...)
x.__rdiv__(y) <==> y/x
__rdivmod__(...)
x.__rdivmod__(y) <==> divmod(y, x)
__rfloordiv__(...)
x.__rfloordiv__(y) <==> y//x
__rmod__(...)
x.__rmod__(y) <==> y%x
__rmul__(...)
x.__rmul__(y) <==> y*x
__rpow__(...)
y.__rpow__(x[, z]) <==> pow(x, y[, z])
__rsub__(...)
x.__rsub__(y) <==> y-x
__rtruediv__(...)
x.__rtruediv__(y) <==> y/x
__sub__(...)
x.__sub__(y) <==> x-y
__truediv__(...)
x.__truediv__(y) <==> x/y

Data and other attributes inherited from __builtin__.float:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
class PushIter(__builtin__.object)
    Wrap an iterator in another iterator that allows one to push new
items onto the front of the iteration stream
 
  Methods defined here:
__init__(self, it)
__iter__(self)
next(self)
peek(self, default=None)
push(self, item)
Push a new item onto the front of the iteration stream

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'PushIter' objects>
list of weak references to the object (if defined)

 
class SafeReadIter
     Methods defined here:
__init__(self, infile)
__iter__(self)
next(self)

 
Functions
       
add(a, b)
argmax(lst, key=<function <lambda>>)
Find the index 'i' in 'lst' with maximum lst[i]
 
lst -- list to search
key -- function to apply to each lst[i].
       argmax(lst, key=func) --> argmax(map(key, lst))
argmin(lst, key=<function <lambda>>)
Find the index 'i' in 'lst' with minimum lst[i]
 
lst -- list to search
key -- function to apply to each lst[i].
       argmin(lst, key=func) --> argmin(map(key, lst))
bucket(array, ndivs=None, low=None, width=None, key=<function <lambda>>)
Group elements of 'array' into 'ndivs' lists
bucketBin(item, ndivs, low, width)
Return the bin for an item
bucketSize(array, ndivs=None, low=None, width=None)
Determine the bucket size needed to divide the values in array into 
'ndivs' evenly sized buckets
cget(mat, *i)
Returns the column(s) '*i' of a 2D list 'mat'
 
mat -- matrix or 2D list 
*i  -- columns to extract from matrix
 
notes:
If one column is given, the column is returned as a list.
If multiple columns are given, a list of columns (also lists) is returned
clamp(x, low, high)
Clamps a value 'x' between the values 'low' and 'high'
If low == None, then there is no lower bound
If high == None, then there is no upper bound
clampfunc(low, high)
compose(*funcs)
Composes two or more functions into one function
 
example:
compose(f,g,h,i)(x) <==> f(g(h(i(x))))
compose2(f, g)
Compose two functions into one
 
compose2(f, g)(x) <==> f(g(x))
concat(*lists)
Concatenates several lists into one
count(func, lst)
Counts the number of times func(x) is True for x in list 'lst'
   
See also:
    counteq(a, lst)   count items equal to a
    countneq(a, lst)  count items not equal to a
    countle(a, lst)   count items less than or equal to a
    countlt(a, lst)   count items less than a
    countge(a, lst)   count items greater than or equal to a
    countgt(a, lst)   count items greater than a
counteq(a, lst)
countge(a, lst)
countgt(a, lst)
countle(a, lst)
countlt(a, lst)
countneq(a, lst)
cumsum(vals)
Returns a cumalative sum of vals (as a list)
defaultFormat = default_format(val)
defaultJustify = default_justify(val)
default_format(val)
default_justify(val)
deldir(path)
Recursively remove a directory
distrib(array, ndivs=None, low=None, width=None)
Find the distribution of 'array' using 'ndivs' buckets
div(a, b)
eqfunc(a)
equal(*vals)
Returns True if all arguments are equal
evalstr(text)
Replace expressions in a string (aka string interpolation)
 
ex:
>>> name = 'Matt'
>>> evalstr("My name is ${name} and my age is ${12+12}")
'My name is Matt and my age is 24'
 
"${!expr}" expands to "${expr}"
exceptDefault(func, val, exc=<class exceptions.Exception>)
Specify a default value for when an exception occurs
find(func, *lsts)
Returns the indices 'i' of 'lst' where func(lst[i]) == True
 
if N lists are passed, N arguments are passed to 'func' at a time.
Thus, find(func, list1, list2) returns the list of indices 'i' where 
func(list1[i], list2[i]) == True
 
See also:
    findeq(a, lst)   find items equal to a
    findneq(a, lst)  find items not equal to a
    findle(a, lst)   find items less than or equal to a
    findlt(a, lst)   find items less than a
    findge(a, lst)   find items greater than or equal to a
    findgt(a, lst)   find items greater than a
findeq(a, lst)
findge(a, lst)
findgt(a, lst)
findle(a, lst)
findlt(a, lst)
findneq(a, lst)
flatten(lst, depth=inf)
Flattens nested lists/tuples into one list
 
depth -- specifies how deep flattening should occur
frange(start, end, step)
Generates a range of floats 
 
start -- begining of range
end   -- end of range
step  -- step size
gefunc(a)
groupby(func, lst, multi=False)
Places i and j of 'lst' into the same group if func(i) == func(j).
 
func -- is a function of one argument that maps items to group objects
lst  -- is a list of items
multi -- if True, func must return a list of keys (key1, ..., keyn) for
         item a.  groupby will retrun a nested dict 'dct' such that
         dct[key1]...[keyn] == a
 
returns:
a dictionary such that the keys are groups and values are items found in
that group
gtfunc(a)
hist(array, ndivs=None, low=None, width=None)
Create a histogram of 'array' with 'ndivs' buckets
hist2(array1, array2, ndivs1=None, ndivs2=None, low1=None, low2=None, width1=None, width2=None)
Perform a 2D histogram
histDict = hist_dict(array)
Returns a histogram of any items as a dict.
 
The keys of the returned dict are elements of 'array' and the values
are the counts of each element in 'array'.
histInt = hist_int(array)
Returns a histogram of integers as a list of counts
hist_dict(array)
Returns a histogram of any items as a dict.
 
The keys of the returned dict are elements of 'array' and the values
are the counts of each element in 'array'.
hist_int(array)
Returns a histogram of integers as a list of counts
histbins(bins)
Adjust the bins from starts to centers, this will allow GNUPLOT to plot
histograms correctly
icumsum(vals)
Returns a cumalative sum of vals (as an iterator)
idiv(a, b)
int2pretty(num)
Returns a pretty-printed version of an int
invPerm = invperm(perm)
Returns the inverse of a permutation 'perm'
invcmp(a, b)
invperm(perm)
Returns the inverse of a permutation 'perm'
islands(lst)
Takes a iterable and returns islands of equal consequtive items 
 
Return value is a dict with the following format
 
counts = {elm1: [(start,end), (start,end), ...],
          elm2: [(start,end), (start,end), ...]
          ...}
 
where for each (start,end) in counts[elm1] we have lst[start:end] only 
containing elm1
lefunc(a)
lg(num)
Retruns the log_2 of a number
list2lookup(lst)
Creates a dict where each key is lst[i] and value is i
list2matrix(lst, nrows=None, ncols=None, bycols=True)
Turn a list into a matrix by wrapping its entries
listFiles = list_files(path, ext='')
Returns a list of files in 'path' ending with 'ext'
list_files(path, ext='')
Returns a list of files in 'path' ending with 'ext'
ltfunc(a)
makeMatrix = make_matrix(nrows, ncols, val=0)
make_matrix(nrows, ncols, val=0)
map2(func, *matrix)
Maps a function onto the elements of a matrix
 
Also accepts multiple matrices.  Thus matrix addition is
 
map2(add, matrix1, matrix2)
mapapply(funcs, lst)
apply each function in 'funcs' to one element in 'lst'
mapdict(dic, key=<function <lambda>>, val=<function <lambda>>, keyfunc=None, valfunc=None)
Creates a new dict where keys and values are mapped
 
keyfunc and valfunc are DEPRECATED
mapwindow(func, size, lst)
Apply a function 'func' to a sliding window of size 'size' within
a list 'lst'
match(pattern, text)
A quick way to do pattern matching.
 
remember: to name tokens use (?P<name>pattern)
max2(matrix)
Finds the maximum of a 2D list or matrix
maxfunc(func, lst)
Find the element 'e' in 'lst' with maximum func(e)
mget(lst, ind)
Returns a list 'lst2' such that lst2[i] = lst[ind[i]]
 
Or in otherwords, get the subsequence 'lst'
min2(matrix)
Finds the minimum of a 2D list or matrix
minfunc(func, lst)
Find the element 'e' in 'lst' with minimum func(e)
mul(a, b)
neqfunc(a)
oneNorm(vals)
Normalize values so that they sum to 1
openStream = open_stream(filename, mode='r')
Returns a file stream depending on the type of 'filename' and 'mode'
 
The following types for 'filename' are handled:
 
stream         - returns 'filename' unchanged
iterator       - returns 'filename' unchanged
URL string     - opens http pipe
'-'            - opens stdin or stdout, depending on 'mode'
other string   - opens file with name 'filename'
 
mode is standard mode for file(): r,w,a,b
open_stream(filename, mode='r')
Returns a file stream depending on the type of 'filename' and 'mode'
 
The following types for 'filename' are handled:
 
stream         - returns 'filename' unchanged
iterator       - returns 'filename' unchanged
URL string     - opens http pipe
'-'            - opens stdin or stdout, depending on 'mode'
other string   - opens file with name 'filename'
 
mode is standard mode for file(): r,w,a,b
overlap(a, b, x, y, inc=True)
Returns True if range [a,b] overlaps [x,y]
 
inc -- if True, treat [a,b] and [x,y] as inclusive
pretty2int(string)
Parses a pretty-printed version of an int into an int
printDict = print_dict(dic, key=<function <lambda>>, val=<function <lambda>>, num=None, cmp=<built-in function cmp>, order=None, reverse=False, spacing=4, out=<open file '<stdout>', mode 'w'>, format=<function default_format>, justify=<function default_justify>)
Print s a dictionary in two columns
printHist = print_hist(array, ndivs=20, low=None, width=None, cols=75, spacing=2, out=<open file '<stdout>', mode 'w'>)
print_dict(dic, key=<function <lambda>>, val=<function <lambda>>, num=None, cmp=<built-in function cmp>, order=None, reverse=False, spacing=4, out=<open file '<stdout>', mode 'w'>, format=<function default_format>, justify=<function default_justify>)
Print s a dictionary in two columns
print_hist(array, ndivs=20, low=None, width=None, cols=75, spacing=2, out=<open file '<stdout>', mode 'w'>)
printcols(data, width=None, spacing=1, format=<function default_format>, justify=<function default_justify>, out=<open file '<stdout>', mode 'w'>, colwidth=inf, overflow='!')
Prints a list or matrix in aligned columns
 
data    - a list or matrix
width   - maxium number of characters per line (default: 75 for lists)
spacing - number of spaces between columns (default: 1)
out     - stream to print to (default: sys.stdout)
printwrap(text, width=80, prefix='', out=<open file '<stdout>', mode 'w'>)
Prints text with wrapping
range2(width, height)
Iterates over the indices of a matrix
 
Thus list(range2(3, 2)) returns
 [(0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1)]
readDelim = read_delim(filename, delim=None)
Read an entire delimited file into memory as a 2D list
readDict = read_dict(filename, delim='\t', keytype=<type 'str'>, valtype=<type 'str'>)
Read a dict from a file
 
filename may also be a stream
readFloats = read_floats(filename)
Read a list of floats from a file (one float per line)
 
filename may also be a stream
readInts = read_ints(filename)
Read a list of integers from a file (one int per line)
 
filename may also be a stream
readStrings = read_strings(filename)
Read a list of strings from a file (one string per line)
 
filename may also be a stream
readUntil = read_until(stream, chars)
readWhile = read_while(stream, chars)
readWord = read_word(infile, delims=[' ', '\t', '\n'])
read_delim(filename, delim=None)
Read an entire delimited file into memory as a 2D list
read_dict(filename, delim='\t', keytype=<type 'str'>, valtype=<type 'str'>)
Read a dict from a file
 
filename may also be a stream
read_floats(filename)
Read a list of floats from a file (one float per line)
 
filename may also be a stream
read_ints(filename)
Read a list of integers from a file (one int per line)
 
filename may also be a stream
read_strings(filename)
Read a list of strings from a file (one string per line)
 
filename may also be a stream
read_until(stream, chars)
read_while(stream, chars)
read_word(infile, delims=[' ', '\t', '\n'])
remove(lst, *vals)
Returns a copy of list 'lst' with values 'vals' removed
replaceExt = replace_ext(filename, oldext, newext)
Safely replaces a file extension new a new one
replace_ext(filename, oldext, newext)
Safely replaces a file extension new a new one
revdict(dic, allowdups=False)
Reverses a dict 'dic' such that the keys become values and the 
values become keys.
 
allowdups -- if True, one of several key-value pairs with the same value 
             will be arbitrarily choosen.  Otherwise an expection is raised
reverse(lst)
Returns a reversed copy of a list
safediv(a, b, default=inf)
safelog(x, base=2.7182818284590451, default=-inf)
sign(num)
Returns the sign of a number
skipComments = skip_comments(infile)
skip_comments(infile)
sort(lst, compare=<built-in function cmp>, key=None, reverse=False)
Returns a sorted copy of a list
 
python2.4 now has sorted() which fulfills the same purpose
 
lst     -- a list to sort
compare -- a function for comparing items (default: cmp)
key     -- function of one arg to map items
reverse -- when True reverse sorting
sortInd = sortrank(lst, cmp=<built-in function cmp>, key=None, reverse=False)
Returns the ranks of items in lst
sortTogether = sort_together(compare, lst, *others)
Sort several lists based on the sorting of 'lst'
sort_many(lst, *others, **args)
Sort several lists based on the sorting of 'lst'
sort_together(compare, lst, *others)
Sort several lists based on the sorting of 'lst'
sortrank(lst, cmp=<built-in function cmp>, key=None, reverse=False)
Returns the ranks of items in lst
sqrt(...)
sqrt(x)
 
Return the square root of x.
str2bool(val)
Correctly converts the strings "True" and "False" to the 
booleans True and False
sub(a, b)
subdict(dic, keys)
Returns a new dictionary dic2 such that
dic2[i] = dic[i] for all i in keys
 
dic  -- a dictionary
keys -- a list of keys
submatrix(mat, rows=None, cols=None)
Returns a submatrix of 'mat' with only the rows and columns specified
 
Rows and columns will appear in the order as indicated in 'rows' and 'cols'
tempfile(path, prefix, ext)
Generates a a temp filename 'path/prefix_XXXXXX.ext'
 
DEPRECATED: use this instead
fd, filename = temporaryfile.mkstemp(ext, prefix)
os.close(fd)
transpose(mat)
Transpose a matrix
 
Works better than zip() in that rows are lists not tuples
unique(lst)
Returns a copy of 'lst' with only unique entries.
The list is stable (the first occurance is kept).
withinfunc(a, b, ainc=True, binc=True)
writeDelim = write_delim(filename, data, delim='\t')
Write a 2D list into a file using a delimiter
writeDict = write_dict(filename, dct, delim='\t')
Write a dictionary to a file
writeList = write_list(filename, lst)
Write a list of anything (ints, floats, strings, etc) to a file.
 
filename may also be a stream
writeVector = write_list(filename, lst)
Write a list of anything (ints, floats, strings, etc) to a file.
 
filename may also be a stream
write_delim(filename, data, delim='\t')
Write a 2D list into a file using a delimiter
write_dict(filename, dct, delim='\t')
Write a dictionary to a file
write_list(filename, lst)
Write a list of anything (ints, floats, strings, etc) to a file.
 
filename may also be a stream

 
Data
        INF = inf
black = (0, 0, 0, 1)
blue = (0, 0, 1, 1)
green = (0, 1, 0, 1)
grey = (0.5, 0.5, 0.5, 1)
orange = (1, 0.5, 0, 1)
purple = (1, 0, 1, 1)
red = (1, 0, 0, 1)
rp = <rasmus.plotting.LazyR object>
white = (1, 1, 1, 1)
yellow = (1, 1, 0, 1)