py/gamma.py: Make gamma table calculations more generic