# HG changeset patch # User Jeff Hammel # Date 1424994499 28800 # Node ID 719029ee5e7b0ec37f8aa0d3435be7d389f96253 # Parent 0df8bcb6d521ce8f55ee525cd53a02b1fcbe8a16 stubbing diff -r 0df8bcb6d521 -r 719029ee5e7b numerics/histogram.py --- a/numerics/histogram.py Thu Feb 26 15:12:48 2015 -0800 +++ b/numerics/histogram.py Thu Feb 26 15:48:19 2015 -0800 @@ -20,21 +20,30 @@ # imports import argparse import os -import subprocess import sys import time from .read import CSVParser +from collections import OrderedDict # module globals -__all__ = ['HistogramParser', 'main'] +__all__ = ['Histogram', 'HistogramParser', 'main'] + +class Histogram(object): + """historgram""" -class HistogramParser(argparse.ArgumentParser): + def __init__(self, bins): + bins = sorted(bin) + assert len(bins) > 1 + self.histogram = self.OrderedDict(zip(bins[:-1], + bins[1:])) + +class HistogramParser(CSVParser): """histogram CLI option parser""" def __init__(self, **kwargs): kwargs.setdefault('formatter_class', argparse.RawTextHelpFormatter) kwargs.setdefault('description', __doc__) - argparse.ArgumentParser.__init__(self, **kwargs) + CSVParser..__init__(self, **kwargs) self.add_argument('-n', '--bins', dest='n_bins', type=int, help="number of bins") self.options = None