Changeset 27035 for issm/trunk/src/m/miscellaneous/MatlabFuncs.py
- Timestamp:
- 06/01/22 05:01:48 (3 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
- Property svn:mergeinfo changed
/issm/trunk-jpl merged: 26745-26955,26957-27031
- Property svn:mergeinfo changed
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/m/miscellaneous/MatlabFuncs.py
r26744 r27035 2 2 functions of the same, respective name. 3 3 4 Where possible, users are encouraged to use native and/or the most efficient 5 methods in Python, but we provide these functions as a way to make translations 4 Where possible, users are encouraged to use native and/or the most efficient 5 methods in Python, but we provide these functions as a way to make translations 6 6 from the MATLAB to the Python ISSM API more seamless. 7 7 """ … … 82 82 83 83 def cosdsingle(x): # {{{ 84 """function cosdsingle - Helper function for cosd to reduce repetition of 84 """function cosdsingle - Helper function for cosd to reduce repetition of 85 85 logic 86 86 … … 162 162 NOTE: 163 163 - Only the following functionality is currently implemented: 164 - C = intersect(A,B) returns the data common to both A and B, with no 164 - C = intersect(A,B) returns the data common to both A and B, with no 165 165 repetitions. C is in sorted order. 166 166 … … 175 175 176 176 NOTE: 177 - Takes a type as its second argument (in contrast to the MATLAB function 177 - Takes a type as its second argument (in contrast to the MATLAB function 178 178 that it replicates, which takes a string representing the name of a type) 179 179 """ … … 204 204 def ismember(a, s): # {{{ 205 205 import numpy as np 206 207 206 if not isinstance(s, (tuple, list, dict, np.ndarray)): 208 207 s = [s] … … 215 214 else: 216 215 if not isinstance(s, np.ndarray): 217 b = np.empty_like(a) 216 b = np.empty_like(a).flat 218 217 for i, item in enumerate(a.flat): 219 b .flat[i] = item in s218 b[i] = item in s 220 219 else: 221 220 b = np.in1d(a.flat, s.flat).reshape(a.shape) 222 223 221 return b 224 222 # }}} … … 272 270 def oshostname(): # {{{ 273 271 import socket 274 275 return socket.gethostname() 272 hostname = socket.gethostname() 273 274 return hostname.lower() 276 275 # }}} 277 276 … … 298 297 299 298 def sindsingle(x): # {{{ 300 """function sindsingle - Helper function for sind to reduce repetition of 299 """function sindsingle - Helper function for sind to reduce repetition of 301 300 logic 302 301
Note:
See TracChangeset
for help on using the changeset viewer.