transparently deal with one-dimensional array output

This commit is contained in:
Philip Eisenlohr 2015-09-30 18:44:54 +00:00
parent ed7c231712
commit e089e60202
1 changed files with 9 additions and 2 deletions

View File

@ -475,12 +475,19 @@ class ASCIItable():
return self.output_write(delimiter.join(map(str,self.data))) 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 write whole numpy array data
''' '''
for row in self.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, def data_append(self,