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

[Strings3] Update documentation and codebase with new string representations of X, Y, Z and Identity #5153

Merged
merged 100 commits into from
Feb 22, 2024

Conversation

Qottmann
Copy link
Contributor

@Qottmann Qottmann commented Feb 5, 2024

Updating docs and codebase with qml.X/Y/Z/I(*) instead of qml.PauliX/Y/Z(*) and qml.Identity(*) following #5116 and updating composite operation outputs in docs according to #5138

ToDo

@Qottmann Qottmann requested a review from mudit2812 February 15, 2024 14:01
Copy link
Contributor

@trbromley trbromley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Qottmann! This was from a find-and-replace right? 😆

My main reflection is that, given we are pointing everyone to X, Y, Z, we should probably improve the docs for them (e.g.) - maybe making PauliX the alias instead.

@josh146
Copy link
Member

josh146 commented Feb 15, 2024

Yep this is actually quite important:

My main reflection is that, given we are pointing everyone to X, Y, Z, we should probably improve the docs for them (e.g.) - maybe making PauliX the alias instead.

We should update the qml.X etc. docstrings to be the main docstrings. We should also have the qml.PauliX have minimal docstrings with a ..seealso:: linking to the X version

@Qottmann Qottmann force-pushed the docstrings branch 2 times, most recently from 3be7577 to 80c5d1b Compare February 16, 2024 13:08
@Qottmann
Copy link
Contributor Author

Excellent point!

A lot of the codebase seems to rely on checking not just isinstance(op, PauliX) but also directly checking the name of the class or instance. I went with the solution to have X/Y/Z/I be the main classes and overwrite the class name. PauliX/Y/Z/Identity are now just aliases. This way the mechanics in the codebase and any plugins remain functioning.

I also tried subclassing but it turned out difficult to have both isinstance(qml.PauliX(0), qml.X) and isinstance(qml.X(0), qml.PauliX). I also tried with a metaclass to overwrite the __instancecheck__ but I couldnt get it to work (happy to discuss though)

Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that was painful to get through...

@Qottmann Qottmann added this to the v0.35 milestone Feb 21, 2024
Qottmann and others added 6 commits February 22, 2024 12:01
Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
@Qottmann
Copy link
Contributor Author

Now:

image

and

image

Sounds good?

@Qottmann Qottmann merged commit 328821f into master Feb 22, 2024
39 checks passed
@Qottmann Qottmann deleted the docstrings branch February 22, 2024 13:41
Qottmann added a commit that referenced this pull request Feb 22, 2024
… with PennyLane (#5215)

```python3
coeffs = [2.0, f1, f2]
ops = [qml.PauliX(0), qml.PauliY(0), qml.PauliZ(0)]
H = qml.dot(coeffs, ops)
print(H)
```
```pycon
(
    2.0 * X(0)
  + f1(params_0, t) * Y(0)
  + f2(params_1, t) * Z(0)
)
```

- [x] Update repr
- [x] Update tests
- [x] Update docs
- [x] changelog
- [x] Update qml.dot docs

builds on top of #5153
[sc-57051]

---------

Co-authored-by: Thomas R. Bromley <49409390+trbromley@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

4 participants