Mercurial > pylearn
comparison test_dataset.py @ 148:a5329e719229
added test for CachedDataSet
author | Frederic Bastien <bastienf@iro.umontreal.ca> |
---|---|
date | Mon, 12 May 2008 15:47:32 -0400 |
parents | 933db7ece663 |
children | feec9039b941 |
comparison
equal
deleted
inserted
replaced
145:933db7ece663 | 148:a5329e719229 |
---|---|
381 example2 = LookupList(['v','w'], ['a','b']) | 381 example2 = LookupList(['v','w'], ['a','b']) |
382 example3 = LookupList(['x','y','z','u','v','w'], [[1, 2, 3],2,3,0,'a','b']) | 382 example3 = LookupList(['x','y','z','u','v','w'], [[1, 2, 3],2,3,0,'a','b']) |
383 assert example+example2==example3 | 383 assert example+example2==example3 |
384 assert have_raised("var['x']+var['x']",x=example) | 384 assert have_raised("var['x']+var['x']",x=example) |
385 | 385 |
386 def test_CacheDataSet(): | |
387 print "test_CacheDataSet" | |
388 a2 = numpy.random.rand(10,4) | |
389 ds1 = ArrayDataSet(a2,LookupList(['x','y','z'],[slice(3),3,[0,2]]))###???tuple not tested | |
390 ds2 = CachedDataSet(ds1) | |
391 ds3 = CachedDataSet(ds1,cache_all_upon_construction=True) | |
392 assert len(ds2)==10 | |
393 | |
394 test_iterate_over_examples(a2, ds2) | |
395 test_getitem(a2, ds2) | |
396 | |
397 # - for val1,val2,val3 in dataset(field1, field2,field3): | |
398 test_ds_iterator(a2,ds2('x','y'),ds2('y','z'),ds(2'x','y','z')) | |
399 | |
400 | |
401 assert len(ds2.fields())==3 | |
402 for field in ds2.fields(): | |
403 for field_value in field: # iterate over the values associated to that field for all the ds examples | |
404 pass | |
405 for field in ds2('x','z').fields(): | |
406 pass | |
407 for field in ds2.fields('x','y'): | |
408 pass | |
409 for field_examples in ds2.fields(): | |
410 for example_value in field_examples: | |
411 pass | |
412 | |
413 assert ds2 == ds2.fields().examples() | |
414 # for ((x,y),a_v) in (ds('x','y'),a): #???don't work # haven't found a variant that work.# will not work | |
415 # assert numpy.append(x,y)==z | |
416 | |
417 | |
386 def test_ApplyFunctionDataSet(): | 418 def test_ApplyFunctionDataSet(): |
387 print "test_ApplyFunctionDataSet" | 419 print "test_ApplyFunctionDataSet" |
388 raise NotImplementedError() | |
389 def test_CacheDataSet(): | |
390 print "test_CacheDataSet" | |
391 raise NotImplementedError() | 420 raise NotImplementedError() |
392 def test_FieldsSubsetDataSet(): | 421 def test_FieldsSubsetDataSet(): |
393 print "test_FieldsSubsetDataSet" | 422 print "test_FieldsSubsetDataSet" |
394 raise NotImplementedError() | 423 raise NotImplementedError() |
395 def test_DataSetFields(): | 424 def test_DataSetFields(): |
409 raise NotImplementedError() | 438 raise NotImplementedError() |
410 | 439 |
411 test1() | 440 test1() |
412 test_LookupList() | 441 test_LookupList() |
413 test_ArrayDataSet() | 442 test_ArrayDataSet() |
443 test_CacheDataSet() | |
414 #test pmat.py | 444 #test pmat.py |