works also for arrays ...

This commit is contained in:
Martin Diehl 2020-03-21 11:07:21 +01:00
parent 2ad86e4202
commit 20a06840b0
3 changed files with 17 additions and 17 deletions

View File

@ -46,7 +46,7 @@ class Table:
def _add_comment(self,label,shape,info):
if info:
if info is not None:
c = '{}{}: {}'.format(label,' '+str(shape) if np.prod(shape,dtype=int) > 1 else '',info)
self.comments.append(c)
@ -251,7 +251,7 @@ class Table:
"""
self.data.rename(columns={label_old:label_new},inplace=True)
c = '{} => {}{}'.format(label_old,label_new,'' if not info else ': {}'.format(info))
c = '{} => {}{}'.format(label_old,label_new,'' if info is None else ': {}'.format(info))
self.comments.append(c)
self.shapes = {(label if label != label_old else label_new):self.shapes[label] for label in self.shapes}

View File

@ -131,7 +131,7 @@ class VTK:
reader = vtk.vtkGenericDataObjectReader()
reader.SetFileName(fname)
reader.Update()
if not dataset_type:
if dataset_type is None:
raise TypeError('Dataset type for *.vtk file not given.')
elif dataset_type.lower().endswith('rectilineargrid'):
geom = reader.GetRectilinearGridOutput()
@ -196,7 +196,7 @@ class VTK:
if isinstance(data,np.ndarray):
d = np_to_vtk(num_array=data.reshape(data.shape[0],-1),deep=True)
if not label:
if label is None:
raise ValueError('No label defined for numpy.ndarray')
d.SetName(label)
if data.shape[0] == N_cells: