Skip to content

Instantly share code, notes, and snippets.

@techwithshadab
Created November 3, 2021 21:02
Show Gist options
  • Save techwithshadab/884c5c31d319a76f11794918fccab2d5 to your computer and use it in GitHub Desktop.
Save techwithshadab/884c5c31d319a76f11794918fccab2d5 to your computer and use it in GitHub Desktop.
def index_to_selection(i, num_assets):
s = "{0:b}".format(i).rjust(num_assets)
x = np.array([1 if s[i]=='1' else 0 for i in reversed(range(num_assets))])
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment