Changeset 25485
- Timestamp:
- 08/27/20 05:12:12 (5 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/classes/solidearth.py
r25450 r25485 1 1 import numpy as np 2 3 2 from checkfield import checkfield 4 3 from fielddisplay import fielddisplay -
issm/trunk-jpl/src/m/consistency/ismodelselfconsistent.py
r25165 r25485 1 def ismodelselfconsistent(md): #{{{1 def ismodelselfconsistent(md): #{{{ 2 2 ''' 3 3 ISMODELSELFCONSISTENT - check that model forms a closed form solvable problem. … … 36 36 #}}} 37 37 38 def AnalysisConfiguration(solutiontype): #{{{ 38 39 def AnalysisConfiguration(solutiontype): #{{{ 39 40 ''' 40 41 ANALYSISCONFIGURATION - return type of analyses, number of analyses -
issm/trunk-jpl/src/m/qmu/helpers.py
r25455 r25485 1 1 from collections import OrderedDict 2 from copy import deepcopy3 4 2 import numpy as np 5 3 … … 12 10 class Lstruct(list): 13 11 """ 14 An empty struct that can be assigned arbitrary attributes but can also be 12 An empty struct that can be assigned arbitrary attributes but can also be 15 13 accesed as a list. Eg. x.y = 'hello', x[:] = ['w', 'o', 'r', 'l', 'd'] 16 14 17 Note that 'x' returns the array and x.__dict__ will only return attributes 15 Note that 'x' returns the array and x.__dict__ will only return attributes 18 16 other than the array 19 17 20 List-based and struct-based behaviors work normally, however they are 21 referenced as if the other does not exist; len(x) corresponds only to the 22 list component of x, len(x.a) corresponds to x.a, x.__dict__ corresponds 18 List-based and struct-based behaviors work normally, however they are 19 referenced as if the other does not exist; len(x) corresponds only to the 20 list component of x, len(x.a) corresponds to x.a, x.__dict__ corresponds 23 21 only to the non-x-list attributes 24 22 … … 65 63 class OrderedStruct(object): 66 64 """ 67 A form of dictionary-like structure that maintains the ordering in which 65 A form of dictionary-like structure that maintains the ordering in which 68 66 its fields/attributes and their corresponding values were added. 69 67 70 OrderedDict is a similar device, however this class can be used as an 68 OrderedDict is a similar device, however this class can be used as an 71 69 "ordered struct/class" giving it much more flexibility in practice. It is 72 70 also easier to work with fixed valued keys in-code. … … 91 89 x = OrderedStruct('y', 5, 'z', 6) 92 90 93 note below that the output fields as iterables are always in the same 91 note below that the output fields as iterables are always in the same 94 92 order as the inputs 95 93 … … 111 109 ('y', 6) 112 110 113 Note: to access internal fields use dir(x) (input fields will be included, 111 Note: to access internal fields use dir(x) (input fields will be included, 114 112 but are not technically internals) 115 113 """ … … 117 115 def __init__(self, *args): 118 116 """ 119 Provided either nothing or a series of strings, construct a structure 120 that will, when accessed as a list, return its fields in the same order 117 Provided either nothing or a series of strings, construct a structure 118 that will, when accessed as a list, return its fields in the same order 121 119 in which they were provided 122 120 """ … … 233 231 def isempty(x): 234 232 """ 235 returns true if object is +/-infinity, NaN, None, '', has length 0, or is 236 an array/matrix composed only of such components (includes mixtures of 233 returns true if object is +/-infinity, NaN, None, '', has length 0, or is 234 an array/matrix composed only of such components (includes mixtures of 237 235 "empty" types) 238 236 """ … … 272 270 """ 273 271 returns a list of fields of x 274 ignore_internals ignores all fieldnames starting with '_' and is True by 272 ignore_internals ignores all fieldnames starting with '_' and is True by 275 273 default 276 274 """ … … 286 284 """ 287 285 is y is a field of x? 288 ignore_internals ignores all fieldnames starting with '_' and is True by 286 ignore_internals ignores all fieldnames starting with '_' and is True by 289 287 default 290 288 """ … … 338 336 339 337 Note: will include any newlines or tabs that occur in that line, 340 use str(findline(f, s)).strip() to remove these, str() in case result is 338 use str(findline(f, s)).strip() to remove these, str() in case result is 341 339 None 342 340 """ … … 354 352 filler is 0.0 by default 355 353 356 as_numpy_ndarray will return the result as a numpy.ndarray and is False by 354 as_numpy_ndarray will return the result as a numpy.ndarray and is False by 357 355 default 358 356 359 Note: the filler must be either None/np.nan/float('NaN'), float/double, or 357 Note: the filler must be either None/np.nan/float('NaN'), float/double, or 360 358 int. other numpy and float values such as +/- np.inf will also work 361 359
Note:
See TracChangeset
for help on using the changeset viewer.