-
Notifications
You must be signed in to change notification settings - Fork 35
Update format of the generator chain #129
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
Update format of the generator chain #129
Conversation
So far, the code is ready and should work. Some of the tests are failing because I used a package from python 3.9. Do we need that backwards compatibility? |
781fe97
to
863469e
Compare
Yep, we only very recently moved to provide support for Python 3.9 and there is no plan to drop support for 3.6, 3.7 and 3.8 in the upcoming releases. So ideally we should not use any features that are Python 3.9 only |
A possible alternative to consider (which makes for a good choice despite being an external dependency) is |
If all we need is a topological sort of the signal generation DAG, then we
can implement it ourselves in < 1 day.
If we need more significantly more extensive graph algorithms, then using
an existing package makes sense.
…On Sun, 1 Aug 2021 at 13:16, Anurag Saha Roy ***@***.***> wrote:
A possible alternative to consider (which makes for a good choice despite
being an external dependency) is networkx
<https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.dag.topological_sort.html>.
It is widely used, stable, been around for a long time and is also used by
other quantum programming toolchains (eg qiskit which also has their own
re-implementation in rust retworkx <https://github.com/Qiskit/retworkx>.
I would suggest we use networkx and drop support for Python 3.6 instead
of dropping all previous versions in favour of the still pretty new Python
3.9 which many libraries don't fully support yet.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#129 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAH3Q4LURLTT3QHICO73BSDT2UNGHANCNFSM5AUF3K5A>
.
|
4910381
to
d720e25
Compare
I added a simple implementation of topological sorting. This should work without any dependence on python 3.9 now. |
08239c7
to
f495db7
Compare
f495db7
to
67f502b
Compare
Putting this on hold until #134 is fixed |
Please only update the changelog by adding new sections and not removing any of the instructions at the top This reverts commit 863469e.
Updates to CHANGELOG should follow the style in 4d6c8e2. Sorry if this wasn't adequately clear in the CONTRIBUTING document. The changelog should be updating by adding new details about what was done without removing content from the top. |
Codecov Report
@@ Coverage Diff @@
## dev #129 +/- ##
==========================================
+ Coverage 71.28% 71.81% +0.53%
==========================================
Files 36 36
Lines 5237 5475 +238
==========================================
+ Hits 3733 3932 +199
- Misses 1504 1543 +39
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.
Good to go.
What
Changes the form of the signal chain that the generator accepts into a dictionary. For each device, the dict specifies which devices are used as inputs, for example:
instead of
"d1": ["LO", "AWG", "DigitalToAnalog", "Response", "Mixer", "VoltsToHertz"]
Also, I added an optional callback to the generator which can be used for debugging during the signal generation.
Why
Closes #29
Previously, the order of the devices in the chain depended on the way the generator internally stored the signals on a stack. The dictionary can be created more intuitively and does not depend on the actual implementation of the generator.
How
The generator brings the directed graph into topological order. Then it iterates through the devices, only storing the signals as long as they are needed. This implementation should be able to handle any signal chain, even if the output of one device is used as input for several others. In case of a cycle, it will raise an error.
Remarks
I didn't test it with complicated signal chains, but some are covered by the unit tests.
Checklist
black
andflake8
have been used to ensure styling guidelines are metnumpydoc
style