Ignore:
Timestamp:
03/13/19 03:17:46 (6 years ago)
Author:
bdef
Message:

pep8 compliance of NTs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/test/NightlyRun/GetIds.py

    r23176 r23793  
    44import numpy as np
    55
     6
    67def GetIds(ids_names):
    7         """
    8         GetIds - output ids from a given array of IDs and test names
     8    """
     9     GetIds - output ids from a given array of IDs and test names
    910
    10                 the test names can be any string or sub-string present
    11                 in the test's name (first line of corresponding file)
     11              the test names can be any string or sub-string present
     12              in the test's name (first line of corresponding file)
    1213
    13                  test names are case sensitive
    14  
    15             Usage:
    16                 ids=GetIds(101)
    17                 ids=GetIds('Dakota')
    18                 ids=GetIds([101,102...])
    19                 ids=GetIds([\'Dakota\',\'Slr\'...])
    20                 ids=GetIds([[101,102...],[\'Dakota\',\'Slr\'...]])
    21         """
     14              test names are case sensitive
    2215
    23         ids = []
     16         Usage:
     17             ids = GetIds(101)
     18             ids = GetIds('Dakota')
     19             ids = GetIds([101, 102...])
     20             ids = GetIds([\'Dakota\',\'Slr\'...])
     21             ids = GetIds([[101, 102...],[\'Dakota\',\'Slr\'...]])
     22    """
    2423
    25         # 1 input, either an id or a test name
    26         if type(ids_names) == str:
    27                 ids = IdFromString(ids_names)
    28                 if len(ids) == 0:
    29                         # fail silently
    30                         return []
    31                         #raise RuntimeError('runme.py: GetIds.py: No tests with names matching "'+ids_names+'" were found. Note that name checking is case sensitive. Test names are in the first line of a given test eg: "Square" would include test101.py: "SquareShelfConstrainedStressSSA2d"')
     24    ids = []
    3225
    33         if type(ids_names) == int:
    34                 ids = [ids_names]
    35                 if len(ids) == 0:
    36                         # fail silently
    37                         return []
    38                         #raise RuntimeError('runme.py: GetIds.py: No tests with ids matching "'+ids_names+'" were found. Check that there is a test file named "test'+str(ids_names)+'.py"')
     26    # 1 input, either an id or a test name
     27    if type(ids_names) == str:
     28        ids = IdFromString(ids_names)
     29        if len(ids) == 0:
     30            # fail silently
     31            return []
     32        #raise RuntimeError('runme.py: GetIds.py: No tests with names matching "'+ids_names+'" were found. Note that name checking is case sensitive. Test names are in the first line of a given test eg: "Square" would include test101.py: "SquareShelfConstrainedStressSSA2d"')
    3933
    40         # many inputs of either ids or test names
    41         if type(ids_names) == list and len(ids_names) > 0:
    42                 # is everything a string or int?
    43                 if np.array([type(i) == int for i in ids_names]).all():
    44                         ids = ids_names
    45                 elif np.array([type(i) == str for i in ids_names]).all():
    46                         ids = np.concatenate([IdFromString(i) for i in ids_names])
    47                         if len(ids) == 0:
    48                                 raise RuntimeError('runme.py: GetIds.py: No tests with names matching "'+ids_names+'" were found. Note that name checking is case sensitive.')
     34    if type(ids_names) == int:
     35        ids = [ids_names]
     36        if len(ids) == 0:
     37            # fail silently
     38            return []
     39        #raise RuntimeError('runme.py: GetIds.py: No tests with ids matching "'+ids_names+'" were found. Check that there is a test file named "test'+str(ids_names)+'.py"')
    4940
    50         # many inputs of both ids and test names
    51         # ids_names[0] -> ids_names by id
    52         # ids_names[1] -> ids_names by test name
    53         if type(ids_names) == list and len(ids_names) == 2:
    54                 if type(ids_names[0]) == list and len(ids_names[0]) > 0 and type(ids_names[0][0]) == int:
    55                         ids = np.concatenate([ids,ids_names[0]])
    56                 if type(ids_names[1]) == list and len(ids_names[1]) > 0 and type(ids_names[1][0]) == str:
    57                         ids = np.concatenate([ids,np.concatenate([IdFromString(i) for i in ids_names[1]])])
    58                         if len(ids) == 0:
    59                                 raise RuntimeError('runme.py: GetIds.py: No tests with names matching "'+ids_names+'" were found. Note that name checking is case sensitive.')
     41    # many inputs of either ids or test names
     42    if type(ids_names) == list and len(ids_names) > 0:
     43        # is everything a string or int?
     44        if np.array([type(i) == int for i in ids_names]).all():
     45            ids = ids_names
     46        elif np.array([type(i) == str for i in ids_names]).all():
     47            ids = np.concatenate([IdFromString(i) for i in ids_names])
     48            if len(ids) == 0:
     49                raise RuntimeError('runme.py: GetIds.py: No tests with names matching "' + ids_names + '" were found. Note that name checking is case sensitive.')
    6050
    61         # no recognizable ids or id formats
    62         if np.size(ids) == 0 and not np.all(np.equal(ids_names,None)):
    63                 raise RuntimeError('runme.py: GetIds.py: include and exclude options (-i/--id; -in/--include_name; -e/--exclude; -en/--exclude_name) options must follow GetIds usage format:\n'+GetIds.__doc__)
     51    # many inputs of both ids and test names
     52    # ids_names[0] -> ids_names by id
     53    # ids_names[1] -> ids_names by test name
     54    if type(ids_names) == list and len(ids_names) == 2:
     55        if type(ids_names[0]) == list and len(ids_names[0]) > 0 and type(ids_names[0][0]) == int:
     56            ids = np.concatenate([ids, ids_names[0]])
     57        if type(ids_names[1]) == list and len(ids_names[1]) > 0 and type(ids_names[1][0]) == str:
     58            ids = np.concatenate([ids, np.concatenate([IdFromString(i) for i in ids_names[1]])])
     59            if len(ids) == 0:
     60                raise RuntimeError('runme.py: GetIds.py: No tests with names matching "' + ids_names + '" were found. Note that name checking is case sensitive.')
    6461
    65         return np.array(ids).astype(int)
     62    # no recognizable ids or id formats
     63    if np.size(ids) == 0 and not np.all(np.equal(ids_names, None)):
     64        raise RuntimeError('runme.py: GetIds.py: include and exclude options (-i/--id; -in/--include_name; -e/--exclude; -en/--exclude_name) options must follow GetIds usage format:\n' + GetIds.__doc__)
    6665
     66    return np.array(ids).astype(int)
Note: See TracChangeset for help on using the changeset viewer.