Changeset 25346


Ignore:
Timestamp:
08/05/20 00:25:08 (5 years ago)
Author:
jdquinn
Message:

CHG: Default argument cannot follow *args; shlex not behaving as expected

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

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/coordsystems/epsg2proj.py

    r25189 r25346  
     1import shlex
    12import subprocess
    23
    34
    45def epsg2proj(epsg): #{{{
    5     '''
     6    """
    67    FUNCTION EPSG2PROJ - uses gdalsrsinfo to provide PROJ.4 compatible string
    78    from EPSG code
     
    1819        - In case of Python 2, except socket.timeout: https://docs.python.org/3/library/socket.html?highlight=socket%20timeout#socket.timeout
    1920        - In case of Python 3, except TimeoutExpired: https://docs.python.org/3/library/subprocess.html#subprocess.SubprocessError
    20     '''
     21    """
    2122
    2223    #First, get GDAL version
  • issm/trunk-jpl/src/m/io/loadmodel.py

    r25092 r25346  
    3333    #       try:
    3434    #recover model on file and name it md
    35     struc = loadvars(path, OL=onlylast)
     35    struc = loadvars(path, onlylast=onlylast)
    3636    name = [key for key in list(struc.keys())]
    3737    if len(name) > 1:
  • issm/trunk-jpl/src/m/io/loadvars.py

    r25125 r25346  
    1515
    1616
    17 def loadvars(*args, OL):
    18     '''
     17def loadvars(*args, **kwargs):
     18    """
    1919    LOADVARS - function to load variables from a file.
    2020
     
    3030        nvdict = loadvars('shelve.dat', {'a':None, 'b':None})
    3131        nvdict = loadvars('shelve.dat')
    32     '''
     32    """
    3333
    3434    filename = ''
     
    5555    else:
    5656        raise TypeError("Unrecognized input arguments.")
     57
     58    onlylast = False
     59
     60    for key, value in kwargs.items():
     61        if key == 'onlylast':
     62            onlylast = value
    5763
    5864    if whichdb(filename):   #We used python pickle for the save
     
    110116                            nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [OrderedDict() for i in range(max(1, len(curclass.groups)))]
    111117                        else:
    112                             if OL:   #we load only the last result to save on time and memory
     118                            if onlylast:   #we load only the last result to save on time and memory
    113119                                nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(__import__(listtype), listtype)()]
    114120                                Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]]
     
    126132                        if AllHaveTime:
    127133                            #Time dimension is in all the variables so we take that as stepnumber for the results
    128                             if OL:   #we load only the last result to save on time and memory
     134                            if onlylast:   #we load only the last result to save on time and memory
    129135                                nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]] = [getattr(__import__(listtype), listtype)()]
    130136                                Tree = nvdict['md'].__dict__[classtree[mod][0]].__dict__[classtree[mod][1]]
     
    166172                        NewFormat = 'Time' in NCFile.dimensions
    167173                        if type(Tree) == list and NewFormat:
    168                             if OL:
     174                            if onlylast:
    169175                                if vardim == 1:
    170176                                    Tree[0].__dict__[str(var)] = varval[-1].data
Note: See TracChangeset for help on using the changeset viewer.