Changeset 999
- Timestamp:
- 13/06/08 11:44:48 (4 years ago)
- Location:
- trunk/bindings/python
- Files:
-
- 2 edited
-
nxs.py (modified) (10 diffs)
-
nxstest.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bindings/python/nxs.py
r980 r999 259 259 status = self.lib.nxiopen_(filename,mode,_ref(self.handle)) 260 260 if status == ERROR: 261 op = 'open' if mode in [ACC_READ, ACC_RDWR] else 'create' 261 if mode in [ACC_READ, ACC_RDWR]: 262 op = 'open' 263 else: 264 op = 'create' 262 265 raise RuntimeError, "Could not %s %s"%(op,filename) 263 266 self.isopen = True … … 282 285 """ 283 286 if self.isopen: return 284 mode = ACC_READ if self.mode==ACC_READ else ACC_RDWR 287 if self.mode==ACC_READ: 288 mode = ACC_READ 289 else: 290 mode = ACC_RDWR 285 291 status = self.lib.nxiopen_(self.filename,mode,_ref(self.handle)) 286 292 if status == ERROR: … … 367 373 raise ValueError, "Could not open %s in %s"%(path,self._loc()) 368 374 n,path,nxclass = self.getgroupinfo() 369 self.path = path.split('/') if path != 'root' else [] 375 if path != 'root': 376 self.path = path.split('/') 377 else: 378 self.path = [] 370 379 371 380 … … 386 395 raise ValueError, "Could not open %s in %s"%(path,self.filename) 387 396 n,path,nxclass = self.getgroupinfo() 388 self.path = path.split('/') if path != 'root' else [] 397 if path != 'root': 398 self.path = path.split('/') 399 else: 400 self.path = [] 389 401 390 402 … … 505 517 n,path,_ = self.getgroupinfo() 506 518 #print "path",path 507 path = "/"+path if not path == "root" else "/" 519 if not path == "root": 520 path = "/"+path 521 else: 522 path = "/" 508 523 self.initgroupdir() 509 524 L = [] … … 1013 1028 target = self.getattr(name,length,dtype) 1014 1029 #print "target %s, path %s"%(target,pathstr) 1015 return target if target != pathstr else None 1030 if target != pathstr: 1031 return target 1032 else: 1033 return None 1016 1034 return None 1017 1035 … … 1066 1084 status = self.lib.nxiisexternalgroup_(self.handle,name,nxclass, 1067 1085 url,maxnamelen) 1068 return None if status == ERROR else url.value 1086 if status == ERROR: 1087 return None 1088 else: 1089 url.value 1069 1090 1070 1091 … … 1076 1097 This is an extension to the NeXus API. 1077 1098 """ 1078 pathstr = "/".join(self.path) if not self.path == [] else "root" 1099 if not self.path == []: 1100 pathstr = "/".join(self.path) 1101 else: 1102 pathstr = "root" 1079 1103 return "%s(%s)"%(self.filename,pathstr) 1080 1104 … … 1105 1129 size = data.nbytes 1106 1130 return datafn,pdata,size 1131 1132 def _nxany(self,iter): 1133 """ 1134 replace python 2.5 any() 1135 """ 1136 for e in iter: 1137 if e: 1138 return 1 1139 return 0 1107 1140 1108 1141 def _pinput(self, data, dtype, shape): … … 1127 1160 input_shape = numpy.array([i for i in data.shape if i != 1]) 1128 1161 target_shape = numpy.array([i for i in shape if i != 1]) 1129 if len(input_shape) != len(target_shape) or any(input_shape != target_shape): 1162 print input_shape 1163 print target_shape 1164 # if len(input_shape) != len(target_shape) or any(input_shape != target_shape): 1165 if len(input_shape) != len(target_shape) or self._nxany(input_shape != target_shape): 1130 1166 raise ValueError,\ 1131 1167 "Shape mismatch %s!=%s: %s"%(data.shape,shape,self.filename) -
trunk/bindings/python/nxstest.py
r976 r999 353 353 def test(): 354 354 tests = 0 355 quiet = True if '-q' in sys.argv else False 356 external = True if '-x' in sys.argv else False 355 if '-q' in sys.argv: 356 quiet = True 357 else: 358 quiet = False 359 if '-x' in sys.argv: 360 external = True 361 362 else: 363 external = False 357 364 if 'hdf4' in sys.argv: 358 365 test_mode('w4',quiet,external)
Note: See TracChangeset
for help on using the changeset viewer.
