small improvements
bugfix: writing correct labels (now consistent with readin) error handling for inconsistent initialization
This commit is contained in:
parent
a8016d64bb
commit
76a1506893
|
@ -13,7 +13,7 @@ class Table():
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
array : numpy.ndarray
|
array : numpy.ndarray
|
||||||
Data.
|
Data as two dimensional array
|
||||||
headings : dict
|
headings : dict
|
||||||
Column headings. Labels as keys and shape as tuple. Example 'F':(3,3) for a deformation gradient.
|
Column headings. Labels as keys and shape as tuple. Example 'F':(3,3) for a deformation gradient.
|
||||||
comments : iterable of str, optional
|
comments : iterable of str, optional
|
||||||
|
@ -29,6 +29,9 @@ class Table():
|
||||||
d[i] = label
|
d[i] = label
|
||||||
i+=1
|
i+=1
|
||||||
|
|
||||||
|
if i != self.data.shape[1]:
|
||||||
|
raise IndexError('Mismatch between array shape and headings')
|
||||||
|
|
||||||
self.data.rename(columns=d,inplace=True)
|
self.data.rename(columns=d,inplace=True)
|
||||||
|
|
||||||
if comments is None:
|
if comments is None:
|
||||||
|
@ -123,7 +126,7 @@ class Table():
|
||||||
labels+=['{}_{}'.format(i+1,l)\
|
labels+=['{}_{}'.format(i+1,l)\
|
||||||
for i in range(self.headings[l][0])]
|
for i in range(self.headings[l][0])]
|
||||||
else:
|
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))]
|
for i in range(np.prod(self.headings[l],dtype=int))]
|
||||||
|
|
||||||
header = ['{} header'.format(len(self.comments)+1)]\
|
header = ['{} header'.format(len(self.comments)+1)]\
|
||||||
|
|
Loading…
Reference in New Issue