def finto(x, ii, n, null=<NUM_LIT:0>):
x  = x.toarray() if sps.issparse(x) else np.asarray(x)<EOL>shx = x.shape<EOL>if isinstance(ii, tuple):<EOL><INDENT>if not pimms.is_vector(n): n = tuple([n for _ in ii])<EOL>if len(n) != len(ii): raise ValueError('<STR_LIT>' % (len(ii),len(n)))<EOL>sh = n + shx[<NUM_LIT:1>:]<EOL><DEDENT>elif pimms.is_int(ii): sh = (n,) + shx<EOL>else:                  sh = (n,) + shx[<NUM_LIT:1>:]<EOL>u = np.zeros(sh, dtype=x.dtype) if null == <NUM_LIT:0> else np.full(sh, null, dtype=x.dtype)<EOL>u[ii] = x<EOL>return u<EOL>
finto(x,ii,n) yields a vector u of length n such that u[ii] = x.

Notes:
  * The ii index may be a tuple (as can be passed to numpy arrays' getitem method) in order to
    specify that the specific elements of a multidimensional output be set. In this case, the
    argument n should be a tuple of sizes (a single integer is taken to be a square/cube/etc).
  * x may be a sparse-array, but in it will be reified by this function.

The following optional arguments are allowed:
  * null (defaut: 0) specifies the value that should appear in the elements of u that are not
    set.