11# SPDX-License-Identifier: AGPL-3.0-or-later
22import logging
3- from typing import Any , Optional , Sequence , Union
3+ from typing import Any , Sequence
44
55import h5py
66import numpy as np
@@ -21,10 +21,10 @@ class ConfigMaterial(YAML):
2121 """
2222
2323 def __init__ (self ,
24- config : Optional [ Union [ str , dict [str ,Any ]]] = None ,* ,
25- homogenization : Optional [ dict [str ,dict ]] = None ,
26- phase : Optional [ dict [str ,dict ]] = None ,
27- material : Optional [ list [dict [str ,Any ]]] = None ):
24+ config : str | dict [str , Any ] | None = None ,* ,
25+ homogenization : dict [str ,dict ] | None = None ,
26+ phase : dict [str ,dict ] | None = None ,
27+ material : list [dict [str ,Any ]] | None = None ):
2828 """
2929 New material configuration.
3030
@@ -42,7 +42,7 @@ def __init__(self,
4242 Materialpoint configuration.
4343 Defaults to an empty list if 'config' is not given.
4444 """
45- kwargs : dict [str ,Union [ dict [str ,dict ], list [dict [str ,Any ] ]]] = {}
45+ kwargs : dict [str ,dict [str ,dict ] | list [dict [str ,Any ]]] = {}
4646 for arg ,value in zip (['homogenization' ,'phase' ,'material' ],[homogenization ,phase ,material ]):
4747 if value is None and config is None :
4848 kwargs [arg ] = [] if arg == 'material' else {}
@@ -54,13 +54,13 @@ def __init__(self,
5454
5555 @staticmethod
5656 def load_DREAM3D (fname : str ,
57- grain_data : Optional [ str ] = None ,
58- cell_data : Optional [ str ] = None ,
57+ grain_data : str | None = None ,
58+ cell_data : str | None = None ,
5959 cell_ensemble_data : str = 'CellEnsembleData' ,
6060 phases : str = 'Phases' ,
6161 Euler_angles : str = 'EulerAngles' ,
6262 phase_names : str = 'PhaseName' ,
63- base_group : Optional [ str ] = None ) -> 'ConfigMaterial' :
63+ base_group : str | None = None ) -> 'ConfigMaterial' :
6464 """
6565 Load DREAM3D (HDF5) file.
6666
@@ -157,11 +157,11 @@ def load_DREAM3D(fname: str,
157157
158158 @staticmethod
159159 def from_table (table : Table ,* ,
160- homogenization : Optional [ Union [ str , StrSequence ]] = None ,
161- phase : Optional [ Union [ str , StrSequence ]] = None ,
162- v : Optional [ Union [ str , FloatSequence ]] = None ,
163- O : Optional [ Union [ str , FloatSequence ]] = None ,
164- V_e : Optional [ Union [ str , FloatSequence ]] = None ) -> 'ConfigMaterial' :
160+ homogenization : str | StrSequence | None = None ,
161+ phase : str | StrSequence | None = None ,
162+ v : str | FloatSequence | None = None ,
163+ O : str | FloatSequence | None = None ,
164+ V_e : str | FloatSequence | None = None ) -> 'ConfigMaterial' :
165165 """
166166 Generate from an ASCII table.
167167
@@ -357,8 +357,8 @@ def is_valid(self) -> bool:
357357
358358 def material_rename_phase (self ,
359359 mapping : dict [str , str ],
360- ID : Optional [ Sequence [int ]] = None ,
361- constituent : Optional [ Sequence [int ]] = None ) -> 'ConfigMaterial' :
360+ ID : Sequence [int ] | None = None ,
361+ constituent : Sequence [int ] | None = None ) -> 'ConfigMaterial' :
362362 """
363363 Change phase name in material.
364364
@@ -390,7 +390,7 @@ def material_rename_phase(self,
390390
391391 def material_rename_homogenization (self ,
392392 mapping : dict [str , str ],
393- ID : Optional [ Sequence [int ]] = None ) -> 'ConfigMaterial' :
393+ ID : Sequence [int ] | None = None ) -> 'ConfigMaterial' :
394394 """
395395 Change homogenization name in material.
396396
@@ -417,11 +417,11 @@ def material_rename_homogenization(self,
417417
418418
419419 def material_add (self ,* ,
420- homogenization : Optional [ Union [ str , StrSequence ]] = None ,
421- phase : Optional [ Union [ str , StrSequence ]] = None ,
422- v : Optional [ Union [ float , FloatSequence ]] = None ,
423- O : Optional [ Union [ float , FloatSequence ]] = None ,
424- V_e : Optional [ Union [ float , FloatSequence ]] = None ) -> 'ConfigMaterial' :
420+ homogenization : str | StrSequence | None = None ,
421+ phase : str | StrSequence | None = None ,
422+ v : float | FloatSequence | None = None ,
423+ O : float | FloatSequence | None = None ,
424+ V_e : float | FloatSequence | None = None ) -> 'ConfigMaterial' :
425425 """
426426 Add material entries.
427427
0 commit comments