Ignore:
Timestamp:
14/04/09 18:56:40 (3 years ago)
Author:
Freddie Akeroyd
Message:

Merg in r1212:r1222 from trunk. Refs #115.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2/bindings/python/nxstest.py

    r1180 r1230  
    132132    # .. demonstrate extensible data 
    133133    file.makedata('flush_data','int32',[nxs.UNLIMITED]) 
     134    file.opendata('flush_data') 
    134135    for i in range(7): 
    135         file.opendata('flush_data') 
    136136        file.putslab(i,[i],[1]) 
    137         file.flush() 
    138         # Oops... why isn't there a closedata()? 
     137    file.closedata() 
     138    file.flush() 
    139139    file.closegroup() 
    140140 
     
    142142    file.makegroup('sample','NXsample') 
    143143    file.opengroup('sample','NXsample') 
    144     file.makedata('ch_data','char',[12]) 
     144    file.makedata('ch_data','char',[20]) 
    145145    file.opendata('ch_data') 
    146146    file.putdata('NeXus sample') 
     
    231231            fail("%s retrieved %s"%(dtype,get)) 
    232232 
     233 
    233234    # Check attribute types 
    234235    file.opendata('r8_data') 
     
    255256    for i in range(100): comp_array[i,:] *= i 
    256257    expected = comp_array 
    257     file.opengroup('data','NXdata') 
    258     file.opendata('comp_data') 
     258    file.opengroup('data','NXdata') #/entry/data 
     259    file.opendata('comp_data')      #/entry/data/comp_data 
    259260    get = file.getdata() 
    260     file.closedata()  #/entry/data/comp_data 
    261     file.closegroup() #/entry/data 
     261    file.closedata()                #/entry/data/comp_data 
     262    file.closegroup()               #/entry/data 
    262263    if not (get == expected).all(): 
    263264        fail("compressed data differs") 
    264265        print get 
     266         
     267    # Check strings 
     268    file.opengroup('sample','NXsample') #/entry/sample 
     269    file.opendata('ch_data')            #/entry/sample/ch_data 
     270    rawshape,rawdtype = file.getrawinfo() 
     271    shape,dtype = file.getinfo() 
     272    get = file.getdata() 
     273    file.closedata()                    #/entry/sample/ch_data 
     274    file.closegroup()                   #/entry/sample 
     275    if not (shape[0]==12 and dtype=='char'): 
     276        fail("returned string info is incorrect") 
     277        print shape,dtype 
     278    if not (rawshape[0]==20 and rawdtype=='char'): 
     279        fail("returned string storage info is incorrect") 
     280        print shape,dtype 
     281    if not (get == "NeXus sample"): 
     282        fail("returned string is incorrect") 
     283        print shape,dtype 
     284 
     285 
    265286    file.closegroup() #/entry 
    266          
     287 
    267288    # Check read slab (e.g., from extensible) 
    268289 
Note: See TracChangeset for help on using the changeset viewer.