def interweave(a, b):
"""
given two array-like variables interweave them together.
Discussed here: http://stackoverflow.com/questions/5347065/interweaving-two-numpy-arrays
Parameters
==========
a : array-like
first array
b : array-like
second array
Returns
=======
out : numpy.ndarray
interweaved array
"""
a = np.asanyarray(a)
b = np.asanyarray(b)
ans = np.empty((a.size + b.size), dtype=a.dtype)
ans[0::2] = a
ans[1::2] = b
return ans
评论列表
文章目录