diff --git a/python/ffsim/states/bitstring.py b/python/ffsim/states/bitstring.py index 49306b5ab..98cc3ae22 100644 --- a/python/ffsim/states/bitstring.py +++ b/python/ffsim/states/bitstring.py @@ -311,18 +311,25 @@ def addresses_to_strings( norb = 3 nelec = (2, 1) dim = ffsim.dim(norb, nelec) - strings = ffsim.addresses_to_strings(range(dim), norb, nelec) - [format(s, f"06b") for s in strings] - # output: - # ['001011', - # '010011', - # '100011', - # '001101', - # '010101', - # '100101', - # '001110', - # '010110', - # '100110'] + + strings = ffsim.addresses_to_strings(range(5), norb, nelec) + print(strings) # prints [11, 19, 35, 13, 21] + + strings = ffsim.addresses_to_strings( + range(5), norb, nelec, bitstring_type=ffsim.BitstringType.STRING + ) + print(strings) # prints ['001011', '010011', '100011', '001101', '010101'] + + strings = ffsim.addresses_to_strings( + range(5), norb, nelec, bitstring_type=ffsim.BitstringType.BIT_ARRAY + ) + print(strings) + # prints + # [[False False True False True True] + # [False True False False True True] + # [ True False False False True True] + # [False False True True False True] + # [False True False True False True]] Args: addresses: The state vector addresses to convert to bitstrings. @@ -338,6 +345,10 @@ def addresses_to_strings( If False, then two lists are returned, ``(strings_a, strings_b)``. Note that the list of alpha strings appears first, that is, on the left. In the spinless case (when `nelec` is an integer), this argument is ignored. + + Returns: + The bitstrings. The type of the output depends on `bitstring_type` and + `concatenate`. """ if isinstance(nelec, int): # Spinless case @@ -441,6 +452,9 @@ def strings_to_addresses( nelec: Either a single integer representing the number of fermions for a spinless system, or a pair of integers storing the numbers of spin alpha and spin beta fermions. + + Returns: + The state vector addresses, as a Numpy array of integers. """ if not len(strings): return np.array([])