Changeset 24255


Ignore:
Timestamp:
10/18/19 06:22:34 (6 years ago)
Author:
bdef
Message:

BUG: syntax fix in array indexes

Location:
issm/trunk-jpl
Files:
1 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/boundaryconditions/SetIceShelfBC.py

    r24213 r24255  
    5252        raise NameError('mesh type not supported yet')
    5353    if any(md.mask.ice_levelset <= 0):
    54         values = md.mask.ice_levelset[md.mesh.segments[:, 0: - 1] - 1]
     54        values = md.mask.ice_levelset[md.mesh.segments[:, 0:-1] - 1]
    5555        segmentsfront = 1 - values
    5656        np.sum(segmentsfront, axis=1) != numbernodesfront
    5757        segments = np.nonzero(np.sum(segmentsfront, axis=1) != numbernodesfront)[0]
    5858    #Find all nodes for these segments and spc them
    59         pos = md.mesh.segments[segments, 0: - 1] - 1
     59        pos = md.mesh.segments[segments, 0:-1] - 1
    6060    else:
    6161        pos = np.nonzero(md.mesh.vertexonboundary)[0]
  • issm/trunk-jpl/src/m/boundaryconditions/SetMarineIceSheetBC.py

    r24213 r24255  
    6464        segments = np.nonzero(np.sum(segmentsfront, axis=1) != numbernodesfront)[0]
    6565    #Find all nodes for these segments and spc them
    66         pos = md.mesh.segments[segments, 0: - 1] - 1
     66        pos = md.mesh.segments[segments, 0:-1] - 1
    6767    else:
    6868        pos = np.nonzero(md.mesh.vertexonboundary)[0]
  • issm/trunk-jpl/src/m/classes/esa.py

    r24213 r24255  
    3232        string = "%s\n%s" % (string, fielddisplay(self, 'love_h', 'load Love number for radial displacement'))
    3333        string = "%s\n%s" % (string, fielddisplay(self, 'love_l', 'load Love number for horizontal displaements'))
    34         string = "%s\n%s" % (string, fielddisplay(self, 'hemisphere', 'North - south, East - west components of 2 - D horiz displacement vector: - 1 south, 1 north'))
     34        string = "%s\n%s" % (string, fielddisplay(self, 'hemisphere', 'North-south, East-west components of 2-D horiz displacement vector:-1 south, 1 north'))
    3535        string = "%s\n%s" % (string, fielddisplay(self, 'degacc', 'accuracy (default .01 deg) for numerical discretization of the Green''s functions'))
    3636        string = "%s\n%s" % (string, fielddisplay(self, 'transitions', 'indices into parts of the mesh that will be icecaps'))
  • issm/trunk-jpl/src/m/classes/thermal.py

    r24213 r24255  
    107107            md = checkfield(md, 'fieldname', 'thermal.watercolumn_upperlimit', '>=', 0)
    108108
    109             TEMP = md.thermal.spctemperature[: - 1].flatten(- 1)
     109            TEMP = md.thermal.spctemperature[:-1].flatten(- 1)
    110110            pos = np.where(~np.isnan(TEMP))
    111111            try:
  • issm/trunk-jpl/src/m/consistency/checkfield.py

    r24213 r24255  
    167167            minval = np.nanmin(field)
    168168            if options.getfieldvalue('timeseries', 0):
    169                 minval = np.nanmin(field[: - 1])
     169                minval = np.nanmin(field[:-1])
    170170            elif options.getfieldvalue('singletimeseries', 0):
    171171                if np.size(field) == 1:  #some singletimeseries are just one value
     
    187187            minval = np.nanmin(field)
    188188            if options.getfieldvalue('timeseries', 0):
    189                 minval = np.nanmin(field[: - 1])
     189                minval = np.nanmin(field[:-1])
    190190            elif options.getfieldvalue('singletimeseries', 0):
    191191                if np.size(field) == 1:  #some singletimeseries are just one value
     
    208208            maxval = np.nanmax(field)
    209209            if options.getfieldvalue('timeseries', 0):
    210                 maxval = np.nanmax(field[: - 1])
     210                maxval = np.nanmax(field[:-1])
    211211            elif options.getfieldvalue('singletimeseries', 0):
    212212                if np.size(field) == 1:  #some singletimeseries are just one value
     
    230230            maxval = np.nanmax(field)
    231231            if options.getfieldvalue('timeseries', 0):
    232                 maxval = np.nanmax(field[: - 1])
     232                maxval = np.nanmax(field[:-1])
    233233            elif options.getfieldvalue('singletimeseries', 0):
    234234                if np.size(field) == 1:  #some singletimeseries are just one value
  • issm/trunk-jpl/src/m/contrib/defleurian/paraview/exportVTK.py

    r24241 r24255  
    242242                                fid.write('{:f} {:f} {:f}\n'.format(0, 0, 0))
    243243                    else:
    244                         if ((np.size(spe_res_struct.__dict__[field])) == every_nodes):
     244                        if (np.size(spe_res_struct.__dict__[field]) == 1):
     245                            #skipping integers
     246                            continue
     247                        elif ((np.size(spe_res_struct.__dict__[field])) == every_nodes):
    245248                            fid.write('SCALARS {} float 1 \n'.format(field))
    246249                            fid.write('LOOKUP_TABLE default\n')
     
    248251                                outval = cleanOutliers(np.squeeze(spe_res_struct.__dict__[field][enveloppe_index[node]]))
    249252                                fid.write('{:f}\n'.format(outval))
    250                         elif ((np.size(spe_res_struct.__dict__[field])) == every_cells):
     253                        elif (np.shape(spe_res_struct.__dict__[field])[0] == np.size(spe_res_struct.__dict__[field]) == every_cells):
    251254                            saved_cells[field] = np.squeeze(spe_res_struct.__dict__[field])
     255                        else:
     256                            print("format for field {}.{} is not suported, field is skipped".format(sol, field))
     257                            continue
    252258    # }}}
    253259    # loop on arguments, if something other than result is asked, do it now {{{
     
    256262            othernames = (dict.keys(other_struct.__dict__))
    257263            for field in othernames:
    258                 if (np.size(other_struct.__dict__[field]) == every_nodes):
     264                if (np.size(other_struct.__dict__[field]) == 1):
     265                    #skipping integers
     266                    continue
     267                elif (np.size(other_struct.__dict__[field]) == every_nodes):
    259268                    fid.write('SCALARS {} float 1 \n'.format(field))
    260269                    fid.write('LOOKUP_TABLE default\n')
     
    262271                        outval = cleanOutliers(other_struct.__dict__[field][enveloppe_index[node]])
    263272                        fid.write('{:f}\n'.format(outval))
    264                 elif (np.size(other_struct.__dict__[field]) == every_cells):
     273                elif (np.shape(other_struct.__dict__[field])[0] == np.size(other_struct.__dict__[field]) == every_cells):
    265274                    saved_cells[field] = other_struct.__dict__[field]
     275                else:
     276                    print("format for field {}.{} is not suported, field is skipped".format(other, field))
     277                    continue
    266278    # }}}
    267279    # Now writting cell variables {{{
  • issm/trunk-jpl/src/m/extrusion/project3d.py

    r24213 r24255  
    5353                projected_vector = (paddingvalue * np.ones((md.mesh.numberofvertices + 1))).astype(vector2d.dtype)
    5454                projected_vector[-1] = vector2d[-1]
    55                 vector2d = vector2d[: - 1]
     55                vector2d = vector2d[:-1]
    5656            else:
    5757                raise TypeError("vector length not supported")
     
    6868                projected_vector = (paddingvalue * np.ones((md.mesh.numberofvertices + 1, np.size(vector2d, axis=1)))).astype(vector2d.dtype)
    6969                projected_vector[-1, :] = vector2d[-1, :]
    70                 vector2d = vector2d[: - 1, :]
     70                vector2d = vector2d[:-1, :]
    7171            else:
    7272                raise TypeError("vector length not supported")
     
    8686                projected_vector = (paddingvalue * np.ones((md.mesh.numberofelements + 1))).astype(vector2d.dtype)
    8787                projected_vector[-1] = vector2d[-1]
    88                 vector2d = vector2d[: - 1]
     88                vector2d = vector2d[:-1]
    8989            else:
    9090                raise TypeError("vector length not supported")
     
    101101                projected_vector = (paddingvalue * np.ones((md.mesh.numberofelements + 1, np.size(vector2d, axis=1)))).astype(vector2d.dtype)
    102102                projected_vector[-1, :] = vector2d[-1, :]
    103                 vector2d = vector2d[: - 1, :]
     103                vector2d = vector2d[:-1, :]
    104104            else:
    105105                raise TypeError("vector length not supported")
  • issm/trunk-jpl/src/m/miscellaneous/fielddisplay.py

    r24213 r24255  
    106106        string = "%s%dx1%s" % (sbeg, len(field), send)
    107107    else:
    108         string = string[: - 1] + send
     108        string = string[:-1] + send
    109109
    110110    #call displayunit
  • issm/trunk-jpl/src/m/plot/processdata.py

    r24213 r24255  
    120120        print('multiple-column spc field; specify column to plot using option "spccol"')
    121121        print(('column ', spccol, ' plotted for time: ', procdata[-1, spccol]))
    122         procdata = procdata[0: - 1, spccol]
     122        procdata = procdata[0:-1, spccol]
    123123
    124124    #mask?
  • issm/trunk-jpl/src/m/solve/WriteData.py

    r24213 r24255  
    4444        scale = options.getfieldvalue('scale')
    4545        if np.size(data) > 1 and np.ndim(data) > 1 and np.size(data, 0) == timeserieslength:
    46             data[0: - 1, :] = scale * data[0: - 1, :]
     46            data[0:-1, :] = scale * data[0:-1, :]
    4747        else:
    4848            data = scale * data
  • issm/trunk-jpl/src/m/solve/parseresultsfromdisk.py

    r24240 r24255  
    149149    try:
    150150        length = struct.unpack('i', fid.read(struct.calcsize('i')))[0]
    151         fieldname = struct.unpack('{}s'.format(length), fid.read(length))[0][: - 1]
     151        fieldname = struct.unpack('{}s'.format(length), fid.read(length))[0][:-1]
    152152        fieldname = fieldname.decode()  #strings are binaries when stored so need to be converted back
    153153        time = struct.unpack('d', fid.read(struct.calcsize('d')))[0]
     
    159159
    160160        elif datatype == 2:
    161             field = struct.unpack('{}s'.format(M), fid.read(M))[0][: - 1]
     161            field = struct.unpack('{}s'.format(M), fid.read(M))[0][:-1]
    162162            field = field.decode()
    163163
     
    282282    try:
    283283        length = struct.unpack('i', fid.read(struct.calcsize('i')))[0]
    284         fieldname = struct.unpack('{}s'.format(length), fid.read(length))[0][: - 1]
     284        fieldname = struct.unpack('{}s'.format(length), fid.read(length))[0][:-1]
    285285        time = struct.unpack('d', fid.read(struct.calcsize('d')))[0]
    286286        step = struct.unpack('i', fid.read(struct.calcsize('i')))[0]
  • issm/trunk-jpl/test/NightlyRun/IdToName.py

    r24226 r24255  
    1313
    1414    string = '#Test Name:'
    15     name = file_text[len(string) + 1: - 1]
     15    name = file_text[len(string) + 1:-1]
    1616    return name
  • issm/trunk-jpl/test/NightlyRun/test244.py

    r24214 r24255  
    7575md.qmu.variables.surface_mass_balanceC = normal_uncertain.normal_uncertain('scaled_SmbC', 1, 0.5)
    7676Tmin = 273.
    77 telms = np.atleast_2d(np.min(md.smb.Ta[0: - 1, :], 1))
     77telms = np.atleast_2d(np.min(md.smb.Ta[0:-1, :], 1))
    7878mint_on_partition = telms.flatten()
    7979for pa in range(np.size(mint_on_partition)):
Note: See TracChangeset for help on using the changeset viewer.