Fix UnboundLocalError when a datasource of the wrong shape is looked for

We should raise a proper exception when the shape isn't correct as opposed to let an UnboundLocalError occur.
Hmm, I don't know why I thought otherwise. Sorry for the noise!