-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add for-loops to documentation #28
Conversation
Codecov Report
@@ Coverage Diff @@
## master #28 +/- ##
==========================================
+ Coverage 96.94% 97.61% +0.66%
==========================================
Files 12 12
Lines 1704 2141 +437
==========================================
+ Hits 1652 2090 +438
+ Misses 52 51 -1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @thisac! Just a question on the par
type, as well as some additional questions regarding for loops (that only just came to me reading through the examples)
Co-authored-by: Josh Izaac <josh146@gmail.com>
@josh146 Updated the docs with some new information about the program type, and fixed the issues that we discussed some time ago. I still need to update Blackbird to support arrays being free parameters, although I'm not sure if it's necessary to add any comments about this in the docs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just read through it; reads clearly and succinctly. Thanks @thisac
Co-authored-by: Josh Izaac <josh146@gmail.com>
…lackbird into ch326-blackbird-documentation
@josh146 Added a part on the TDM program as well, attempting to briefly explain how the TDM program type differs; mainly trying to explain the use of the p-type keywords. Let me know what you think! 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @thisac, just have a question regarding p
arrays (it's hard to tell if they are required/what happens if you include one that isn't).
I suppose the distinction needs to be made:
- If an array starts with
p
, each element in the array corresponds to a single timebin - If an array doesn't start with
p
, the entire array is passed to the gate in every timebin (it is a constant across timebins)
Now that I've written it out... it does feel a bit like a separate keyword, akin to const
in C++ 😆
loop int array bs =
1, 2
doc/syntax.rst
Outdated
TDM programs has reserved words starting with a ``p`` followed by a number; e.g., | ||
``p0``, ``p1``, or ``p42``. These are placeholders for the parameters in their | ||
corresponding arrays (see script example below). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if you don't use p
? E.g.,
name tdm
version 1.0
type tdm (temporal_modes=42, copies=3)
int array a =
1, 2
int array b =
3, 4
Sgate(0.7, 0) | 1
BSgate(a, 0.0) | [0, 1]
MeasureHomodyne(phi=b) | 0
Will that produce a parsing error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should. In that case I believe it would try to validate the type of a
and b
and fail (since they are arrays).
I was wrong above. This does work, but will insert the arrays directly into the operations inside the Blackbird program.
Thanks @josh146,
Yes, this would be the general use case. They're not strictly required, only used when wanting to pass different values to the different time-bins. Do you think this needs clarification still?
This wouldn't (and shouldn't) work, right? Blackbird doesn't support passing an array to a gate. But, assuming that gates could receive arrays as parameters, then yes, this would be the case. |
This should work, as you say, for gates that accept arrays (e.g., name tdm
version 1.0
type tdm (temporal_modes=42, copies=3)
int array U =
1, 0
0, 1
int array p0 =
3, 4
Sgate(0.7, 0) | 1
Interferometer(U) | [0, 1] # All of U with every timebin
MeasureHomodyne(phi=p0) | 0 # one element of p0 per timebin |
Co-authored-by: Josh Izaac <josh146@gmail.com>
This PR updates the Blackbird documentation by: