From e089e6020251f5eab64bfbc0270101d396a0972f Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 30 Sep 2015 18:44:54 +0000 Subject: [PATCH] transparently deal with one-dimensional array output --- lib/damask/asciitable.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/damask/asciitable.py b/lib/damask/asciitable.py index cb0971497..803d835f6 100644 --- a/lib/damask/asciitable.py +++ b/lib/damask/asciitable.py @@ -475,12 +475,19 @@ class ASCIItable(): return self.output_write(delimiter.join(map(str,self.data))) # ------------------------------------------------------------------ - def data_writeArray(self, fmt = None, delimiter = '\t'): + def data_writeArray(self, + fmt = None, + delimiter = '\t'): ''' write whole numpy array data ''' for row in self.data: - self.__IO__['out'].write(delimiter.join([fmt % value for value in row] if fmt else map(repr,row)) + '\n') + try: + output = [fmt % value for value in row] if fmt else map(repr,row) + except: + output = [fmt % row] if fmt else [repr(row)] + + self.__IO__['out'].write(delimiter.join(output) + '\n') # ------------------------------------------------------------------ def data_append(self,