Mercurial > pylearn
changeset 106:cf9bdb1d9656
added test
author | Frederic Bastien <bastienf@iro.umontreal.ca> |
---|---|
date | Tue, 06 May 2008 16:41:45 -0400 |
parents | 8c0a1b11b007 |
children | 695b729027d4 5bfcb7e5df4a |
files | test_dataset.py |
diffstat | 1 files changed, 32 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/test_dataset.py Tue May 06 16:34:48 2008 -0400 +++ b/test_dataset.py Tue May 06 16:41:45 2008 -0400 @@ -35,9 +35,10 @@ def test_ArrayDataSet(): #don't test stream #tested only with float value - #test with y too - #test missing value - + #don't always test with y + #don't test missing value + #don't test with tuple + #don't test proterties def test_iterate_over_examples(array,ds): #not in doc!!! i=0 @@ -263,39 +264,61 @@ for x in ds: pass - assert have_raised("ds['h']") # h is not defined... - assert have_raised("ds[['x']]") # h is not defined... - assert not have_raised("ds['x']") - assert have_raised("ds["+str(len(ds))+"]") # index not defined - assert not have_raised("ds["+str(len(ds)-1)+"]") - #ds[:n] returns a dataset with the n first examples. ds2=ds[:3] assert isinstance(ds2,DataSet) test_ds(ds,ds2,index=[0,1,2]) + del ds2 #ds[i1:i2:s]# returns a ds with the examples i1,i1+s,...i2-s. ds2=ds[1:7:2] assert isinstance(ds2,DataSet) test_ds(ds,ds2,[1,3,5]) + del ds2 #ds[i] ds2=ds[5] assert isinstance(ds2,Example) + assert have_raised("ds["+str(len(ds))+"]") # index not defined + assert not have_raised("ds["+str(len(ds)-1)+"]") + del ds2 #ds[[i1,i2,...in]]# returns a ds with examples i1,i2,...in. ds2=ds[[4,7,2,8]] assert isinstance(ds2,DataSet) test_ds(ds,ds2,[4,7,2,8]) + del ds2 #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("ds['x']") + 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==a[i][:3]).all() + i+=1 + i=0 + for example in ds['y']: + assert (example==a[i][3]).all() + i+=1 + i=0 + for example in ds['z']: + assert (example==a[i,0:3:2]).all() + i+=1 + del ds2,i #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])#???? #* ds1 & ds2 & ds3 == ds.vstack([ds1,ds2,ds3])#????