-
Notifications
You must be signed in to change notification settings - Fork 21
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
Fix #45: Parameterized measurement patterns #158
base: master
Are you sure you want to change the base?
Fix #45: Parameterized measurement patterns #158
Conversation
3093bdd
to
a5e16de
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #158 +/- ##
==========================================
+ Coverage 71.82% 72.95% +1.13%
==========================================
Files 30 31 +1
Lines 5359 6038 +679
==========================================
+ Hits 3849 4405 +556
- Misses 1510 1633 +123 ☔ View full report in Codecov by Sentry. |
@thierry-martinez great, is the intention to merge @pafloxy's #68-equivalent code first (when it's ready), before merging this? |
I adapted #68 code for The test |
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.
I think as for now this is all that I was looking for, If @shinich1 thinks its alright maybe we should go for the merge. :)
@thierry-martinez @pafloxy great! give us a few days to look through. A few quick comments:
|
Let me review it later. Anyway, is it absolutely necessary to use sympy?
Additionally, let me point out that @masa10-f is planning to completely eliminate sympy from the source. |
If sympy is absolutely necessary, it's OK, but we may need to verify that we're using it wisely. |
@shinich1 @thierry-martinez
where we might need to add another line or so to exclude the case where the measurement angles is an instance of |
I think the best way is to move parameter implementation with The reason mostly follows @EarlMilktea 's. Sustaining maintainability is going to help a lot in the long run for everyone contributing to this repo and will help a lot those maintaining.
|
I propose in my last commits a version which does not require
|
Thank you! I believe you mean |
@thierry-martinez the implementation looks good to me! we need to:
|
I'm a little bit concerned about...
|
We suggest the following:
|
This commit implements TeamGraphix#158 (comment) Sympy plugin is implemented in https://github.com/thierry-martinez/graphix-symbolic/tree/sympy
As @shinich1 suggested in the above message, this PR now only provides abstract base classes for parameters, and a minimal concrete class for placeholders (symbolic angles that can solely be substituted, and that cannot appear in computation). The sympy part is implemented as a plugin in the |
This commit implements TeamGraphix#158 (comment) Sympy plugin is implemented in https://github.com/thierry-martinez/graphix-symbolic/tree/sympy
b74c594
to
784dd34
Compare
This commit is yet another tentative to implement parameterized measurement patterns, to fulfill issue TeamGraphix#45 (previous tentative: TeamGraphix#68). This commit adds two methods to the class `Pattern`: - `is_parameterized()` returns True if there is at least one measurement angle that is not just an instance of numbers.Number: indeed, a parameterized pattern is a pattern where at least one measurement angle is an expression that is not a number, typically an instance of `sympy.Expr` (but we don't force to choose sympy here). - `subs(variable, substitute)` returns a copy of the pattern where occurrences of the given variable in measurement angles are substituted by the given value. Substitution is performed by calling the method `subs` on measurement angles, if the method exists, which is the case in particular for `sympy.Expr`. If the substitution returns a number, this number is coerced to `float`, to get numbers that implement the full number protocol (in particular, sympy numbers don't implement `cos`).
`parameter.py` is inspired by TeamGraphix#68 but is split in Parameter and ParameterExpression.
@thierry-martinez |
I added missing |
I re-reviewed you code and felt that the whole logic of |
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.
WIP: May be updated later.
Suggested by EarlMilktea: TeamGraphix#158 (comment)
Suggested by EarlMilktea: TeamGraphix#158 (comment)
Suggested by EarlMilktea: TeamGraphix#158 (comment)
Suggested by EarlMilktea: TeamGraphix#158 (comment)
Suggested by EarlMilktea: TeamGraphix#158 (comment)
This partially reverts commit 9f97fda.
These abstract methods were declared in `Expression` and raised an exception in `AffineExpression`. These methods are required for simulation, therefore they will still be implemented in parameters with support for symbolic computation, but we can just rely on duck-typing there.
This flag allows the user to choose between np.complex128 or O data-types for matrices, the former being more efficient and the latter allowing symbolic computation.
@EarlMilktea I believe this is the direction we agreed on at the meeting in Paris. could you review this PR? |
@thierry-martinez (CC: @shinich1 ) I'm basically agree with your idea, but I still feel that this PR should be postponed until other TODOs are resolved, because...
It would make it very difficult to improve/assess the performance of the simulator if this PR were to be merged before simulator optimization/refactoring, because simulator optimization is basically the process of reducing Pythonic tasks (ex. using
I admit this PR somehow require |
This commit is yet another tentative to implement parameterized measurement patterns, to fulfill issue #45 (previous tentative: #68).
This commit adds two methods to the class
Pattern
:is_parameterized()
returns True if there is at least one measurement angle that is not just an instance of numbers.Number: indeed, a parameterized pattern is a pattern where at least one measurement angle is an expression that is not a number, typically an instance ofsympy.Expr
(but we don't force to choose sympy here).subs(variable, substitute)
returns a copy of the pattern where occurrences of the given variable in measurement angles are substituted by the given value. Substitution is performed by calling the methodsubs
on measurement angles, if the method exists, which is the case in particular forsympy.Expr
. If the substitution returns a number, this number is coerced tofloat
, to get numbers that implement the full number protocol (in particular, sympy numbers don't implementcos
).