consistent interface and description

This commit is contained in:
Martin Diehl 2022-05-13 06:02:22 +02:00
parent c8d48d6eb9
commit 12cd19554f
2 changed files with 9 additions and 3 deletions

View File

@ -370,9 +370,9 @@ class Table:
label : str label : str
Column label. Column label.
data : numpy.ndarray data : numpy.ndarray
Column data. Column data. First dimension needs to match number of rows.
info : str, optional info : str, optional
Human-readable information about the modified data. Human-readable information about the data.
Returns Returns
------- -------

View File

@ -404,10 +404,11 @@ class VTK:
def set(self, def set(self,
label: str = None, label: str = None,
data: Union[np.ndarray, np.ma.MaskedArray] = None, data: Union[np.ndarray, np.ma.MaskedArray] = None,
info: str = None,
*, *,
table: 'Table' = None): table: 'Table' = None):
""" """
Add (or replace existing) point or cell data. Add new or replace existing point or cell data.
Data can either be a numpy.array, which requires a corresponding label, Data can either be a numpy.array, which requires a corresponding label,
or a damask.Table. or a damask.Table.
@ -419,6 +420,8 @@ class VTK:
data : numpy.ndarray or numpy.ma.MaskedArray, optional data : numpy.ndarray or numpy.ma.MaskedArray, optional
Data to add or replace. First array dimension needs to match either Data to add or replace. First array dimension needs to match either
number of cells or number of points. number of cells or number of points.
info : str, optional
Human-readable information about the data.
table: damask.Table, optional table: damask.Table, optional
Data to add or replace. Each table label is individually considered. Data to add or replace. Each table label is individually considered.
Number of rows needs to match either number of cells or number of points. Number of rows needs to match either number of cells or number of points.
@ -465,14 +468,17 @@ class VTK:
_add_array(dup.vtk_data, _add_array(dup.vtk_data,
label, label,
np.where(data.mask,data.fill_value,data) if isinstance(data,np.ma.MaskedArray) else data) np.where(data.mask,data.fill_value,data) if isinstance(data,np.ma.MaskedArray) else data)
if info is not None: dup.comments = f'{label}: {info}'
else: else:
raise ValueError('no label defined for data') raise ValueError('no label defined for data')
elif isinstance(table,Table): elif isinstance(table,Table):
for l in table.labels: for l in table.labels:
_add_array(dup.vtk_data,l,table.get(l)) _add_array(dup.vtk_data,l,table.get(l))
if info is not None: dup.comments = f'{l}: {info}'
else: else:
raise TypeError raise TypeError
return dup return dup