Changeset 1571 for trunk/bindings/python/nxs
- Timestamp:
- 21/10/10 16:35:38 (19 months ago)
- Location:
- trunk/bindings/python/nxs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bindings/python/nxs/napi.py
r1474 r1571 256 256 except: 257 257 raise OSError, \ 258 "NeXus library %s could not be loaded: %s"%(file,sys.exc_info() [0])258 "NeXus library %s could not be loaded: %s"%(file,sys.exc_info()) 259 259 raise OSError, "Set NEXUSLIB or move NeXus to one of: %s"%(", ".join(files)) 260 260 … … 505 505 #print "target and current differ at",name 506 506 up = self._path[i:] 507 down = target[i:]507 down = target[i:] 508 508 break 509 509 else: … … 725 725 n,_,_ = self.getgroupinfo() 726 726 L = [] 727 for iin range(n):727 for dummy in range(n): 728 728 name,nxclass = self.getnextentry() 729 729 if nxclass not in H4SKIP: … … 925 925 # TODO: consider accepting preallocated data so we don't thrash memory 926 926 shape,dtype = self.getinfo() 927 d ata,pdata,size,datafn = self._poutput(dtype,shape)927 dummy_data,pdata,dummy_size,datafn = self._poutput(dtype,shape) 928 928 status = nxlib.nxigetdata_(self.handle,pdata) 929 929 if status == ERROR: … … 946 946 """ 947 947 # TODO: consider accepting preallocated data so we don't thrash memory 948 shape,dtype = self.getrawinfo()949 d ata,pdata,size,datafn = self._poutput(dtype,slab_shape)948 dummy_shape,dtype = self.getrawinfo() 949 dummy_data,pdata,dummy_size,datafn = self._poutput(dtype,slab_shape) 950 950 slab_offset = numpy.array(slab_offset,'i') 951 951 slab_shape = numpy.array(slab_shape,'i') … … 988 988 Corresponds to NXputslab(handle,data,offset,shape) 989 989 """ 990 shape,dtype = self.getrawinfo()990 dummy_shape,dtype = self.getrawinfo() 991 991 data,pdata = self._pinput(data,dtype,slab_shape) 992 992 slab_offset = numpy.array(slab_offset,'i') … … 1080 1080 """ 1081 1081 if dtype is 'char': length += 1 # HDF4 needs zero-terminator 1082 d ata,pdata,size,datafn = self._poutput(str(dtype),[length])1082 dummy_data,pdata,size,datafn = self._poutput(str(dtype),[length]) 1083 1083 storage = c_int(_nxtype_code[str(dtype)]) 1084 1084 #print "getattr",self._loc(),name,length,size,dtype … … 1166 1166 self.initattrdir() 1167 1167 n = self.getattrinfo() 1168 for iin range(n):1168 for dummy in range(n): 1169 1169 name,length,dtype = self.getnextattr() 1170 1170 value = self.getattr(name,length,dtype) … … 1277 1277 n = self.getattrinfo() 1278 1278 self.initattrdir() 1279 for iin range(n):1279 for dummy in range(n): 1280 1280 name,length,dtype = self.getnextattr() 1281 1281 if name == "target": … … 1365 1365 on the data type and shape of the data group. 1366 1366 """ 1367 if isinstance(shape, int): 1368 shape = [shape] 1367 1369 if len(shape) == 1 and dtype == 'char': 1368 1370 # string - use ctypes allocator … … 1395 1397 as you need pdata to keep the memory from being released to the heap. 1396 1398 """ 1399 if isinstance(shape, int): 1400 shape = [shape] 1397 1401 if dtype == "char": 1398 1402 data = numpy.asarray(data, dtype='S%d'%(shape[-1])) … … 1409 1413 or (input_shape != target_shape).any(): 1410 1414 raise ValueError,\ 1411 "Shape mismatch %s!=%s: %s"%(data _shape,shape,self._loc())1415 "Shape mismatch %s!=%s: %s"%(data.shape,shape,self._loc()) 1412 1416 # Check data type 1413 1417 if str(data.dtype) != dtype: -
trunk/bindings/python/nxs/tree.py
r1547 r1571 130 130 131 131 132 from copy import copy , deepcopy133 134 import os,numpy as np132 from copy import copy 133 134 import numpy as np 135 135 import napi 136 136 import unit … … 220 220 return None 221 221 222 def _readattrs(self):223 """224 Return the attributes for the currently open group/data or for225 the file if no group or data object is open.226 """227 attrs = dict()228 for i in range(self.getattrinfo()):229 name,length,nxtype = self.getnextattr()230 value = self.getattr(name, length, nxtype)231 pair = self.NXattr(value,nxtype)232 attrs[name] = pair233 #print "read attr",name,pair.nxdata, pair.nxtype234 return attrs235 236 222 def _readdata(self, name): 237 223 """ … … 242 228 # Instead record the location, type and size 243 229 self.opendata(name) 244 attrs = self. _readattrs()230 attrs = self.getattrs() 245 231 if 'target' in attrs and attrs['target'].nxdata != self.path: 246 232 # This is a linked dataset; don't try to load it. … … 268 254 def _readchildren(self,n): 269 255 children = {} 270 for iin range(n):256 for dummy in range(n): 271 257 name,nxclass = self.getnextentry() 272 258 #print "name,class,path",name,nxclass,self.path … … 294 280 # in and skip those of different classes? 295 281 n,name,nxclass = self.getgroupinfo() 296 attrs = self. _readattrs()282 attrs = self.getattrs() 297 283 if 'target' in attrs and attrs['target'].nxdata != self.path: 298 284 # This is a linked group; don't try to load it. … … 654 640 655 641 def _str_attrs(self,indent=0): 656 result = ""657 642 attrs = self.nxattrs 658 643 names = attrs.keys() … … 1241 1226 1242 1227 def nxdata_set(self, value): 1243 nxtype, nxdims = _gettype(value)1228 dummy_nxtype, nxdims = _gettype(value) 1244 1229 if nxdims == self.nxdims: 1245 1230 self._value = _settype(value, self.nxtype) … … 1309 1294 else: 1310 1295 slab = [slice(None), slice(None)] 1311 for d imin signal.nxdims[2:]:1296 for dummy in signal.nxdims[2:]: 1312 1297 slab.append(0) 1313 1298 data = signal[slab].nxreshape(signal.nxdims[:2]).nxdata … … 1661 1646 Find all child nodes that have a particular class. 1662 1647 """ 1663 return [E for name,E in self.nxentries.items() if E.nxclass==nxclass]1648 return [E for dummy_name,E in self.nxentries.items() if E.nxclass==nxclass] 1664 1649 1665 1650 def nxsignals(self): … … 2626 2611 def imshow_irregular(x,y,z): 2627 2612 import pylab 2628 from matplotlib.ticker import FormatStrFormatter2613 #from matplotlib.ticker import FormatStrFormatter 2629 2614 ax = pylab.gca() 2630 2615 im = pylab.mpl.image.NonUniformImage(ax, extent=(x[0],x[-1],y[0],y[-1]), origin=None)
Note: See TracChangeset
for help on using the changeset viewer.
