Don't crash on infinite dimensions. Fixes #859