source: issm/branches/trunk-jpl-damage/src/m/model/MatlabFuncs.py@ 12878

Last change on this file since 12878 was 12878, checked in by cborstad, 13 years ago

merged trunk-jpl into trunk-jpl-damage through revision 12877

File size: 675 bytes
RevLine 
[12842]1def strcmp(s1,s2):
[12675]2
[12842]3 if s1 == s2:
[12675]4 return True
5 else:
6 return False
7
[12842]8def strncmp(s1,s2,n):
[12675]9
[12842]10 if s1[0:n] == s2[0:n]:
[12675]11 return True
12 else:
13 return False
14
[12842]15def strcmpi(s1,s2):
[12675]16
[12842]17 if s1.lower() == s2.lower():
[12675]18 return True
19 else:
20 return False
21
[12842]22def strncmpi(s1,s2,n):
[12675]23
[12842]24 if s1.lower()[0:n] == s2.lower()[0:n]:
[12675]25 return True
26 else:
27 return False
28
[12842]29def ismember(a,s):
30 import numpy
31
32 if not isinstance(s,(tuple,list,dict,numpy.ndarray)):
33 s=[s]
34
35 if not isinstance(a,(tuple,list,dict,numpy.ndarray)):
36 a=[a]
37
38 if not isinstance(a,numpy.ndarray):
39 b=[item in s for item in a]
40
41 else:
42 b=numpy.empty_like(a)
43 for i,item in enumerate(a.flat):
44 b.flat[i]=item in s
45
46 return b
47
Note: See TracBrowser for help on using the repository browser.