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].
initial_conditions : dictionary, optional
Labels and values of the inital conditions at each material point.
comments : (list of) str, optional
Comments, e.g. history of operations.
comments : str or iterable of str, optional
Additional, human-readable information, e.g. history of operations.
"""
self.material = material
self.size = size # type: ignore
self.origin = origin # type: ignore
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:
"""Give short human-readable summary."""

View File

@ -1,6 +1,6 @@
import re
import copy
from typing import Union, Tuple, List
from typing import Union, Tuple, List, Iterable
import pandas as pd
import numpy as np
@ -14,7 +14,7 @@ class Table:
def __init__(self,
shapes: dict,
data: np.ndarray,
comments: Union[str, list] = None):
comments: Union[str, Iterable[str]] = None):
"""
New spreadsheet.
@ -30,7 +30,7 @@ class Table:
"""
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.data = pd.DataFrame(data=data)
self._relabel('uniform')
@ -434,8 +434,8 @@ class Table:
def rename(self,
old: Union[str, List[str]],
new: Union[str, List[str]],
old: Union[str, Iterable[str]],
new: Union[str, Iterable[str]],
info: str = None) -> 'Table':
"""
Rename column data.

View File

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