Changeset 24873
- Timestamp:
- 05/18/20 11:53:41 (5 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/array/MatlabArray.py
r24261 r24873 29 29 aout = allequal(ain, aval) 30 30 ''' 31 if type(ain) != type(aval): 32 print((allequal.__doc__)) 33 raise RuntimeError("ain and aval must be of the same type") 31 # if type(ain) != type(aval): 32 # print((allequal.__doc__)) 33 # raise RuntimeError("ain and aval must be of the same type") 34 aincopy = ain.copy() # Save copy to return in case ain[n] != aval (we modify ain in order to iterate over its values) 34 35 35 36 if type(ain) == list: … … 40 41 for i in ain: 41 42 if i != aval: 42 if type(ain) == str: 43 return '' 44 else: 45 return [] 46 return ain 43 return aincopy 44 return [] 47 45 48 46 -
issm/trunk-jpl/src/m/classes/qmu/normal_uncertain.py
r24870 r24873 142 142 @staticmethod 143 143 def prop_mean(nuv): #{{{ 144 if type(nuv) not in [list, np.ndarray]:145 return [nuv.mean]146 147 144 mean = np.zeros(np.size(nuv)) 148 145 for i in range(np.size(nuv)): … … 153 150 @staticmethod 154 151 def prop_stddev(nuv): #{{{ 155 if type(nuv) not in [list, np.ndarray]:156 return [nuv.stddev]157 152 stddev = np.zeros(np.size(nuv)) 158 153 for i in range(np.size(nuv)): … … 230 225 # collect only the variables of the appropriate class 231 226 # nuv = [struc_class(i, 'normal_uncertain', 'nuv') for i in dvar] 232 fields = fieldnames(dvar) 227 nuv = deepcopy(dvar) 228 fields = fieldnames(nuv) 233 229 for field in fields: 234 if getattr( dvar, field)[0].__class__.__name__ != 'normal_uncertain':235 delattr( dvar, field)236 if len( dvar) > 0:237 vlist_write(fidi, 'normal_uncertain', 'nuv', dvar)238 #}}} 239 230 if getattr(nuv, field)[0].__class__.__name__ != 'normal_uncertain': 231 delattr(nuv, field) 232 if len(nuv) > 0: 233 vlist_write(fidi, 'normal_uncertain', 'nuv', nuv) 234 #}}} 235 -
issm/trunk-jpl/src/m/classes/qmu/response_function.py
r24870 r24873 204 204 # collect only the responses of the appropriate class 205 205 #rf = [struc_class(vars(dresp)[i][j], 'response_function', 'rf') for i in fieldnames(dresp) for j in range(len(vars(dresp)[i]))] 206 fields = fieldnames(dresp) 206 resp = deepcopy(dresp) 207 fields = fieldnames(resp) 207 208 for field in fields: 208 if getattr( dresp, field)[0].__class__.__name__ != 'response_function':209 delattr( dresp, field)210 if len( dresp) > 0:211 rdesc = rlist_write(fidi, 'response_function', 'rf', dresp, rdesc)209 if getattr(resp, field)[0].__class__.__name__ != 'response_function': 210 delattr(resp, field) 211 if len(resp) > 0: 212 rdesc = rlist_write(fidi, 'response_function', 'rf', resp, rdesc) 212 213 return rdesc 213 214 -
issm/trunk-jpl/src/m/classes/qmu/uniform_uncertain.py
r24870 r24873 81 81 if npart != len(uuv.lower): 82 82 raise RuntimeError("uniform_uncertain constructor: for the scaled variable %s the lower field is not currently a vector of values for all the partitions described in the partition vector" % uuv.descriptor) 83 83 84 84 return [uuv] # Always return a list, so we have something akin to a MATLAB single row matrix 85 85 … … 146 146 @staticmethod 147 147 def prop_lower(uuv): #{{{ 148 if type(uuv) not in [list, np.ndarray]:149 return [uuv.lower]150 151 148 lower = np.zeros(np.size(uuv)) 152 149 for i in range(np.size(uuv)): … … 160 157 @staticmethod 161 158 def prop_upper(uuv): #{{{ 162 if type(uuv) not in [list, np.ndarray]:163 return [uuv.upper]164 165 159 upper = np.zeros(np.size(uuv)) 166 160 for i in range(np.size(uuv)): 167 161 upper[i] = uuv[i].upper 168 162 169 upper = allequal(upper, np.Inf)163 #upper = allequal(upper, np.Inf) 170 164 171 165 return upper … … 240 234 # # collect only the variables of the appropriate class 241 235 # uuv = [struc_class(i, 'uniform_uncertain', 'uuv') for i in dvar] 242 fields = fieldnames(dvar) 236 uuv = deepcopy(dvar) 237 fields = fieldnames(uuv) 243 238 for field in fields: 244 if getattr( dvar, field)[0].__class__.__name__ != 'uniform_uncertain':245 delattr( dvar, field)246 if len( dvar) > 0:247 vlist_write(fidi, 'uniform_uncertain', 'uuv', dvar)248 #}}} 239 if getattr(uuv, field)[0].__class__.__name__ != 'uniform_uncertain': 240 delattr(uuv, field) 241 if len(uuv) > 0: 242 vlist_write(fidi, 'uniform_uncertain', 'uuv', uuv) 243 #}}} -
issm/trunk-jpl/src/m/qmu/expandresponses.py
r24213 r24873 12 12 13 13 for k in fnames: 14 v = eval('responses.{}'.format(k))14 v = getattr(responses, k) 15 15 exec('dresp.{} = type(v)()'.format(k)) 16 16 for j in range(len(v)): -
issm/trunk-jpl/src/m/qmu/importancefactors.m
r24870 r24873 8 8 % Example: factors=importancefactors(md,'drag','max_vel'); 9 9 % 10 10 11 variablenamelength=length(variablename); 11 12 -
issm/trunk-jpl/src/m/qmu/importancefactors.py
r24870 r24873 10 10 11 11 Example: factors = importancefactors(md, 'drag', 'max_vel') 12 ''' 12 ''' 13 13 14 variablenamelength = len(variablename) 14 15
Note:
See TracChangeset
for help on using the changeset viewer.