diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 9b72ef04af2..f76eb360bd1 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -701,7 +701,7 @@ fully differentiable. of shots is set explicitly. * If creating a QNode from a quantum function with an argument named `shots`, - a `DeprecationWarning` is raised, warning the user that this is a reserved + a `UserWarning` is raised, warning the user that this is a reserved argument to change the number of shots on a per-call basis. [(#1075)](https://github.com/PennyLaneAI/pennylane/pull/1075) diff --git a/pennylane/_qubit_device.py b/pennylane/_qubit_device.py index 93d38a07eee..1d093252ecf 100644 --- a/pennylane/_qubit_device.py +++ b/pennylane/_qubit_device.py @@ -475,7 +475,7 @@ def sample_basis_states(self, number_of_states, state_probability): "The number of shots has to be explicitly set on the device " "when using sample-based measurements. Since no shots are specified, " "a default of 1000 shots is used.", - DeprecationWarning, + UserWarning, ) shots = self.shots or 1000 diff --git a/pennylane/devices/default_qubit_jax.py b/pennylane/devices/default_qubit_jax.py index ef20d8669df..e50997381e5 100644 --- a/pennylane/devices/default_qubit_jax.py +++ b/pennylane/devices/default_qubit_jax.py @@ -247,8 +247,8 @@ def sample_basis_states(self, number_of_states, state_probability): "The number of shots has to be explicitly set on the jax device " "when using sample-based measurements. Since no shots are specified, " "a default of 1000 shots is used.\n" - "This warning will replaced with an error in a future release.", - DeprecationWarning, + "This warning will be replaced with an error in a future release.", + UserWarning, ) shots = self.shots or 1000 diff --git a/pennylane/qnode.py b/pennylane/qnode.py index abf4e5505b1..eab6d06b479 100644 --- a/pennylane/qnode.py +++ b/pennylane/qnode.py @@ -157,7 +157,7 @@ def __init__( "Detected 'shots' as an argument to the given quantum function. " "The 'shots' argument name is reserved for overriding the number of shots " "taken by the device. Its use outside of this context should be avoided.", - DeprecationWarning, + UserWarning, ) self._qfunc_uses_shots_arg = True else: diff --git a/pennylane/templates/embeddings/amplitude.py b/pennylane/templates/embeddings/amplitude.py index 4c750c8de74..4a0eeb71b15 100644 --- a/pennylane/templates/embeddings/amplitude.py +++ b/pennylane/templates/embeddings/amplitude.py @@ -131,7 +131,7 @@ def __init__(self, features, wires, pad_with=None, normalize=False, pad=None, do if pad is not None: warnings.warn( "The pad argument will be replaced by the pad_with option in future versions of PennyLane.", - PendingDeprecationWarning, + UserWarning, ) if pad_with is None: pad_with = pad diff --git a/pennylane/vqe/vqe.py b/pennylane/vqe/vqe.py index fe129230806..66e479b3b3d 100644 --- a/pennylane/vqe/vqe.py +++ b/pennylane/vqe/vqe.py @@ -547,7 +547,7 @@ class VQECost(ExpvalCost): def __init__(self, *args, **kwargs): warnings.warn( "Use of VQECost is deprecated and should be replaced with ExpvalCost", - DeprecationWarning, + UserWarning, 2, ) super().__init__(*args, **kwargs) diff --git a/tests/devices/test_default_qubit_jax.py b/tests/devices/test_default_qubit_jax.py index a214d89014a..83afe2ea957 100644 --- a/tests/devices/test_default_qubit_jax.py +++ b/tests/devices/test_default_qubit_jax.py @@ -182,7 +182,9 @@ def test_sampling_analytic_mode(self): def circuit(): return qml.sample(qml.PauliZ(wires=0)) - with pytest.deprecated_call(): + with pytest.warns( + UserWarning, match="The number of shots has to be explicitly set on the jax device" + ): res = circuit() assert len(res) == 1000 diff --git a/tests/tape/test_qnode.py b/tests/tape/test_qnode.py index 1ed5d3658a5..1cb3b2415ed 100644 --- a/tests/tape/test_qnode.py +++ b/tests/tape/test_qnode.py @@ -883,7 +883,7 @@ def circuit(a, shots=0): return qml.sample(qml.PauliZ(wires=0)) with pytest.warns( - DeprecationWarning, match="The 'shots' argument name is reserved for overriding" + UserWarning, match="The 'shots' argument name is reserved for overriding" ): circuit = qml.QNode(circuit, dev) @@ -909,7 +909,7 @@ def circuit(a, shots): # assert that warning is still raised with pytest.warns( - DeprecationWarning, match="The 'shots' argument name is reserved for overriding" + UserWarning, match="The 'shots' argument name is reserved for overriding" ): circuit = qml.QNode(circuit, dev) diff --git a/tests/templates/test_embeddings/test_amplitude.py b/tests/templates/test_embeddings/test_amplitude.py index baf265d363b..1b53a3650bd 100644 --- a/tests/templates/test_embeddings/test_amplitude.py +++ b/tests/templates/test_embeddings/test_amplitude.py @@ -239,7 +239,7 @@ def circuit(x=None): return qml.expval(qml.PauliZ(0)) with pytest.warns( - PendingDeprecationWarning, + UserWarning, match="will be replaced by the pad_with option in future versions", ): circuit(x=inputs) diff --git a/tests/test_qubit_device.py b/tests/test_qubit_device.py index 8973a4ec185..cd9473a8075 100644 --- a/tests/test_qubit_device.py +++ b/tests/test_qubit_device.py @@ -414,7 +414,7 @@ def test_raises_deprecation_warning(self, mock_qubit_device, monkeypatch): state_probs = [0.1, 0.2, 0.3, 0.4] with pytest.warns( - DeprecationWarning, match="The number of shots has to be explicitly set on the device" + UserWarning, match="The number of shots has to be explicitly set on the device" ): dev.sample_basis_states(number_of_states, state_probs) diff --git a/tests/test_vqe.py b/tests/test_vqe.py index 42a32652340..dd395f2f204 100644 --- a/tests/test_vqe.py +++ b/tests/test_vqe.py @@ -1216,13 +1216,13 @@ def test_all_interfaces_gradient_agree(self, tol): def test_vqe_cost(): - """Tests that VQECost raises a DeprecationWarning but otherwise behaves as ExpvalCost""" + """Tests that VQECost raises a UserWarning but otherwise behaves as ExpvalCost""" h = qml.Hamiltonian([1], [qml.PauliZ(0)]) dev = qml.device("default.qubit", wires=1) ansatz = qml.templates.StronglyEntanglingLayers - with pytest.warns(DeprecationWarning, match="Use of VQECost is deprecated"): + with pytest.warns(UserWarning, match="Use of VQECost is deprecated"): cost = qml.VQECost(ansatz, h, dev) assert isinstance(cost, qml.ExpvalCost)