Mercurial > pylearn
changeset 220:1f527fe65e22
test on simple slicing works
author | Thierry Bertin-Mahieux <bertinmt@iro.umontreal.ca> |
---|---|
date | Fri, 23 May 2008 13:44:25 -0400 |
parents | 5b3afda2f1ad |
children | 58e17421c69c |
files | _test_dataset.py |
diffstat | 1 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/_test_dataset.py Fri May 23 13:16:42 2008 -0400 +++ b/_test_dataset.py Fri May 23 13:44:25 2008 -0400 @@ -1,6 +1,8 @@ from dataset import * from math import * import unittest +import sys +import numpy as N def _sum_all(a): s=a @@ -92,10 +94,14 @@ print b('x+y') + + # to be used with a any new dataset class T_dataset_tester(object): """ This class' goal is to test any new dataset that is created + Tests are (will be!) designed to check the normal behaviours + of a dataset, as defined in dataset.py """ @@ -121,10 +127,20 @@ """test if slicing works properly""" print 'testing slicing...', sys.stdout.flush() + middle = len(ds) / 2 tenpercent = int(len(ds) * .1) set1 = ds[:middle+tenpercent] set2 = ds[middle-tenpercent:] + for k in range(tenpercent + tenpercent -1): + for k2 in ds.fieldNames() : + if type(set1[middle-tenpercent+k](k2)[0]) == N.ndarray : + for k3 in range(len(set1[middle-tenpercent+k](k2)[0])) : + assert set1[middle-tenpercent+k](k2)[0][k3] == set2[k](k2)[0][k3] + else : + assert set1[middle-tenpercent+k](k2)[0] == set2[k](k2)[0] + + print 'done' ###################################################################