Mercurial > hg > numerics
changeset 48:36e47061187f
stub a transposition function
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 19 Jan 2015 12:38:51 -0800 |
parents | 6d34c02f7c9c |
children | 5caa67643162 |
files | numerics/data.py |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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