Ignore:
Timestamp:
16/01/09 23:26:16 (3 years ago)
Author:
Paul Kienzle
Message:

xml getattrinfo now returns correct number of attrs for root; nxstest now skips bogus CDF0.0 entry in HDF4 root; nxs/napi.py now reimplements openpath so that nexus file knows its current path. Refs #149.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bindings/python/nxstest.py

    r1170 r1171  
    4545        print "%(prefix)s@%(attr)s: %(value)s" % locals() 
    4646    for name,nxclass in file.entries(): 
     47        if nxclass.startswith("CDF"): continue # Root has an extra CDF class 
    4748        if nxclass == "SDS": 
    4849            shape,dtype = file.getinfo() 
     
    189190    file = nxs.open(filename,'rw') 
    190191    if filename != file.inquirefile(): fail("Files don't match") 
    191     attrs = file.getattrinfo() 
    192     if attrs != 4: fail("Expected 4 root attributes but got %d", attrs) 
    193     for i in range(attrs): 
     192 
     193    # check headers 
     194    num_attrs = file.getattrinfo() 
     195    wxattrs = ['xmlns','xmlns:xsi','xsi:schemaLocation', 'XML_version'] 
     196    w4attrs = ['HDF_version'] 
     197    w5attrs = ['HDF5_Version'] 
     198    extras = dict(wx=wxattrs,w4=w4attrs,w5=w5attrs) 
     199    expected_attrs = ['NeXus_version','file_name','file_time']+extras[mode] 
     200    for i in range(num_attrs): 
    194201        name,dims,type = file.getnextattr() 
    195         if name not in ['file_time','HDF_version','HDF5_Version','XML_version', 
    196                         'NeXus_version','file_name']: 
     202        if name not in expected_attrs: 
    197203            fail("attribute %s unexpected"%(name)) 
     204    if num_attrs != len(expected_attrs):  
     205        fail("Expected %d root attributes but got %d" 
     206             % (len(expected_attrs),num_attrs)) 
    198207     
    199208    file.opengroup('entry','NXentry') 
     
    230239    if not get == numpy.int32(42): fail("i4_attribute retrieved %s"%(get)) 
    231240    get = file.getattr("r4_attribute",1,'float32') 
    232     if not get == numpy.float32(3.14159265): fail("r4_attribute retrieved %s"%(get)) 
     241    if ((mode=='wx' and not abs(get-3.14159265) < 1e-6) or 
     242        (mode!='wx' and not get == numpy.float32(3.14159265))): 
     243        fail("r4_attribute retrieved %s"%(get)) 
    233244    ## Oops... NAPI doesn't support array attributes 
    234245    #expect = numpy.array([3,2],dtype='int32') 
Note: See TracChangeset for help on using the changeset viewer.