don't add empty strings

This commit is contained in:
Martin Diehl 2022-11-28 20:05:39 +00:00 committed by Philip Eisenlohr
parent bfdd072d06
commit d668f8a56d
2 changed files with 11 additions and 6 deletions

View File

@ -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

View File

@ -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: