Skip to content

Commit

Permalink
pl-device-test fix: do not differentiate Projector with respect to …
Browse files Browse the repository at this point in the history
…state (#5683)

### Before submitting

Please complete the following checklist when submitting a PR:

- [x] All new features must include a unit test.
If you've fixed a bug or added code that should be tested, add a test to
the
      test directory!

- [x] All new functions and code must be clearly commented and
documented.
If you do make documentation changes, make sure that the docs build and
      render correctly by running `make docs`.

- [ ] Ensure that the test suite passes, by running `make test`.

- [x] Add a new entry to the `doc/releases/changelog-dev.md` file,
summarizing the
      change, and including a link back to the PR.

- [x] The PennyLane source code conforms to
      [PEP8 standards](https://www.python.org/dev/peps/pep-0008/).
We check all of our code against [Pylint](https://www.pylint.org/).
      To lint modified files, simply `pip install pylint`, and then
      run `pylint pennylane/path/to/file.py`.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


------------------------------------------------------------------------------------------------------------

**Context:**

**Description of the Change:**
Use vanilla NumPy arrays in `test_projector_expectation` to avoid
differentiating `qml.Projector` with respect to the state attribute.

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**
  • Loading branch information
vincentmr authored May 14, 2024
1 parent 64de143 commit be35a7b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@

<h3>Bug fixes 🐛</h3>

* Use vanilla NumPy arrays in `test_projector_expectation` to avoid differentiating `qml.Projector` with respect to the state attribute.
[(#5683)](https://github.com/PennyLaneAI/pennylane/pull/5683)

* `qml.Projector` is now compatible with jax-jit.
[(#5595)](https://github.com/PennyLaneAI/pennylane/pull/5595)

Expand Down
10 changes: 6 additions & 4 deletions pennylane/devices/tests/test_compare_default_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests that a device gives the same output as the default device."""
import numpy as np

# pylint: disable=no-self-use,no-member
import pytest
from flaky import flaky
Expand Down Expand Up @@ -90,10 +92,10 @@ def workload():
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1],
pnp.array([1, 1, 0, 0]) / pnp.sqrt(2),
pnp.array([0, 1, 0, 1]) / pnp.sqrt(2),
pnp.array([1, 1, 1, 0]) / pnp.sqrt(3),
pnp.array([1, 1, 1, 1]) / 2,
np.array([1, 1, 0, 0]) / np.sqrt(2),
np.array([0, 1, 0, 1]) / np.sqrt(2),
np.array([1, 1, 1, 0]) / np.sqrt(3),
np.array([1, 1, 1, 1]) / 2,
],
)
def test_projector_expectation(self, device, state, tol, benchmark):
Expand Down
2 changes: 1 addition & 1 deletion requirements-ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ autograd
toml
appdirs
semantic_version
autoray
autoray>=0.6.1,<0.6.10
matplotlib
requests
tomli # Drop once minimum Python version is 3.11
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ autograd~=1.4
toml~=0.10
appdirs~=1.4
semantic_version~=2.10
autoray>=0.6.1
autoray>=0.6.1,<0.6.10
matplotlib~=3.5
opt_einsum~=3.3
requests~=2.31.0
Expand Down

0 comments on commit be35a7b

Please sign in to comment.