Last active
June 12, 2019 08:15
-
-
Save RicherMans/6ce6a90c328dd6470f579552cc28e4d2 to your computer and use it in GitHub Desktop.
Interwaves two arrays given a specific ratio of array1 to array2, Ratio can also be float
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def interweave(ratio, arr1, arr2): | |
combined_length = len(arr1) + len(arr2) | |
index_array = np.arange(combined_length) | |
take_array = (ratio * np.arange(0, len(arr1))).round().astype(int) | |
take_binary = np.zeros_like(index_array).astype(bool) | |
take_binary[take_array] = 1 | |
index_array[take_binary] = arr1 | |
index_array[~take_binary] = arr2 | |
return index_array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment