Created
September 21, 2019 12:56
-
-
Save straussmaximilian/654928ee8ca4883f8e51030a6d0f064a to your computer and use it in GitHub Desktop.
This file contains 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 boolean_index(array): | |
""" | |
Takes a numpy array and isolates all points that are within [0.2,0.4] for | |
the first dimension and between [0.4,0.6] for | |
the second dimension by creating a boolean index. | |
""" | |
index = (array[:, 0] >= 0.2) & (array[:, 1] >= 0.4) & (array[:, 0] <= 0.4) & (array[:, 1] <= 0.6) | |
return array[index] | |
print('Boolean index:\t', end='') | |
%timeit boolean_index(array) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment