Package PyML :: Package utils :: Module misc
[hide private]
[frames] | no frames]

Module misc

source code

Classes [hide private]
  Container
  Null
Null objects always and reliably, do nothing.
  MyList
  DecisionFuncResults
Functions [hide private]
 
my_import(name) source code
 
subseteq(A, B) source code
 
setminus(A, B) source code
 
unique(A)
return the unique elements of a list
source code
 
consecutiveUnique(A, B=None) source code
 
listEqual(A, B)
Determine if the lists A and B contain exactly the same elements...
source code
 
setEqual(A, B) source code
 
intersect(A, B) source code
 
intersectDicts(A, B) source code
 
intersectIndices(A, B) source code
 
intersectSorted(A, B) source code
 
union(A, B) source code
 
mergeSorted(A, B) source code
 
invertDict(A) source code
 
invert(A) source code
 
majority(A) source code
 
idSubList(A, ids, idlist, *options)
Take a sublist of a list where each member has an id...
source code
 
subList(A, I, J=None)
return a sublist of a list...
source code
 
list2dict(A, val=None)
convert a list to a dictionary...
source code
 
dictCount(A) source code
 
emptyLOL(n) source code
 
matrix(shape, value=None) source code
 
LOD(n) source code
 
inverseCumulative(x, v) source code
 
translate(id, idList) source code
 
count(A)
count the number of occurrences of each element in a list
source code
 
extractAttribute(l, attribute) source code
 
split(s, delim) source code
 
flat(A) source code
 
transpose(A) source code
 
dictProjection(A, B) source code
 
randsubset(length, subsetLength)
returns a random subset of range(length) of size subsetLength
source code
 
sortDict(dict)
sort the values and keys of a dictionary...
source code
 
dict2array(dict) source code
 
argmax(A)
returns the indices of the maximum element of a two dimensional matrix
source code
 
splitFileName(fileName) source code
 
unravel(l) source code
 
findDelim(handleOrName) source code
 
getDelim(handleOrName) source code
 
adjacencyMatrix(fileName) source code
 
getArch() source code
 
mysetattr(obj, attribute, value) source code
 
isString(var)
determine whether a variable is a string
source code
 
set_attributes(x, values, defaults=None) source code
 
update(x, **entries)
Update a dict or an object with according to entries.
source code
 
timer(fn, *args)
Time the application of fn to args.
source code
 
get_defaults(defaults, args, varNames) source code
Function Details [hide private]

listEqual(A, B)

source code 
Determine if the lists A and B contain exactly the same elements
(the lists are treated as multisets)

idSubList(A, ids, idlist, *options)

source code 
Take a sublist of a list where each member has an id
the sublist is taken according to the given sublist of ids
these indicate either ids to take or ids to remove (default
behavior is to take the ids in idlist, use the option "remove"
for the other behavior)

subList(A, I, J=None)

source code 
return a sublist of a list
INPUT
A - list, list of lists, or a list of strings
I - subset of "rows" (first index) to take
J - subset of "columns" (second index) to take (optional)
returns A[i] for i in I
or A[i][j] for i in I and j in J if J is given

list2dict(A, val=None)

source code 
convert a list to a dictionary
If a value list is not given, then the value 1 is associated with
each element in the dictionary
to assign each element its position in the list use:
list2dict(A, range(len(A)))

sortDict(dict)

source code 
sort the values and keys of a dictionary
assumes values are numeric

update(x, **entries)

source code 
Update a dict or an object with according to entries.
>>> update({'a': 1}, a=10, b=20)
{'a': 10, 'b': 20}
>>> update(Struct(a=1), a=10, b=20)
Struct(a=10, b=20)

timer(fn, *args)

source code 
Time the application of fn to args. Return (result, seconds).