Changeset 2676 in lmdz_wrf for trunk/tools/generic_tools.py
- Timestamp:
- Jul 13, 2019, 9:12:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r2665 r2676 214 214 # same_shape: Function to check if two matrices have the same shape 215 215 # search_sec_list: Function to provide the values and indices on a list which matches a section of a string 216 # searchInlist: Function to search a value wihitn a list 217 # searchInlist_Strsec: Function to search a value within a section of the Strings in a list 216 218 # shrinkarray_dim: Function to shrink a given array with a vector of True/False along a given dimension 217 219 # significant_decomposition: Function to decompose a given number by its signifcant potencies … … 248 250 listname = list 249 251 nameFind = value to find 250 >>> sear Inlist(['1', '2', '3', '5'], '5')252 >>> searchInlist(['1', '2', '3', '5'], '5') 251 253 True 252 254 """ 253 255 for x in listname: 254 256 if x == nameFind: 257 return True 258 return False 259 260 def searchInlist_Strsec(listname, isec, esec, nameFind): 261 """ Function to search a value within a section of the Strings in a list 262 listname = list 263 isec= initial position of the section 264 esec= ending position of the section (+1 will be added) 265 nameFind = value to find 266 >>> searchInlist_Strsec(['101', '102', '103', '104'], 1, 2, '01') 267 True 268 """ 269 fname = 'searchInlist_Strsec' 270 271 if len(nameFind) != esec-isec+1: 272 print errmsg 273 print ' ' + fname + ": wrong name to find: '" + nameFind + "' and section ",\ 274 isec, ', ', esec, ' !!' 275 print " length of the name to find: '" + nameFind + "' length=", \ 276 len(nameFind), ' does not coincide with size of section', esec-isec+1, '!!' 277 quit(-1) 278 279 for x in listname: 280 if x[isec:esec+1] == nameFind: 255 281 return True 256 282 return False
Note: See TracChangeset
for help on using the changeset viewer.