Changeset 1658 for trunk/bindings


Ignore:
Timestamp:
21/10/11 19:55:03 (7 months ago)
Author:
Paul Kienzle
Message:

python: support 64-bit dims. Refs #285

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bindings/python/nxs/napi.py

    r1572 r1658  
    738738 
    739739    # ==== Data ==== 
    740     nxlib.nxigetrawinfo_.restype = c_int 
    741     nxlib.nxigetrawinfo_.argtypes = [c_void_p, c_int_p, c_void_p, c_int_p] 
     740    nxlib.nxigetrawinfo64_.restype = c_int 
     741    nxlib.nxigetrawinfo64_.argtypes = [c_void_p, c_int_p, c_void_p, c_int_p] 
    742742    def getrawinfo(self): 
    743743        """ 
     
    760760        """ 
    761761        rank = c_int(0) 
    762         shape = numpy.zeros(MAXRANK, 'i') 
     762        shape = numpy.zeros(MAXRANK, 'int64') 
    763763        storage = c_int(0) 
    764         status = nxlib.nxigetrawinfo_(self.handle, _ref(rank), shape.ctypes.data, 
    765                                      _ref(storage)) 
     764        status = nxlib.nxigetrawinfo64_(self.handle, _ref(rank),  
     765                                        shape.ctypes.data, _ref(storage)) 
    766766        if status == ERROR: 
    767767            raise NeXusError, "Could not get data info: %s"%(self._loc()) 
     
    771771        return shape,dtype 
    772772 
    773     nxlib.nxigetinfo_.restype = c_int 
    774     nxlib.nxigetinfo_.argtypes = [c_void_p, c_int_p, c_void_p, c_int_p] 
     773    nxlib.nxigetinfo64_.restype = c_int 
     774    nxlib.nxigetinfo64_.argtypes = [c_void_p, c_int_p, c_void_p, c_int_p] 
    775775    def getinfo(self): 
    776776        """ 
     
    796796        """ 
    797797        rank = c_int(0) 
    798         shape = numpy.zeros(MAXRANK, 'i') 
     798        shape = numpy.zeros(MAXRANK, 'int64') 
    799799        storage = c_int(0) 
    800         status = nxlib.nxigetinfo_(self.handle, _ref(rank), shape.ctypes.data, 
     800        status = nxlib.nxigetinfo64_(self.handle, _ref(rank),  
     801                                     shape.ctypes.data, 
    801802                                     _ref(storage)) 
    802803        if status == ERROR: 
     
    846847        self._indata = False 
    847848 
    848     nxlib.nximakedata_.restype = c_int 
    849     nxlib.nximakedata_.argtypes  = [c_void_p, c_char_p, c_int, c_int, c_int_p] 
     849    nxlib.nximakedata64_.restype = c_int 
     850    nxlib.nximakedata64_.argtypes  = [c_void_p, c_char_p, c_int, c_int, c_int64_p] 
    850851    def makedata(self, name, dtype=None, shape=None): 
    851852        """ 
     
    866867        #print "makedata",self._loc(),name,shape,dtype 
    867868        storage = _nxtype_code[str(dtype)] 
    868         shape = numpy.array(shape,'i') 
    869         status = nxlib.nximakedata_(self.handle,name,storage,len(shape), 
    870                                   shape.ctypes.data_as(c_int_p)) 
     869        shape = numpy.asarray(shape,'int64') 
     870        status = nxlib.nximakedata64_(self.handle,name,storage,len(shape), 
     871                                      shape.ctypes.data_as(c_int64_p)) 
    871872        if status == ERROR: 
    872873            raise ValueError, "Could not create data %s: %s"%(name,self._loc()) 
    873874 
    874     nxlib.nxicompmakedata_.restype = c_int 
    875     nxlib.nxicompmakedata_.argtypes  = [c_void_p, c_char_p, c_int, c_int, c_int_p, 
    876                                       c_int, c_int_p] 
     875    nxlib.nxicompmakedata64_.restype = c_int 
     876    nxlib.nxicompmakedata64_.argtypes  = [c_void_p, c_char_p, c_int, c_int, c_int64_p, 
     877                                          c_int, c_int64_p] 
    877878    def compmakedata(self, name, dtype=None, shape=None, mode='lzw', 
    878879                     chunks=None): 
     
    894895        # Make sure shape/chunk_shape are integers; hope that 32/64 bit issues 
    895896        # with the c int type sort themselves out. 
    896         dims = numpy.array(shape,'i') 
     897        dims = numpy.asarray(shape,'int64') 
    897898        if chunks == None: 
    898             chunks = numpy.ones(dims.shape,'i') 
     899            chunks = numpy.ones(dims.shape,'int64') 
    899900            chunks[-1] = shape[-1] 
    900901        else: 
    901             chunks = numpy.array(chunks,'i') 
    902         status = nxlib.nxicompmakedata_(self.handle,name,storage,len(dims), 
    903                                       dims.ctypes.data_as(c_int_p), 
    904                                       _compression_code[mode], 
    905                                       chunks.ctypes.data_as(c_int_p)) 
     902            chunks = numpy.array(chunks,'int64') 
     903        status = nxlib.nxicompmakedata64_(self.handle,name,storage,len(dims), 
     904                                          dims.ctypes.data_as(c_int64_p), 
     905                                          _compression_code[mode], 
     906                                          chunks.ctypes.data_as(c_int64_p)) 
    906907        if status == ERROR: 
    907908            raise ValueError, \ 
     
    932933        return datafn() 
    933934 
    934     nxlib.nxigetslab_.restype = c_int 
    935     nxlib.nxigetslab_.argtypes = [c_void_p, c_void_p, c_int_p, c_int_p] 
     935    nxlib.nxigetslab64_.restype = c_int 
     936    nxlib.nxigetslab64_.argtypes = [c_void_p, c_void_p, c_int64_p, c_int64_p] 
    936937    def getslab(self, slab_offset, slab_shape): 
    937938        """ 
     
    948949        dummy_shape,dtype = self.getrawinfo() 
    949950        dummy_data,pdata,dummy_size,datafn = self._poutput(dtype,slab_shape) 
    950         slab_offset = numpy.array(slab_offset,'i') 
    951         slab_shape = numpy.array(slab_shape,'i') 
    952         status = nxlib.nxigetslab_(self.handle,pdata, 
    953                                       slab_offset.ctypes.data_as(c_int_p), 
    954                                       slab_shape.ctypes.data_as(c_int_p)) 
     951        slab_offset = numpy.asarray(slab_offset,'int64') 
     952        slab_shape = numpy.asarray(slab_shape,'int64') 
     953        status = nxlib.nxigetslab64_(self.handle,pdata, 
     954                                     slab_offset.ctypes.data_as(c_int64_p), 
     955                                     slab_shape.ctypes.data_as(c_int64_p)) 
    955956        #print "slab",offset,size,data 
    956957        if status == ERROR: 
     
    975976            raise ValueError, "Could not write data: %s"%(self._loc()) 
    976977 
    977     nxlib.nxiputslab_.restype = c_int 
    978     nxlib.nxiputslab_.argtypes = [c_void_p, c_void_p, c_int_p, c_int_p] 
     978    nxlib.nxiputslab64_.restype = c_int 
     979    nxlib.nxiputslab64_.argtypes = [c_void_p, c_void_p, c_int64_p, c_int64_p] 
    979980    def putslab(self, data, slab_offset, slab_shape): 
    980981        """ 
     
    990991        dummy_shape,dtype = self.getrawinfo() 
    991992        data,pdata = self._pinput(data,dtype,slab_shape) 
    992         slab_offset = numpy.array(slab_offset,'i') 
    993         slab_shape = numpy.array(slab_shape,'i') 
     993        slab_offset = numpy.asarray(slab_offset,'int64') 
     994        slab_shape = numpy.asarray(slab_shape,'int64') 
    994995        #print "slab",offset,size,data 
    995996        status = nxlib.nxiputslab_(self.handle,pdata, 
    996                                       slab_offset.ctypes.data_as(c_int_p), 
    997                                       slab_shape.ctypes.data_as(c_int_p)) 
     997                                      slab_offset.ctypes.data_as(c_int64_p), 
     998                                      slab_shape.ctypes.data_as(c_int64_p)) 
    998999        if status == ERROR: 
    9991000            raise ValueError, "Could not write slab: %s"%(self._loc()) 
Note: See TracChangeset for help on using the changeset viewer.