From 76a15068931a225a92e53ebe52bff2f33c157a5f Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 28 Nov 2019 20:18:54 +0100 Subject: [PATCH] small improvements bugfix: writing correct labels (now consistent with readin) error handling for inconsistent initialization --- python/damask/table.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/damask/table.py b/python/damask/table.py index 0c9f3ac40..04a073cce 100644 --- a/python/damask/table.py +++ b/python/damask/table.py @@ -13,7 +13,7 @@ class Table(): Parameters ---------- array : numpy.ndarray - Data. + Data as two dimensional array headings : dict Column headings. Labels as keys and shape as tuple. Example 'F':(3,3) for a deformation gradient. comments : iterable of str, optional @@ -29,6 +29,9 @@ class Table(): d[i] = label i+=1 + if i != self.data.shape[1]: + raise IndexError('Mismatch between array shape and headings') + self.data.rename(columns=d,inplace=True) if comments is None: @@ -123,7 +126,7 @@ class Table(): labels+=['{}_{}'.format(i+1,l)\ for i in range(self.headings[l][0])] else: - labels+=['{}:{}_{}'.format(i+1,'x'.join([str(d) for d in self.headings[l]]),l)\ + labels+=['{}:{}_{}'.format('x'.join([str(d) for d in self.headings[l]]),i+1,l)\ for i in range(np.prod(self.headings[l],dtype=int))] header = ['{} header'.format(len(self.comments)+1)]\