guide the user with explicit keywords

This commit is contained in:
Martin Diehl 2023-02-01 15:03:30 +01:00
parent 8895e7a36f
commit fd84406903
1 changed files with 20 additions and 11 deletions

View File

@ -1,4 +1,4 @@
from typing import Optional, Union, Sequence, Dict, Any, Collection from typing import Optional, Union, Sequence, Dict, Any, List
import numpy as np import numpy as np
import h5py import h5py
@ -23,8 +23,10 @@ class ConfigMaterial(Config):
""" """
def __init__(self, def __init__(self,
config: Optional[Dict[str, Any]] = None, config: Optional[Union[str,Dict[str,Any]]] = None,*,
**kwargs): homogenization: Optional[Dict[str,Dict]] = None,
phase: Optional[Dict[str,Dict]] = None,
material: Optional[List[Dict[str,Any]]] = None):
""" """
New material configuration. New material configuration.
@ -32,16 +34,23 @@ class ConfigMaterial(Config):
---------- ----------
config : dict or str, optional config : dict or str, optional
Material configuration. String needs to be valid YAML. Material configuration. String needs to be valid YAML.
Defaults to None, in which case empty entries for homogenization : dict, optional
any missing material, homogenization, and phase entry are created. Homogenization configuration.
kwargs : key=value pairs, optional Defaults to an empty dict if 'config' is not given.
Initial content specified as pairs of key=value. phase : dict, optional
Phase configuration.
Defaults to an empty dict if 'config' is not given.
material : dict, optional
Materialpoint configuration.
Defaults to an empty list if 'config' is not given.
""" """
default: Collection kwargs: Dict[str,Union[Dict[str,Dict],List[Dict[str,Any]]]] = {}
if config is None: for arg,value in zip(['homogenization','phase','material'],[homogenization,phase,material]):
for section, default in {'material':[],'homogenization':{},'phase':{}}.items(): if value is None and config is None:
if section not in kwargs: kwargs.update({section:default}) kwargs[arg] = [] if arg == 'material' else {}
elif value is not None:
kwargs[arg] = value
super().__init__(config,**kwargs) super().__init__(config,**kwargs)