Merge branch '149-python-vtk-improvements' into 'development'
don't add empty strings Closes #149 See merge request damask/DAMASK!673
This commit is contained in:
commit
3505fdee9a
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue