Mercurial > hg > tvii
comparison tvii/dataset/cli.py @ 87:9d5a5e9f5c3b
add kmeans + dataset
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 17 Dec 2017 14:05:57 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
86:b56d329c238d | 87:9d5a5e9f5c3b |
---|---|
1 """ | |
2 command line abstraction for dataset generations | |
3 """ | |
4 | |
5 import csv | |
6 import argparse | |
7 import sys | |
8 from ..cli import CLIParser | |
9 | |
10 | |
11 class DatasetGenerationParser(CLIParser): | |
12 """argument parser for dataset generation""" | |
13 | |
14 def add_arguments(self): | |
15 self.add_argument('-N', '--number', dest='number', | |
16 type=int, default=100, | |
17 help="number of points [DEFAULT: %(default)s]") | |
18 self.add_argument('-D', '--dimensions', dest='dimensions', | |
19 type=int, default=2, | |
20 help="number of dimensions of data [DEFAULT: %(default)s]") | |
21 self.add_argument('-o', '--output', dest='output', | |
22 type=argparse.FileType('w'), default=sys.stdout, | |
23 help="where to write the data to, or stdout by default") | |
24 | |
25 def writer(self): | |
26 """returns CSV writer as specified by arguments""" | |
27 | |
28 assert self.options | |
29 return csv.writer(self.options.output) |