comparison _test_dataset.py @ 349:2174fe5cc7d0

added test for ds.subset()
author Frederic Bastien <bastienf@iro.umontreal.ca>
date Tue, 17 Jun 2008 16:09:59 -0400
parents 952129cd55cb
children ae6605eccd09
comparison
equal deleted inserted replaced
348:952129cd55cb 349:2174fe5cc7d0
369 pass 369 pass
370 370
371 #ds[:n] returns a dataset with the n first examples. 371 #ds[:n] returns a dataset with the n first examples.
372 ds2=ds.subset[:3] 372 ds2=ds.subset[:3]
373 test_ds(ds,ds2,index=[0,1,2]) 373 test_ds(ds,ds2,index=[0,1,2])
374 # del ds2 374 # del ds2
375 375
376 # #ds[i1:i2:s]# returns a ds with the examples i1,i1+s,...i2-s. 376 #ds[i1:i2:s]# returns a ds with the examples i1,i1+s,...i2-s.
377 # ds2=ds.subset[1:7:2] 377 ds2=ds.subset[1:7:2]
378 # test_ds(ds,ds2,[1,3,5]) 378 test_ds(ds,ds2,[1,3,5])
379 # del ds2 379 # del ds2
380 380
381 # #ds[i] 381 # #ds[i]
382 # ds2=ds.subset[5] 382 # ds2=ds.subset[5]
383 # assert isinstance(ds2,Example) 383 # assert isinstance(ds2,Example)
384 # assert have_raised("var['ds']["+str(len(ds))+"]",ds=ds) # index not defined 384 # assert have_raised("var['ds']["+str(len(ds))+"]",ds=ds) # index not defined
385 # assert not have_raised("var['ds']["+str(len(ds)-1)+"]",ds=ds) 385 # assert not have_raised("var['ds']["+str(len(ds)-1)+"]",ds=ds)
386 # del ds2 386 # del ds2
387 387
388 # #ds[[i1,i2,...in]]# returns a ds with examples i1,i2,...in. 388 #ds[[i1,i2,...in]]# returns a ds with examples i1,i2,...in.
389 # ds2=ds.subset[[4,7,2,8]] 389 ds2=ds.subset[[4,7,2,8]]
390 # test_ds(ds,ds2,[4,7,2,8]) 390 test_ds(ds,ds2,[4,7,2,8])
391 # del ds2 391 # del ds2
392 392
393 # #ds.<property># returns the value of a property associated with 393 #ds.<property># returns the value of a property associated with
394 # #the name <property>. The following properties should be supported: 394 #the name <property>. The following properties should be supported:
395 # # - 'description': a textual description or name for the ds 395 # - 'description': a textual description or name for the ds
396 # # - 'fieldtypes': a list of types (one per field) 396 # - 'fieldtypes': a list of types (one per field)
397 397
398 # #* ds1 | ds2 | ds3 == ds.hstack([ds1,ds2,ds3])#???? 398 #* ds1 | ds2 | ds3 == ds.hstack([ds1,ds2,ds3])#????
399 # #assert hstack([ds('x','y'),ds('z')])==ds 399 #assert hstack([ds('x','y'),ds('z')])==ds
400 # #hstack([ds('z','y'),ds('x')])==ds 400 #hstack([ds('z','y'),ds('x')])==ds
401 # assert have_raised2(hstack,[ds('x'),ds('x')]) 401 assert have_raised2(hstack,[ds('x'),ds('x')])
402 # assert have_raised2(hstack,[ds('y','x'),ds('x')]) 402 assert have_raised2(hstack,[ds('y','x'),ds('x')])
403 # assert not have_raised2(hstack,[ds('x'),ds('y')]) 403 assert not have_raised2(hstack,[ds('x'),ds('y')])
404 404
405 # # i=0 405 # i=0
406 # # for example in hstack([ds('x'),ds('y'),ds('z')]): 406 # for example in hstack([ds('x'),ds('y'),ds('z')]):
407 # # example==ds[i] 407 # example==ds[i]
408 # # i+=1 408 # i+=1
409 # # del i,example 409 # del i,example
410 # #* ds1 & ds2 & ds3 == ds.vstack([ds1,ds2,ds3])#???? 410 #* ds1 & ds2 & ds3 == ds.vstack([ds1,ds2,ds3])#????
411 411
412 def test_fields_fct(ds): 412 def test_fields_fct(ds):
413 #@todo, fill correctly 413 #@todo, fill correctly
414 assert len(ds.fields())==3 414 assert len(ds.fields())==3
415 i=0 415 i=0