Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Likely error in loop construct in _multisensor.py #928

Open
mhucka opened this issue Feb 3, 2025 · 0 comments
Open

Likely error in loop construct in _multisensor.py #928

mhucka opened this issue Feb 3, 2025 · 0 comments

Comments

@mhucka
Copy link
Contributor

mhucka commented Feb 3, 2025

In the file src/openfermion/contrib/representability/_multitensor.py, lines 105-122, the index variable index is first used in a for loop, then used again in subsequent lines outside of the for loop.

for index, dual_element in enumerate(self.dual_basis):
    dcol, dval = self.synthesize_element(dual_element)
    dual_row_indices.extend([index] * len(dcol))
    dual_col_indices.extend(dcol)
    dual_data_values.extend(dval)
    inner_prod_data_values.append(float(dual_element.dual_scalar))
    bias_data_values.append(dual_element.constant_bias)
sparse_dual_operator = csr_matrix(
    (dual_data_values, (dual_row_indices, dual_col_indices)), [index + 1, self.vec_dim]
)

sparse_bias_vector = csr_matrix(
    (bias_data_values, (range(index + 1), [0] * (index + 1))), [index + 1, 1]
)

sparse_innerp_vector = csr_matrix(
    (inner_prod_data_values, (range(index + 1), [0] * (index + 1))), [index + 1, 1]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant