Changeset 25817


Ignore:
Timestamp:
12/03/20 05:46:39 (4 years ago)
Author:
bdef
Message:

CHG:minor syntax fix for to suit PEP8

Location:
issm/trunk-jpl/src/m
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/qmustatistics.py

    r25698 r25817  
    1313
    1414    def __init__(self, *args):  #{{{
    15         self.nfiles_per_directory   = 5 # Number of files per output directory
    16         self.ndirectories           = 50 # Number of output directories; should be < numcpus
     15        self.nfiles_per_directory = 5 # Number of files per output directory
     16        self.ndirectories  = 50 # Number of output directories; should be < numcpus
    1717
    1818        self.method = [{}]
     
    6060    def setdefaultparameters(self):  # {{{
    6161        self.method[0]['name'] = 'None'
    62         self.nfiles_per_directory   = 5 # Number of files per output directory
    63         self.ndirectories           = 50 # Number of output directories; should be < numcpus
     62        self.nfiles_per_directory = 5 # Number of files per output directory
     63        self.ndirectories = 50 # Number of output directories; should be < numcpus
    6464        return self
    6565    #}}}
  • issm/trunk-jpl/src/m/classes/results.py

    r25780 r25817  
    11from copy import deepcopy
    22
    3 import numpy as np
    4 
    5 from fielddisplay import fielddisplay
    6 
    7 
    8 class results(object): #{{{
     3
     4class results(object):  #{{{
    95    """RESULTS class definition
    106
     
    139
    1410    TODO:
    15     - Rework so that a solution of arbitrary length (normal or transient) can 
     11    - Rework so that a solution of arbitrary length (normal or transient) can
    1612    initialized from one call to the results class constructor.
    1713    """
    1814
    19     def __init__(self): #{{{
    20         pass
    21     #}}}
    22 
    23     def __repr__(self): #{{{
     15    def __init__(self):  #{{{
     16        pass
     17    #}}}
     18
     19    def __repr__(self):  #{{{
    2420        s = ''
    2521        for key, value in self.__dict__.items():
     
    2723                lengthvalue = 1
    2824            else:
    29                 lengthvalue = len(value)
     25                try:
     26                    lengthvalue = len(value)
     27                except TypeError:
     28                    lengthvalue = 1
    3029            s += '    {}: [1x{} struct]\n'.format(key, lengthvalue)
    3130
     
    3332    #}}}
    3433
    35     def setdefaultparameters(self): #{{{
     34    def setdefaultparameters(self):  #{{{
    3635        #do nothing
    3736        return self
    3837    #}}}
    3938
    40     def checkconsistency(self, md, solution, analyses): #{{{
    41         return md
    42     #}}}
    43 
    44     def marshall(self, prefix, md, fid): #{{{
    45         pass
    46     #}}}
    47 #}}}
    48 
    49 class resultsdakota(object): #{{{
    50     """RESULTSDAKOTA class definition - Used to store results from a run of
     39    def checkconsistency(self, md, solution, analyses):  #{{{
     40        return md
     41    #}}}
     42
     43    def marshall(self, prefix, md, fid):  #{{{
     44        pass
     45    #}}}
     46#}}}
     47
     48
     49class resultsdakota(object):  #{{{
     50    """RESULTSDAKOTA class definition - Used to store results from a run of
    5151    Dakota.
    5252
     
    5757    """
    5858
    59     def __init__(self): #{{{
    60         pass
    61     #}}}
    62 
    63     def __repr__(self): #{{{
     59    def __init__(self):  #{{{
     60        pass
     61    #}}}
     62
     63    def __repr__(self):  #{{{
    6464        s = ''
    6565        for key, value in self.__dict__.items():
     
    7373    #}}}
    7474
    75     def __len__(self): #{{{
     75    def __len__(self):  #{{{
    7676        return len(self.__dict__.keys())
    7777    #}}}
    7878
    79     def setdefaultparameters(self): #{{{
     79    def setdefaultparameters(self):  #{{{
    8080        #do nothing
    8181        return self
    8282    #}}}
    8383
    84     def checkconsistency(self, md, solution, analyses): #{{{
    85         return md
    86     #}}}
    87 
    88     def marshall(self, prefix, md, fid): #{{{
    89         pass
    90     #}}}
    91 #}}}
    92 
    93 class solution(object): #{{{
    94     """SOLUTION class definition - Value of an attribute (which should be
     84    def checkconsistency(self, md, solution, analyses):  #{{{
     85        return md
     86    #}}}
     87
     88    def marshall(self, prefix, md, fid):  #{{{
     89        pass
     90    #}}}
     91#}}}
     92
     93
     94class solution(object):  #{{{
     95    """SOLUTION class definition - Value of an attribute (which should be
    9596    a string representing a solution type) of an instance of results class
    9697
     
    102103    NOTE:
    103104    - Under MATLAB, this is implemented as a structure array
    104     - Only when this instance of solution represents a transient solution 
     105    - Only when this instance of solution represents a transient solution
    105106    should self.steps have more than one element
    106107    """
    107108
    108     def __init__(self, *args): #{{{
     109    def __init__(self, *args):  #{{{
    109110        self.steps = None
    110111        if len(args) == 1:
     
    118119    #}}}
    119120
    120     def __deepcopy__(self, memo): #{{{
     121    def __deepcopy__(self, memo):  #{{{
    121122        return solution(deepcopy(self.steps, memo))
    122123    #}}}
    123124
    124     def __repr__(self): #{{{
     125    def __repr__(self):  #{{{
    125126        s = ''
    126127        numsteps = len(self.steps)
     
    137138    #}}}
    138139
    139     def __len__(self): #{{{
     140    def __len__(self):  #{{{
    140141        return len(self.steps)
    141142    #}}}
    142143
    143     def __getattr__(self, key): #{{{
     144    def __getattr__(self, key):  #{{{
    144145        if len(self.steps) == 1:
    145146            return getattr(self.steps[0], key)
     
    148149    #}}}
    149150
    150     def __getitem__(self, index): #{{{
     151    def __getitem__(self, index):  #{{{
    151152        while True:
    152153            try:
     
    158159    #}}}
    159160
    160     def setdefaultparameters(self): #{{{
    161         return self
    162     #}}}
    163 
    164     def checkconsistency(self, md, solution, analyses): #{{{
    165         return md
    166     #}}}
    167 
    168     def marshall(self, prefix, md, fid): #{{{
    169         pass
    170     #}}}
    171 #}}}
    172 
    173 class solutionstep(object): #{{{
     161    def setdefaultparameters(self):  #{{{
     162        return self
     163    #}}}
     164
     165    def checkconsistency(self, md, solution, analyses):  #{{{
     166        return md
     167    #}}}
     168
     169    def marshall(self, prefix, md, fid):  #{{{
     170        pass
     171    #}}}
     172#}}}
     173
     174
     175class solutionstep(object):  #{{{
    174176    """SOLUTIONSTEP class definition - Single element of <solution>.steps
    175177
     
    178180    """
    179181
    180     def __init__(self, *args): #{{{
    181         pass
    182     #}}}
    183 
    184     def __repr__(self): #{{{
     182    def __init__(self, *args):  #{{{
     183        pass
     184    #}}}
     185
     186    def __repr__(self):  #{{{
    185187        s = ''
    186188        width = self.getlongestfieldname()
     
    191193    #}}}
    192194
    193     def getfieldnames(self): #{{{
     195    def getfieldnames(self):  #{{{
    194196        return self.__dict__.keys()
    195197    #}}}
    196198
    197     def getlongestfieldname(self): #{{{
     199    def getlongestfieldname(self):  #{{{
    198200        maxlength = 0
    199201        for key in self.__dict__.keys():
     
    205207    #}}}
    206208
    207     def setdefaultparameters(self): #{{{
    208         return self
    209     #}}}
    210 
    211     def checkconsistency(self, md, solution, analyses): #{{{
    212         return md
    213     #}}}
    214 
    215     def marshall(self, prefix, md, fid): #{{{
    216         pass
    217     #}}}
    218 #}}}
     209    def setdefaultparameters(self):  #{{{
     210        return self
     211    #}}}
     212
     213    def checkconsistency(self, md, solution, analyses):  #{{{
     214        return md
     215    #}}}
     216
     217    def marshall(self, prefix, md, fid):  #{{{
     218        pass
     219    #}}}
     220#}}}
  • issm/trunk-jpl/src/m/classes/solidearthsettings.py

    r25806 r25817  
    1313    """
    1414
    15     def __init__(self, *args): #{{{
     15    def __init__(self, *args):  #{{{
    1616        self.reltol                 = 0
    1717        self.abstol                 = 0
  • issm/trunk-jpl/src/m/os/issmscpout.py

    r24252 r25817  
    1717    #if hostname and host are the same, do a simple copy
    1818
    19     if m.strcmpi(host, hostname):
     19    if host == hostname:
    2020        for package in packages:
    2121            here = os.getcwd()
  • issm/trunk-jpl/src/m/solve/loadresultfromdisk.py

    r25718 r25817  
    22import numpy as np
    33
    4 def loadresultfromdisk(filename, step, name, *args): # {{{
     4
     5def loadresultfromdisk(filename, step, name, *args):  # {{{
    56    """
    6     LOADRESULTFROMDISK - load specific result of solution sequence from disk 
     7    LOADRESULTFROMDISK - load specific result of solution sequence from disk
    78    file "filename"
    89
     
    1819    try:
    1920        fid = open(filename, 'rb')
    20     except IOError as e:
     21    except IOError:
    2122        raise IOError("loadresultsfromdisk error message: could not open {} for binary reading".format(filename))
    2223
     
    3637        rstep = struct.unpack('i', fid.read(struct.calcsize('i')))[0]
    3738
    38         # TODO: Check number of characters unpacked and break if need be (see 
     39        # TODO: Check number of characters unpacked and break if need be (see
    3940        #       src/m/solve/loadresultfromdisk.py)
    40        
     41
    4142        if (rstep == step) and (fieldname == name):
    4243            # ok, go read the result really
  • issm/trunk-jpl/src/m/solve/loadresultsfromcluster.py

    r25688 r25817  
    11import os
    2 import platform
    32import socket
    43
     
    1514        print(('WARNING: ' + filename + ' does not exist'))
    1615
     16
    1717def loadresultsfromcluster(md, *args):
    1818    """LOADRESULTSFROMCLUSTER - load results of solution sequence from cluster
    1919
    2020    Usage:
    21         md = loadresultsfromcluster(md, runtimename)
     21        md = loadresultsfromcluster(md)
     22        md = loadresultsfromcluster(md, 'runtimename', runtimename)
    2223    """
    2324
  • issm/trunk-jpl/src/m/solve/loadresultsfromdisk.py

    r25726 r25817  
    11import os
    2 
    32from helpers import fieldnames, struct
    43from parseresultsfromdisk import parseresultsfromdisk
     
    87
    98def loadresultsfromdisk(md, filename):
    10     """LOADRESULTSFROMDISK - load results of solution sequence from disk file 
     9    """LOADRESULTSFROMDISK - load results of solution sequence from disk file
    1110    "filename"
    1211
     
    2322        # Check that file exists
    2423        if not os.path.exists(filename):
    25             err_msg  = '============================================================\n'
     24            err_msg = '============================================================\n'
    2625            err_msg += '   Binary file {} not found                                 \n'.format(filename)
    2726            err_msg += '                                                            \n'
  • issm/trunk-jpl/src/m/solve/parseresultsfromdisk.py

    r25726 r25817  
    11from collections import OrderedDict
    22import struct
    3 
    43import numpy as np
    5 
    64from results import solution
    75
    86
    9 def parseresultsfromdisk(md, filename, iosplit): #{{{
     7def parseresultsfromdisk(md, filename, iosplit):  #{{{
    108    if iosplit:
    119        saveres = parseresultsfromdiskiosplit(md, filename)
     
    1614#}}}
    1715
     16
    1817def parseresultsfromdiskiosplit(md, filename):  # {{{
    1918    #Open file
    2019    try:
    2120        fid = open(filename, 'rb')
    22     except IOError as e:
     21    except IOError:
    2322        raise IOError("parseresultsfromdisk error message: could not open '{}' for binary reading.".format(filename))
    2423
     
    8988        result = ReadData(fid, md)
    9089
    91         if result == None:
     90        if result is None:
    9291            if allresults == []:
    9392                raise Exception('no results found in binary file ' + filename)
Note: See TracChangeset for help on using the changeset viewer.