# HG changeset patch # User Jeff Hammel # Date 1421700685 28800 # Node ID e7e49b46832b8ca62704d40fc0f4be105f7e21a3 # Parent e39643d18d828fd77bd5e78bc54092c60fcfcfbd make this function semi-meaningful diff -r e39643d18d82 -r e7e49b46832b numerics/data.py --- a/numerics/data.py Mon Jan 19 12:45:06 2015 -0800 +++ b/numerics/data.py Mon Jan 19 12:51:25 2015 -0800 @@ -6,7 +6,11 @@ from collections import OrderedDict -__all__ = ['ColumnNumberException', 'ColumnLengthException', 'Rows', 'Columns'] +__all__ = ['ColumnNumberException', + 'ColumnLengthException', + 'transpose', + 'Rows', + 'Columns'] class ColumnNumberException(Exception): @@ -25,10 +29,12 @@ if not array: return array # nothing to do - n_cols = len(array[0]) - retval = [[]] * n_cols + n_cols = set([len(row) for row in array]) + if len(n_cols) != 1: + raise Exception("Differing number of columns found: {}".format(', '.join(sorted(n_cols)))) + return zip(*array) - # XXX this is a nothing function; we shouldn't use this + class ColumnLengthException(ColumnNumberException): """