diff --git a/lib/damask/config/__init__.py b/lib/damask/config/__init__.py index 3c75ebd19..ba31241d0 100644 --- a/lib/damask/config/__init__.py +++ b/lib/damask/config/__init__.py @@ -1,5 +1,5 @@ # -*- coding: UTF-8 no BOM -*- -# $Id$ +"""Aggregator for configuration file handling""" -from .material import Material +from .material import Material #noqa diff --git a/lib/damask/config/material.py b/lib/damask/config/material.py index 09b716e04..4c228e312 100644 --- a/lib/damask/config/material.py +++ b/lib/damask/config/material.py @@ -100,20 +100,19 @@ class Texture(Section): class Material(): - - ''' - Reads, manipulates and writes material.config files - ''' + """Reads, manipulates and writes material.config files""" + __slots__ = ['data'] def __init__(self,verbose=True): + """generates ordered list of parts""" self.parts = [ 'homogenization', 'microstructure', 'crystallite', 'phase', 'texture', - ] # ordered (!) list of parts + ] self.data = {\ 'homogenization': {'__order__': []}, 'microstructure': {'__order__': []}, @@ -124,6 +123,7 @@ class Material(): self.verbose = verbose def __repr__(self): + """returns current configuration to be used as material.config""" me = [] for part in self.parts: if self.verbose: print('doing '+part) @@ -144,7 +144,6 @@ class Material(): re_sec = re.compile(r'^\[(.+)\]$') # pattern for section name_section = '' - idx_section = 0 active = False for line in content: @@ -197,8 +196,7 @@ class Material(): return saveFile def add_section(self, part=None, section=None, initialData=None, merge = False): - '''adding/updating''' - + """adding/updating""" part = part.lower() section = section.lower() if part not in self.parts: raise Exception('invalid part %s'%part) @@ -227,10 +225,10 @@ class Material(): def add_microstructure(self, section='', components={}, # dict of phase,texture, and fraction lists ): - ''' Experimental! Needs expansion to multi-constituent microstructures...''' - + """Experimental! Needs expansion to multi-constituent microstructures...""" microstructure = Microstructure() - components=dict((k.lower(), v) for k,v in components.iteritems()) # make keys lower case (http://stackoverflow.com/questions/764235/dictionary-to-lowercase-in-python) + # make keys lower case (http://stackoverflow.com/questions/764235/dictionary-to-lowercase-in-python) + components=dict((k.lower(), v) for k,v in components.iteritems()) for key in ['phase','texture','fraction','crystallite']: if type(components[key]) is not list: @@ -259,8 +257,8 @@ class Material(): section=None, key=None, value=None): - if type(value) is not type([]): - if type(value) is not type('s'): + if not isinstance(value,list): + if not isinstance(value,str): value = '%s'%value value = [value] newlen = len(value) @@ -271,17 +269,3 @@ class Material(): if newlen is not oldlen: print('Length of value was changed from %i to %i!'%(oldlen,newlen)) - - -def ex1(): - mat=Material() - p=Phase({'constitution':'lump'}) - t=Texture() - t.add_component('gauss',{'eulers':[1,2,3]}) - mat.add_section('phase','phase1',p) - mat.add_section('texture','tex1',t) - mat.add_microstructure('mustruct1',{'phase':['phase1']*2,'texture':['tex1']*2,'fraction':[0.2]*2}) - print(mat) - mat.write(file='poop') - mat.write(file='poop',overwrite=True) - diff --git a/lib/damask/geometry/__init__.py b/lib/damask/geometry/__init__.py index 3d35ad4fe..51199965b 100644 --- a/lib/damask/geometry/__init__.py +++ b/lib/damask/geometry/__init__.py @@ -1,7 +1,7 @@ # -*- coding: UTF-8 no BOM -*- -# $Id$ +"""Aggregator for geometry handling""" -from .geometry import Geometry # only one class -from .spectral import Spectral # only one class -from .marc import Marc # only one class +from .geometry import Geometry # noqa +from .spectral import Spectral # noqa +from .marc import Marc # noqa diff --git a/lib/damask/geometry/geometry.py b/lib/damask/geometry/geometry.py index 83a7c58a6..25a676b83 100644 --- a/lib/damask/geometry/geometry.py +++ b/lib/damask/geometry/geometry.py @@ -5,10 +5,11 @@ import damask.geometry class Geometry(): - ''' - General class for geometry parsing. - Sub-classed by the individual solvers. - ''' + """ + General class for geometry parsing. + + Sub-classed by the individual solvers. + """ def __init__(self,solver=''): solverClass = {