Guest User

Untitled

a guest
Jan 30th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. arr = np.array([[1,2,3],[4,5,6],[7,8,9]])
  2. array([[0, 1, 2],
  3. [3, 4, 5],
  4. [6, 7, 8]])
  5.  
  6. (0.5, 0.5)
  7. (0.5, 1.5)
  8. (0.5, 2.5)
  9. (1.5, 0.5)
  10. (1.5, 1.5)
  11. (1.5, 2.5)
  12. (2.5, 0.5)
  13. (2.5, 1.5)
  14. (2.5, 2.5)
  15.  
  16. for row in range(arr.shape[0]):
  17. for col in range(arr.shape[1]):
  18. print (row + 0.5, col + 0.5)
  19.  
  20. import numpy as np
  21.  
  22. arr = np.arange(3 * 3).reshape(3, 3)
  23.  
  24. grid = np.mgrid[:arr.shape[0], :arr.shape[1]] + 0.5
  25.  
  26. print(grid.reshape(2, grid.size // 2).T)
Add Comment
Please, Sign In to add comment