SHARE
TWEET

Untitled

a guest Feb 16th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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..)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top