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

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

CHG: merged trunk-jpl into branch through revision 12945

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