Package mvpa :: Package misc :: Module support

[hide private]
[frames] | no frames]

# Module support

source code

Support function -- little helpers in everyday life

Classes | [hide private]

| SmartVersion A bit evolved comparison of versions
| MapOverlap Compute some overlap stats from a sequence of binary maps.
| Event Simple class to define properties of an event.
| HarvesterCall
| Harvester World domination helper: do whatever it is asked and accumulate results

Functions | [hide private]

reuseAbsolutePath(file1, file2, force=False) Use path to file1 as the path to file2 is no absolute path is given for file2 | source code

array (len(startpoints) x data.shape[1:])

transformWithBoxcar(data, startpoints, boxlength, offset=0, fx=N.mean) This function extracts boxcar windows from an array. Such a boxcar is defined by a starting point and the size of the window along the first axis of the array (`boxlength`). Afterwards a customizable function is applied to each boxcar individually (Default: averaging). | source code

_getUniqueLengthNCombinations_lt3(data, n) Generates a list of lists containing all combinations of elements of data of length 'n' without repetitions. | source code

xuniqueCombinations(L, n) Generator of unique combinations form a list L of objects in groups of size n. | source code

_getUniqueLengthNCombinations_binary(L, n=None, sort=True) Find all subsets of data | source code

getUniqueLengthNCombinations(L, n=None, sort=True) Find all subsets of data | source code

indentDoc(v) Given a `value` returns a string where each line is indented | source code

idhash(val) Craft unique id+hash for an object | source code

isSorted(items) Check if listed items are in sorted order. | source code

isInVolume(coord, shape) For given coord check if it is within a specified volume size. | source code

version_to_tuple(v) Convert literal string into a tuple, if possible of ints | source code

getBreakPoints(items, contiguous=True) Return a list of break points. | source code

RFEHistory2maps(history) Convert history generated by RFE into the array of binary maps | source code

Imports: N, re, os, Version, StringType, TupleType, ListType, warning, copy, deepcopy, isSequenceType, debug

Function Details | [hide private]

### reuseAbsolutePath(file1, file2, force=False)

source code

Use path to file1 as the path to file2 is no absolute path is given for file2

Parameters:
  - `force` (bool) - if True, force it even if the file2 starts with /

### transformWithBoxcar(data, startpoints, boxlength, offset=0, fx=N.mean)

source code

This function extracts boxcar windows from an array. Such a boxcar is defined by a starting point and the size of the window along the first axis of the array (`boxlength`). Afterwards a customizable function is applied to each boxcar individually (Default: averaging).

Parameters:
  - `data` (array) - An array with an arbitrary number of dimensions.
  - `startpoints` (sequence) - Boxcar startpoints as index along the first array axis
  - `boxlength` (int) - Length of the boxcar window in #array elements
  - `offset` (int) - Optional offset between the configured starting point and the actual begining of the boxcar window.
Returns: array (len(startpoints) x data.shape[1:])

### _getUniqueLengthNCombinations_lt3(data, n)

source code

Generates a list of lists containing all combinations of elements of data of length 'n' without repetitions.

> data: list n: integer

This function is adapted from a Java version posted in some forum on the web as an answer to the question 'How can I generate all possible combinations of length n?'. Unfortunately I cannot remember which forum it was.

NOTE: implementation is broken for n>2

### xuniqueCombinations(L, n)

source code

Generator of unique combinations form a list L of objects in groups of size n.

# XXX EO: I guess they are already sorted. # XXX EO: It seems to work well for n>20 :)

Adopted from Li Daobing http://code.activestate.com/recipes/190465/ (MIT license, according to activestate.com's policy)

Parameters:
  - `L` (list) - list of unique ids
  - `n` (int) - grouping size

### _getUniqueLengthNCombinations_binary(L, n=None, sort=True)

source code

Find all subsets of data

Adopted from Alex Martelli: http://mail.python.org/pipermail/python-list/2001-January/067815.html

Parameters:
  - `L` (list) - list of unique ids
  - `n` (None or int) - If None, all possible subsets are returned. If n is specified (int), then only the ones of the length n are returned
  - `sort` (bool) - Either to sort the resultant sequence

### getUniqueLengthNCombinations(L, n=None, sort=True)

source code

Find all subsets of data

TODO: work out single stable implementation -- probably just by fixing _getUniqueLengthNCombinations_lt3

Parameters:
  - `L` (list) - list of unique ids
  - `n` (None or int) - If None, all possible subsets are returned. If n is specified (int), then only the ones of the length n are returned

### indentDoc(v)

source code

Given a `value` returns a string where each line is indented

Needed for a cleaner __repr__ output `v` - arbitrary

### isSorted(items)

source code

Check if listed items are in sorted order.

Returns:
  `True` if were sorted. Otherwise `False` + Warning

Parameters: `items`: iterable container

### isInVolume(coord, shape)

source code

For given coord check if it is within a specified volume size.

Returns True/False. Assumes that volume coordinates start at 0. No more generalization (arbitrary minimal coord) is done to save on performance

### version_to_tuple(v)

source code

Convert literal string into a tuple, if possible of ints

Tuple of integers constructed by splitting at '.' or interleaves of numerics and alpha numbers

### getBreakPoints(items, contiguous=True)

source code

Return a list of break points.

Parameters:
  - `items` (iterable) - list of items, such as chunks
  - `contiguous` (bool) - if `True` (default) then raise Value Error if items are not contiguous, i.e. a label occur in multiple contiguous sets
Returns:
  list of indexes for every new set of items

### RFEHistory2maps(history)

source code

Convert history generated by RFE into the array of binary maps

Example:
  history2maps(N.array( [ 3,2,1,0 ] ))
results in
  array([[ 1., 1., 1., 1.],
    [ 1., 1., 1., 0.], [ 1., 1., 0., 0.], [ 1., 0., 0., 0.]])