# Suppress Warnings

I wish to know how to suppress the following warning obtained on qiskit when I try to add two different types of noise to a qubit

WARNING: quantum error already exists for instruction "u2" on qubits [0] , appending additional error.


I know that some warnings can be suppressed with

import warnings
warnings.filterwarnings('ignore', category=DeprecationWarning)


but I do not know what category my warning is contained in. I would also like to know if I can access somewhere all the different warning categories. Additionally trying

import warnings
warnings.filterwarnings('ignore')


to suppress all warnings does not help.

• do you mind adding a code example? Oct 19 '20 at 1:33

Qiskit's NoiseModel class processes warnings through a logger from the logging package, not through the warnings package, so suppressing warnings as in other answers won't help.

However, each method in NoiseModel provides a warnings parameter; it defaults to True but you can set it to False to prevent the warnings from being logged.

Example: myNoiseModel.add_quantum_error(..., warnings=False)

You don't need to provide a category to silence all of the warnings:

import warnings
warnings.filterwarnings('ignore')

• Hi, thanks but I tried this and nothing changes. I have updated the question to include this. Have you any other suggestions?
– LOC
Oct 18 '20 at 22:01

I don't know if this help at all but in term of warning categories, I used ?? warnings and found a few other types:

category=PendingDeprecationWarning
category=ImportWarning
category=ResourceWarning


I also see a question related to warning to Qiskit here. It is not the same as what you are asking but hopefully it will help somehow.