Added protection for out-of-bounds #rank calls
Merge pull request #228 from andrewcsmith/issue-227-rank-allows-dimensions

Added protection for out-of-bounds #rank calls