# HG changeset patch # User Jeff Hammel # Date 1426464218 25200 # Node ID 7fac47bb648e9b07f8fd7faaff21cc44fc664d71 # Parent 8b5fba91dac50839388b37d45bfdb8bae88a0c53 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 diff -r 8b5fba91dac5 -r 7fac47bb648e numerics/bar.py --- 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