From d668f8a56db0bb765357ae42779eb701c79f7366 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 28 Nov 2022 20:05:39 +0000 Subject: [PATCH] don't add empty strings --- python/damask/_vtk.py | 9 +++++++-- python/damask/util.py | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/python/damask/_vtk.py b/python/damask/_vtk.py index e398c0d53..a6f3b2047 100644 --- a/python/damask/_vtk.py +++ b/python/damask/_vtk.py @@ -116,7 +116,10 @@ class VTK: """ s = vtk.vtkStringArray() s.SetName('comments') - for c in util.tail_repack(comments,self.comments): + comments_ = util.tail_repack(comments,self.comments) if comments[:len(self.comments)] == self.comments else \ + [comments] if isinstance(comments,str) else \ + comments + for c in comments_: s.InsertNextValue(c) self.vtk_data.GetFieldData().AddArray(s) @@ -547,9 +550,11 @@ class VTK: Notes ----- - See http://compilatrix.com/article/vtk-1 for further ideas. + The first component is shown when visualizing vector datasets + (this includes tensor datasets because they are flattened). """ + # See http://compilatrix.com/article/vtk-1 for possible improvements. try: import wx _ = wx.App(False) # noqa diff --git a/python/damask/util.py b/python/damask/util.py index 16054b6cb..dc19287f1 100644 --- a/python/damask/util.py +++ b/python/damask/util.py @@ -793,7 +793,7 @@ def tail_repack(extended: _Union[str, _Sequence[str]], Parameters ---------- - extended : (list of) str + extended : (sequence of) str Extended string list with potentially autosplitted tailing string relative to `existing`. existing : list of str Base string list. @@ -811,9 +811,9 @@ def tail_repack(extended: _Union[str, _Sequence[str]], ['a','new','shiny','e','n','t','r','y'] """ - return [extended] if isinstance(extended,str) else existing + \ - ([''.join(extended[len(existing):])] if _np.prod([len(i) for i in extended[len(existing):]]) == 1 else - list(extended[len(existing):])) + new = extended[len(existing):] + return [extended] if isinstance(extended,str) else \ + existing + list([''.join(new)] if _np.prod([len(i) for i in new]) == 1 else new) def aslist(arg: _Union[_IntCollection, int, None]) -> _List: