added grid.py from libsvm