Created
August 31, 2017 01:49
-
-
Save mizunototori/9b26f8b5bdcccabdadb460da7dcfffc1 to your computer and use it in GitHub Desktop.
python ind2sub same with matlab
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 ind2sub(array_shape, ind): | |
# Gives repeated indices, replicates matlabs ind2sub | |
rows = (ind.astype("int32") // array_shape[1]) | |
cols = (ind.astype("int32") % array_shape[1]) | |
return (rows, cols) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference:
https://gist.github.com/kastnerkyle/85a75e2eaaa3f6aa9894d2721d825556