Refactor arg checking and processing.

This fixes a bug when the shape is a tuple containing both symbolic
and numeric scalars.
Add test cases for bug fixed.
Merge pull request #1542 from lamblin/fix_random_shape

Fix bug with mixed types in shape of random sample