开发者

A numpy.arange style function with array inputs

开发者 https://www.devze.com 2023-03-06 09:35 出处:网络
I have numpy arrays of start indices and end ind开发者_开发问答ices from which I\'d like to construct a flattened array of ranges.

I have numpy arrays of start indices and end ind开发者_开发问答ices from which I'd like to construct a flattened array of ranges.

e.g. with inputs

s = np.array([1,2,3])
e = np.array([4,5,10])

and output

array([1,2,3,2,3,4,3,4,5,6,7,8,9])

any way to do this efficiently?


How about just

np.concatenate([np.arange(x, y) for x, y in zip(s, e)])
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号