-
-
Save poolio/9a923135a70843c79691 to your computer and use it in GitHub Desktop.
volume to vector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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