Allow plot_action.py to support arrays
Change-Id: I5a57decc574ea707cd49fc2957a61489fda8f6b5
diff --git a/frc971/analysis/plot_action.py b/frc971/analysis/plot_action.py
index d7dd48d..ffeec7d 100755
--- a/frc971/analysis/plot_action.py
+++ b/frc971/analysis/plot_action.py
@@ -50,6 +50,14 @@
return defs
+
+def maybeint(x):
+ try:
+ return int(x)
+ except ValueError:
+ return x
+
+
def main():
# Parse all command line arguments.
arg_parser = argparse.ArgumentParser(description='Log Plotter')
@@ -68,7 +76,8 @@
if args.plot_defs:
defs = ReadPlotDefinitions(args.plot_defs)
for definition in defs:
- p.Add(definition[0], definition[1], *definition[2:])
+ mapped_definitions = map(maybeint, definition[2:])
+ p.Add(definition[0], definition[1], *mapped_definitions)
# Otherwise use a pre-defined set of data to plot.
else:
diff --git a/frc971/analysis/plotter.py b/frc971/analysis/plotter.py
index 6e3a879..0b43206 100755
--- a/frc971/analysis/plotter.py
+++ b/frc971/analysis/plotter.py
@@ -35,7 +35,7 @@
# Create a legend label using the binary name (optional), the structure
# name and the data search path.
- label = key[1] + '.' + '.'.join(key[2])
+ label = key[1] + '.' + '.'.join(str(x) for x in key[2])
if not no_binary_in_legend:
label = key[0] + ' ' + label