# HG changeset patch # User Frederic Bastien # Date 1210106505 14400 # Node ID cf9bdb1d96561de4b07e0163d4ba64ca1d9db9a2 # Parent 8c0a1b11b0079ce59bd37c24f473e25b84539837 added test diff -r 8c0a1b11b007 -r cf9bdb1d9656 test_dataset.py --- 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.# returns the value of a property associated with #the name . 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])#????