Skip to content
Snippets Groups Projects
Commit 290018f5 authored by Fabian Pedregosa's avatar Fabian Pedregosa
Browse files

Add a misc subpackage in datasets for tools useful to several datasets

From: cdavid <cdavid@cb17146a-f446-4be1-a4f7-bd7c5bb65646>

git-svn-id: https://scikit-learn.svn.sourceforge.net/svnroot/scikit-learn/trunk@14 22fbfee3-77ab-4535-9bad-27d1bd3bc7d8
parent 076938f1
Branches
Tags
No related merge requests found
from tools import dumpvar
#! /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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment