comparison test_dataset.py @ 168:c704a66706fe

more test
author Frederic Bastien <bastienf@iro.umontreal.ca>
date Tue, 13 May 2008 13:00:54 -0400
parents 2a12e7437c56
children 051e07807554
comparison
equal deleted inserted replaced
165:2a12e7437c56 168:c704a66706fe
304 assert len(ds['z'])==10 304 assert len(ds['z'])==10
305 i=0 305 i=0
306 for example in ds['x']: 306 for example in ds['x']:
307 assert (example==array[i][:3]).all() 307 assert (example==array[i][:3]).all()
308 i+=1 308 i+=1
309 assert i==len(ds)
309 i=0 310 i=0
310 for example in ds['y']: 311 for example in ds['y']:
311 assert (example==array[i][3]).all() 312 assert (example==array[i][3]).all()
312 i+=1 313 i+=1
314 assert i==len(ds)
313 i=0 315 i=0
314 for example in ds['z']: 316 for example in ds['z']:
315 assert (example==array[i,0:3:2]).all() 317 assert (example==array[i,0:3:2]).all()
316 i+=1 318 i+=1
319 assert i==len(ds)
317 del ds2,i 320 del ds2,i
318 321
319 #ds.<property># returns the value of a property associated with 322 #ds.<property># returns the value of a property associated with
320 #the name <property>. The following properties should be supported: 323 #the name <property>. The following properties should be supported:
321 # - 'description': a textual description or name for the ds 324 # - 'description': a textual description or name for the ds
336 #* ds1 & ds2 & ds3 == ds.vstack([ds1,ds2,ds3])#???? 339 #* ds1 & ds2 & ds3 == ds.vstack([ds1,ds2,ds3])#????
337 340
338 def test_fields_fct(ds): 341 def test_fields_fct(ds):
339 #@todo, fill correctly 342 #@todo, fill correctly
340 assert len(ds.fields())==3 343 assert len(ds.fields())==3
344 i=0
345 v=0
341 for field in ds.fields(): 346 for field in ds.fields():
342 for field_value in field: # iterate over the values associated to that field for all the ds examples 347 for field_value in field: # iterate over the values associated to that field for all the ds examples
343 pass 348 v+=1
349 i+=1
350 assert i==3
351 assert v==3*10
352 del i,v
353
354 i=0
355 v=0
344 for field in ds('x','z').fields(): 356 for field in ds('x','z').fields():
345 pass 357 i+=1
358 for val in field:
359 v+=1
360 assert i==2
361 assert v==2*10
362 del i,v
363
364 i=0
365 v=0
346 for field in ds.fields('x','y'): 366 for field in ds.fields('x','y'):
347 pass 367 i+=1
368 for val in field:
369 v+=1
370 assert i==2
371 assert v==2*10
372 del i,v
373
374 i=0
375 v=0
348 for field_examples in ds.fields(): 376 for field_examples in ds.fields():
349 for example_value in field_examples: 377 for example_value in field_examples:
350 pass 378 v+=1
351 379 i+=1
380 assert i==3
381 assert v==3*10
382 del i,v
383
352 assert ds == ds.fields().examples() 384 assert ds == ds.fields().examples()
353 385 assert len(ds('x','y').fields()) == 2
354 386 assert len(ds('x','z').fields()) == 2
387 assert len(ds('y').fields()) == 1
388
389 del field
355 390
356 def test_ArrayDataSet(): 391 def test_ArrayDataSet():
357 #don't test stream 392 #don't test stream
358 #tested only with float value 393 #tested only with float value
359 #don't always test with y 394 #don't always test with y