# HG changeset patch # User Thierry Bertin-Mahieux # Date 1211563002 14400 # Node ID 5b3afda2f1ad619ca85a0f9664d3a7a3c28ccb5d # Parent df3fae88ab46499b702338e76c63da51d93d02a1 added a class to test any new dataset diff -r df3fae88ab46 -r 5b3afda2f1ad _test_dataset.py --- a/_test_dataset.py Fri May 23 12:22:54 2008 -0400 +++ b/_test_dataset.py Fri May 23 13:16:42 2008 -0400 @@ -92,6 +92,43 @@ 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 + """ + + + def __init__(self,ds,runall=True) : + """if interested in only a subset of test, init with runall=False""" + self.ds = ds + + if runall : + self.test1_basicstats(ds) + self.test2_slicing(ds) + + def test1_basicstats(self,ds) : + """print basics stats on a dataset, like length""" + + print 'len(ds) = ',len(ds) + print 'num fields = ', len(ds.fieldNames()) + print 'types of field: ', + for k in ds.fieldNames() : + print type(ds[0](k)[0]), + print '' + + def test2_slicing(self,ds) : + """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:] + + +################################################################### +# main if __name__ == '__main__': unittest.main()