Skip to content

Instantly share code, notes, and snippets.

@edenau
Last active December 30, 2019 05:17
Show Gist options
  • Save edenau/5f8afbe3a35d65919a9fde6e4dc649c8 to your computer and use it in GitHub Desktop.
Save edenau/5f8afbe3a35d65919a9fde6e4dc649c8 to your computer and use it in GitHub Desktop.
arr = np.array(range(1000)).reshape(2,5,2,10,-1)
print(arr[:,:,:,3,2] == arr[...,3,2])
# [[[ True, True],
# [ True, True],
# [ True, True],
# [ True, True],
# [ True, True]],
# [[ True, True],
# [ True, True],
# [ True, True],
# [ True, True],
# [ True, True]]])
print(arr.shape) # (2, 5, 2, 10, 5)
print(arr[...,np.newaxis,:,:,:].shape) # (2, 5, 1, 2, 10, 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment