Skip to content

Instantly share code, notes, and snippets.

@poolio
Created February 5, 2015 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poolio/9a923135a70843c79691 to your computer and use it in GitHub Desktop.
Save poolio/9a923135a70843c79691 to your computer and use it in GitHub Desktop.
volume to vector
def v2v(v, dims=None):
"""Convert volume to vector, or vector to volume"""
if v.ndim == 1:
assert dims != None
assert v.size == np.prod(dims)
return v.reshape(dims)
else:
return v.ravel()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment