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

Allow for suppressing warnings in NoiseModel.from_backend() #792

Merged
merged 4 commits into from
Jun 15, 2020

Conversation

nonhermitian
Copy link
Contributor

Summary

The larger devices always have one or more bad gates that trigger warnings. This allows for suppressing these.

Details and comments

@atilag
Copy link
Member

atilag commented Jun 15, 2020

One of the features we have with Python logging system, is that users can filter any Warning they want by doing:

import logging
class WarningFilter(logging.Filter):
    def filter(self, record):
        return not record.getMessage().startswith('Device model')

logger = logging.getLogger("models")
logger.addFilter(WarningFilter())

This will filter all messages starting with "Device model" string, in the models.py file.
If you don't really mind about the warnings at all, you can just disable them:

logging.disable(logging.WARNING)

@nonhermitian
Copy link
Contributor Author

Ok. But it is unclear what that has to do with the current PR that just extends similar functionality that is already in the code base, e.g.:

@nonhermitian
Copy link
Contributor Author

nonhermitian commented Jun 15, 2020

Ok, now I see, the above does do what I need since I am an interested in using this in a module.

Edited as it does not actually work.

@atilag
Copy link
Member

atilag commented Jun 15, 2020

So you pointed out to something that I call technical debt. We shall not couple logging behavior with function parameters, it does only increases coupling between these components and makes things harder to test.
This is the reason why loggers are singletons (unique global instances).

Ok, let's merge this if you find it useful.

@chriseclectic chriseclectic merged commit df0eb84 into Qiskit:master Jun 15, 2020
@chriseclectic chriseclectic added the Changelog: New Feature Include in the Added section of the changelog label Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the Added section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants