Fix issue with np.ndindex(3)

np.ndindex(3) causes the following error:

TypeError: object of type 'int' has no len()

Before checking for length of shape argument, check if tuple first.