Added assert statement to catch wrong shape of array (see issue #503).