Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # create an array to test the problem
- import numpy as np
- a = np.random.randint(255, size=268238).astype("uint8")
- # check size and dtype.
- a.size
- a.dtype
- # until now everything is fine
- # now i want to split it in equal parts of 2211 bytes
- # last one may be smaller
- # a.size // 2211 # 121
- a.size // 2211
- # check
- 121*2211
- 267531
- a.size - 267531
- 707 <-- remainder..sum (267531+707) should be ok.
- #
- https://docs.scipy.org/doc/numpy/reference/generated/numpy.array_split.html
- # just take the elements size now...
- (np.array_split(a, a.size // 2211))[0].size # <-- 2217... but why?
- (np.array_split(a, a.size // 2211))[1].size # <-- 2217... but why?
- # ...
- (np.array_split(a, a.size // 2211))[120].size # <-- 2216 (remainder..)
Add Comment
Please, Sign In to add comment