-
Notifications
You must be signed in to change notification settings - Fork 14
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
Hotfix for minus sign in DRAG shape #869
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Premise: this is in
eval
that is already replaced in 0.2, so if it's passing, I wouldn't care that much.[abcd]
matches any character within (once), and[abcd]+
matches one or more of occurrences of any characters in the list.Thus having twice
\d
(a digit) makes no sense.I assume
[...]
has been used in place of(...)
, that is just a group (so the elements inside have to be matched in the order they are written).\w
is a word character (i.e. a digit or letter or_
), and I don't see how you need that for the parameters (unless you were writing them as kwargs, but then you'd need also an=
), so it's essentially matching just digits, and we're lucky that[...]
is simply making it ignored (since\d
twice and\w
just means\w
, inside[]
, and it's going to match only digits).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 believe that the pattern was meant to match numbers, and not
,
, that are used as a separator.Thus the pattern should have been:
r"[+-]?\d+(\.\d*)?([eE][+-]?\d+)?"
I.e.:
+
or-
or none of them (but not both).
followed by zero or more digitse
(upper or lower case), with either+
or-
or none of them (but not both) and then one or more digitsI didn't test it, but if you want to confirm you can look for a float pattern, or just test yourself.
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.
However, since the idea is just parsing comma-separated float (or integers, that are float compatible), I'd suggest just the following:
Unless there are also booleans involved (for which you should try one or the other).
In any case, I'd convert to a programmatic parse (leveraging standard utilities) rather than using regexes...
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 for the summary @alecandido. I actually learnt several things from these comments (which I could most likely also find online, but thanks for summarizing). Generally the idea behind this PR was exactly
so I did a fix that required the minimal effort (and time) and since both pytests and the hardware check seemed to work, I didn't care much more.
Also, note
qibolab/src/qibolab/pulses.py
Line 222 in c6945e6
which probably means that it is known that the current approach is not robust. Also, none of these approaches will work for the
Custom
shape.Indeed this is cleaner, however I think some additional manipulations are needed, because
value
also contains the name of the shape. For examplevalue
may beDrag(5, 0.02)
, so we would first need to extract5, 0.02
(using regex or some other string gymnastics) and then split.Again, given that this will be irrelevant pretty soon (and also none of these approaches is acceptable for
Custom
), I would leave as it is, and merge if someone else confirms it fixes the issue in the qibocal discussion.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 thought that
value
was only the inside of parentheses, since parentheses otherwise you would match the name as well (but, well, maybe that's what it was desired).In that case, you could split it in two, and match the name and parameters, and then parse the parameters separately.
Something like:
(to be tested, I just wrote it in GitHub).
And yes, not even this one would work for the
Custom
, but definitely, I wouldn't solve the problem at this level now. And if it's working for what you need, just keep it as it is.