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

Fix guess.rb_decay not to raise an error against bad output (backport #1336) #1358

Closed
wants to merge 1 commit into from

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Jan 17, 2024

This is an automatic backport of pull request #1336 done by Mergify.


Mergify commands and options

More conditions and actions can be found in the documentation.

You can also trigger Mergify actions by commenting on this pull request:

  • @Mergifyio refresh will re-evaluate the rules
  • @Mergifyio rebase will rebase this PR on its base branch
  • @Mergifyio update will merge the base branch into this PR
  • @Mergifyio backport <destination> will backport this PR on <destination> branch

Additionally, on Mergify dashboard you can:

  • look at your merge queues
  • generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com

### Summary
Fixed a bug in `guess.rb_decay` where it unintentionally raises an error
if all y values are below the b value (that can happen in experiments on
real devices).

### Details and comments
Changed to return `0` as the initial guess of the decay parameter when
all y values are below the b value, instead of raising an IndexError
like
```
File "/qiskit-experiments/qiskit_experiments/curve_analysis/guess.py", line 406, in rb_decay
    return ((y[0] - b) / a) ** (1 / x[0])
IndexError: index 0 is out of bounds for axis 0 with size 0
```

An alternative solution might be explicitly raising a QiskitError. But,
if we want to raise an error for too bad data to fit, I think the fitter
(not rb_decay) should raise an error because it should not be due to the
failure of guessing initial parameter (that is the object of `rb_decay`
function.

---------

Co-authored-by: Naoki Kanazawa <[email protected]>
(cherry picked from commit 0937bb4)
@wshanks
Copy link
Collaborator

wshanks commented Jan 19, 2024

I think we are not maintaining the 0.5 branch any longer since 0.6 will be released soon.

@wshanks wshanks closed this Jan 19, 2024
@mergify mergify bot deleted the mergify/bp/stable/0.5/pr-1336 branch January 19, 2024 18:44
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.

2 participants