# HG changeset patch # User Jeff Hammel # Date 1425231395 28800 # Node ID 202ab51601b4aba73dceed23fcd829b395e8f6a5 # Parent 8bfa28ff74ce5fd2af01dc23699ae88b5bb81819 stub diff -r 8bfa28ff74ce -r 202ab51601b4 numerics/convert.py --- a/numerics/convert.py Sun Mar 01 09:29:38 2015 -0800 +++ b/numerics/convert.py Sun Mar 01 09:36:35 2015 -0800 @@ -11,11 +11,18 @@ from .data import transpose from .read import read_csv, CSVParser -__all__ = ['cast', 'float_or_orig', 'main'] +__all__ = ['cast', + 'float_or_orig', + 'main'] default_cast = (int, float, str) def cast(to_type, *values): + """ + gently cast a thing to a thing; + if you can't, return the original value + """ + retval = [] for value in values: @@ -25,9 +32,15 @@ retval.append(value) return retval +def cast_or_discard(to_type, *values): + """ + cast to `to_type` if possible; + otherwise just throw away + """ + raise NotImplementedError('TODO') # -> record TODO items def float_or_orig(*values): - return cast([float], *values) + return cast(float, *values) def column_type(values, types=default_cast): diff -r 8bfa28ff74ce -r 202ab51601b4 numerics/histogram.py --- a/numerics/histogram.py Sun Mar 01 09:29:38 2015 -0800 +++ b/numerics/histogram.py Sun Mar 01 09:36:35 2015 -0800 @@ -104,6 +104,9 @@ # transpose to columns columns = transpose(data) + # cast to float + import pdb; pdb.set_trace() + # find min, max if not provided if options.min is None: options.min = min([min(column) for column in columns])