changeset 115:7fac47bb648e

mysteries and more mysteries: bokeh should really be a plugin for this, not the way to do it, but we are porting so lets ignore that and boldly walk forward
author Jeff Hammel <k0scist@gmail.com>
date Sun, 15 Mar 2015 17:03:38 -0700
parents 8b5fba91dac5
children fe820a3afa48
files numerics/bar.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/numerics/bar.py	Sun Mar 15 16:31:21 2015 -0700
+++ b/numerics/bar.py	Sun Mar 15 17:03:38 2015 -0700
@@ -10,15 +10,16 @@
 
 # imports
 import argparse
-#import pandas as pd
 import sys
+from .data import transpose
 from .manipulate import ManipulationParser
-#from .read import CSVParser
 from bokeh.charts import Bar
 from bokeh.plotting import *
+from collections import OrderedDict
 
 __all__ = ['bar_chart', 'BarChartParser', 'main']
 
+
 def bar_chart(data, output):
     """create a bar chart"""
 
@@ -49,8 +50,15 @@
     # process data
     data = parser.typed_data()
 
+    # ensure a mapping is given
+    if len(data) == 1:
+        data.insert(0, range(len(data[-1])))
+    if len(data) != 2:
+        parser.error("A mapping is required")
+    mapping = OrderedDict(transpose(data))
+
     # generate bar chart
-    bar_chart(data, options.output)
+    bar_chart(mapping, options.output)
 
 # BBB keeping this around for reference;
 # we should probably move to a better parsing system at some point