Guest User

Untitled

a guest
Feb 16th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. # create an array to test the problem
  2. import numpy as np
  3. a = np.random.randint(255, size=268238).astype("uint8")
  4. # check size and dtype.
  5. a.size
  6. a.dtype
  7. # until now everything is fine
  8. # now i want to split it in equal parts of 2211 bytes
  9. # last one may be smaller
  10. # a.size // 2211 # 121
  11. a.size // 2211
  12. # check
  13. 121*2211
  14. 267531
  15. a.size - 267531
  16. 707 <-- remainder..sum (267531+707) should be ok.
  17. #
  18. https://docs.scipy.org/doc/numpy/reference/generated/numpy.array_split.html
  19. # just take the elements size now...
  20. (np.array_split(a, a.size // 2211))[0].size # <-- 2217... but why?
  21. (np.array_split(a, a.size // 2211))[1].size # <-- 2217... but why?
  22. # ...
  23. (np.array_split(a, a.size // 2211))[120].size # <-- 2216 (remainder..)
Add Comment
Please, Sign In to add comment