# HG changeset patch # User Jeff Hammel # Date 1421699931 28800 # Node ID 36e47061187f1a0c1c937c3782421ae9a758cb3c # Parent 6d34c02f7c9c3d86a290a2020f1fa4763fc567ea stub a transposition function diff -r 6d34c02f7c9c -r 36e47061187f numerics/data.py --- a/numerics/data.py Mon Jan 19 12:13:06 2015 -0800 +++ b/numerics/data.py Mon Jan 19 12:38:51 2015 -0800 @@ -6,7 +6,7 @@ from collections import OrderedDict -__all__ = ['Rows', 'Columns'] +__all__ = ['ColumnNumberException', 'ColumnLengthException', 'Rows', 'Columns'] class ColumnNumberException(Exception): @@ -19,6 +19,16 @@ Exception.__init__(self.__doc__.format(**self.__dict__).strip()) +def transpose(array): + """makes rows into columns or vice versa""" + + if not array: + return array # nothing to do + + n_cols = len(array[0]) + retval = []] * n_cols + raise NotImplementedError('TODO') # -> record TODO items + class ColumnLengthException(ColumnNumberException): """ wrong length of column: {given} given; {expected} expected @@ -69,5 +79,4 @@ def __iadd__(self, item): column_name, values = item assert column_name not in self.columns - return self