Merge branch 'sequence-not-iterable' into 'development'

Need sequence not iterable

See merge request damask/DAMASK!587
This commit is contained in:
Philip Eisenlohr 2022-05-25 13:25:25 +00:00
commit 1dc5e353c4
3 changed files with 14 additions and 13 deletions

View File

@ -50,15 +50,16 @@ class Grid:
Coordinates of grid origin in meter. Defaults to [0.0,0.0,0.0]. Coordinates of grid origin in meter. Defaults to [0.0,0.0,0.0].
initial_conditions : dictionary, optional initial_conditions : dictionary, optional
Labels and values of the inital conditions at each material point. Labels and values of the inital conditions at each material point.
comments : (list of) str, optional comments : str or iterable of str, optional
Comments, e.g. history of operations. Additional, human-readable information, e.g. history of operations.
""" """
self.material = material self.material = material
self.size = size # type: ignore self.size = size # type: ignore
self.origin = origin # type: ignore self.origin = origin # type: ignore
self.initial_conditions = {} if initial_conditions is None else initial_conditions self.initial_conditions = {} if initial_conditions is None else initial_conditions
self.comments = [] if comments is None else comments # type: ignore comments_ = [comments] if isinstance(comments,str) else comments
self.comments = [] if comments_ is None else [str(c) for c in comments_]
def __repr__(self) -> str: def __repr__(self) -> str:
"""Give short human-readable summary.""" """Give short human-readable summary."""

View File

@ -1,6 +1,6 @@
import re import re
import copy import copy
from typing import Union, Tuple, List from typing import Union, Tuple, List, Iterable
import pandas as pd import pandas as pd
import numpy as np import numpy as np
@ -14,7 +14,7 @@ class Table:
def __init__(self, def __init__(self,
shapes: dict, shapes: dict,
data: np.ndarray, data: np.ndarray,
comments: Union[str, list] = None): comments: Union[str, Iterable[str]] = None):
""" """
New spreadsheet. New spreadsheet.
@ -30,7 +30,7 @@ class Table:
""" """
comments_ = [comments] if isinstance(comments,str) else comments comments_ = [comments] if isinstance(comments,str) else comments
self.comments = [] if comments_ is None else [c for c in comments_] self.comments = [] if comments_ is None else [str(c) for c in comments_]
self.shapes = { k:(v,) if isinstance(v,(np.int64,np.int32,int)) else v for k,v in shapes.items() } self.shapes = { k:(v,) if isinstance(v,(np.int64,np.int32,int)) else v for k,v in shapes.items() }
self.data = pd.DataFrame(data=data) self.data = pd.DataFrame(data=data)
self._relabel('uniform') self._relabel('uniform')
@ -434,8 +434,8 @@ class Table:
def rename(self, def rename(self,
old: Union[str, List[str]], old: Union[str, Iterable[str]],
new: Union[str, List[str]], new: Union[str, Iterable[str]],
info: str = None) -> 'Table': info: str = None) -> 'Table':
""" """
Rename column data. Rename column data.

View File

@ -103,7 +103,7 @@ class VTK:
Parameters Parameters
---------- ----------
comments : str or list of str comments : str or sequence of str
Comments. Comments.
""" """
@ -153,11 +153,11 @@ class VTK:
Parameters Parameters
---------- ----------
cells : iterable of int, len (3) cells : sequence of int, len (3)
Number of cells along each dimension. Number of cells along each dimension.
size : iterable of float, len (3) size : sequence of float, len (3)
Physical length along each dimension. Physical length along each dimension.
origin : iterable of float, len (3), optional origin : sequence of float, len (3), optional
Coordinates of grid origin. Coordinates of grid origin.
Returns Returns
@ -257,7 +257,7 @@ class VTK:
Parameters Parameters
---------- ----------
grid : iterables of floats, len (3) grid : sequence of sequences of floats, len (3)
Grid coordinates along x, y, and z directions. Grid coordinates along x, y, and z directions.
Returns Returns