The ndim checks are redundant, since the signature already requires it in the compiled version.