diff --git a/scikits/learn/datasets/misc/__init__.py b/scikits/learn/datasets/misc/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..3457bb15a4dbe6b85b3e0e8fcb8e4ac29afe240f --- /dev/null +++ b/scikits/learn/datasets/misc/__init__.py @@ -0,0 +1 @@ +from tools import dumpvar diff --git a/scikits/learn/datasets/misc/tools.py b/scikits/learn/datasets/misc/tools.py new file mode 100644 index 0000000000000000000000000000000000000000..8d2c9c1846879a44996c418b5f7fbf4659d6ea44 --- /dev/null +++ b/scikits/learn/datasets/misc/tools.py @@ -0,0 +1,16 @@ +#! /usr/bin/env python + +"""Some basic tools for common operations in datasets.""" + +import textwrap + +def dumpvar(var, varname, wrap = 79): + """return a list of string representing the variable var with name varname. + + For example, if var is [1, 2, 3, 4] and varname is l, this will return the + list ["l = [1, 2, 3, 4]"]. Each item in the list is a wrapped line, using + the value in wrap.""" + strvar = varname + " = " + str(var) + l = [i + '\n' for i in textwrap.wrap(strvar, wrap)] + l.append('\n') + return l