Mercurial > pylearn
diff test_dataset.py @ 269:fdce496c3b56
deprecating __getitem__[fieldname] syntax
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Wed, 04 Jun 2008 19:04:40 -0400 |
parents | 3f1cd8897fda |
children | 271a16d42072 |
line wrap: on
line diff
--- a/test_dataset.py Wed Jun 04 18:48:50 2008 -0400 +++ b/test_dataset.py Wed Jun 04 19:04:40 2008 -0400 @@ -305,49 +305,52 @@ #ds[fieldname]# an iterable over the values of the field fieldname across #the ds (the iterable is obtained by default by calling valuesVStack #over the values for individual examples). - assert have_raised("ds['h']") # h is not defined... - assert have_raised("ds[['x']]") # bad syntax - assert not have_raised("var['ds']['x']",ds=ds) - isinstance(ds['x'],DataSetFields) - ds2=ds['x'] - assert len(ds['x'])==10 - assert len(ds['y'])==10 - assert len(ds['z'])==10 - i=0 - for example in ds['x']: - assert (example==array[i][:3]).all() - i+=1 - assert i==len(ds) - i=0 - for example in ds['y']: - assert (example==array[i][3]).all() - i+=1 - assert i==len(ds) - i=0 - for example in ds['z']: - assert (example==array[i,0:3:2]).all() - i+=1 - assert i==len(ds) - del ds2,i + if 0: + assert have_raised("ds['h']") # h is not defined... + assert have_raised("ds[['x']]") # bad syntax + assert not have_raised("var['ds']['x']",ds=ds) + isinstance(ds['x'],DataSetFields) + ds2=ds['x'] + assert len(ds['x'])==10 + assert len(ds['y'])==10 + assert len(ds['z'])==10 + i=0 + for example in ds['x']: + assert (example==array[i][:3]).all() + i+=1 + assert i==len(ds) + i=0 + for example in ds['y']: + assert (example==array[i][3]).all() + i+=1 + assert i==len(ds) + i=0 + for example in ds['z']: + assert (example==array[i,0:3:2]).all() + i+=1 + assert i==len(ds) + del ds2,i + else: + print 'warning: ds[fieldname] is deprecated... Fred could you fix this test?' -#ds.<property># returns the value of a property associated with - #the name <property>. The following properties should be supported: - # - 'description': a textual description or name for the ds - # - 'fieldtypes': a list of types (one per field) + #ds.<property># returns the value of a property associated with + #the name <property>. The following properties should be supported: + # - 'description': a textual description or name for the ds + # - 'fieldtypes': a list of types (one per field) -#* ds1 | ds2 | ds3 == ds.hstack([ds1,ds2,ds3])#???? - #assert hstack([ds('x','y'),ds('z')])==ds - #hstack([ds('z','y'),ds('x')])==ds + #* ds1 | ds2 | ds3 == ds.hstack([ds1,ds2,ds3])#???? + #assert hstack([ds('x','y'),ds('z')])==ds + #hstack([ds('z','y'),ds('x')])==ds assert have_raised2(hstack,[ds('x'),ds('x')]) assert have_raised2(hstack,[ds('y','x'),ds('x')]) assert not have_raised2(hstack,[ds('x'),ds('y')]) - -# i=0 -# for example in hstack([ds('x'),ds('y'),ds('z')]): -# example==ds[i] -# i+=1 -# del i,example -#* ds1 & ds2 & ds3 == ds.vstack([ds1,ds2,ds3])#???? + + # i=0 + # for example in hstack([ds('x'),ds('y'),ds('z')]): + # example==ds[i] + # i+=1 + # del i,example + #* ds1 & ds2 & ds3 == ds.vstack([ds1,ds2,ds3])#???? def test_fields_fct(ds): #@todo, fill correctly