Closed albi3ro closed 9 months ago
Hello, I would like to work on this feature.
Sounds great @yass19 . Feel free to open a work-in-progress PR as you go or reach out to us with any questions. I also encourage you to read our guide on submitting a Pull Request.
Just to let you know we will be participating in Unitary Hack from June 3-17. Submission and acceptance of Pull Requests during that time will be eligible for swag and potential bounties.
Hi @yass19, if interested in bounties as a follow-up to what Christina mentioned, see issues with the unitaryhack-bounty label.
Hi! Can I work on this issue?
Hi @tgag17, sure :slightly_smiling_face: Feel free to reach out for help/when ready for the PR to be reviewed.
Hi. I am having some issues in pushing the code. Whenever I try to push the code to the origin its showing me an error that permission has been denied to give access and The requested URL returned error: 403
.
I understand this issue is due to the personal access token but I am not able to figure out the solution for this.
Any kind of help would be great :) @antalszava
Hi @tgag17, apologies for the very delayed response!
Did you try creating a fork for PennyLane and pushing there?
Hi @albi3ro @antalszava ! I am trying to retackle this issue. From the code given in the original post, I am not able to recreate the result. Instead of getting the result the code throws an error "Observable must be a scipy sparse csr_matrix.". Could you please confirm if the code should reproduce the result or not?
I am also trying to create a new SparseHamiltonion
object but to convert it to the csr format, the function is not accepting the input of (scalar)(SparseHamiltonion). Any suggestions on what can be done?
Thanks!
Hi @tgag17, apologies for the late reply. Changes in the master
branch have made the original snippet outdated and also seem to have made this issue be resolved (cc @albi3ro):
import pennylane as qml
from scipy import sparse
import numpy as np
sparse_mat = sparse.csr_matrix(np.array([[1.0, 2.0], [2.0, 3.0]]))
h = qml.SparseHamiltonian(sparse_mat, wires=[0])
new_h = -1.0 * h
print(new_h)
(-1.0) [SparseHamiltonian0]
@isaacdevlugt @albi3ro can this issue be closed now that #4828 is merged?
Suppose we create a Sparse Hamiltonian
If we multiply this by a float, we get back a
Hamiltonian
object pairing theSparseHamiltonian
with a coefficient:We should instead create a new
SparseHamiltonian
object with a new matrix. This way we can keep the benefits of having aSparseHamiltonian
object.This would be accomplished by defining the
__mul__
and__rmul__
dunder methods inSparseHamiltonian
located inpennylane/ops/qubit/observables.py