diff --git a/doc/development/deprecations.rst b/doc/development/deprecations.rst index bc0badd3f13..35936e6a6af 100644 --- a/doc/development/deprecations.rst +++ b/doc/development/deprecations.rst @@ -50,16 +50,16 @@ Other deprecations - Deprecated in v0.36 - Will be removed in v0.37 -* ``qml.from_qasm_file`` is deprecated. Instead, the user can open the file and then load its content using ``qml.from_qasm``. +Completed deprecation cycles +---------------------------- + +* ``qml.from_qasm_file`` has been removed. Instead, the user can open the file and then load its content using ``qml.from_qasm``. >>> with open("test.qasm", "r") as f: ... circuit = qml.from_qasm(f.read()) - Deprecated in v0.36 - - Will be removed in v0.37 - -Completed deprecation cycles ----------------------------- + - Removed in v0.37 * The ``qml.load`` function is a general-purpose way to convert circuits into PennyLane from other libraries. It has been removed in favour of the more specific functions ``from_qiskit``, ``from_qasm``, etc. diff --git a/doc/introduction/circuits.rst b/doc/introduction/circuits.rst index 2d4136a0fe3..bb637fc1f61 100644 --- a/doc/introduction/circuits.rst +++ b/doc/introduction/circuits.rst @@ -325,7 +325,6 @@ be loaded by using the following functions: ~pennylane.from_qiskit ~pennylane.from_qasm - ~pennylane.from_qasm_file ~pennylane.from_pyquil ~pennylane.from_quil ~pennylane.from_quil_file diff --git a/doc/introduction/importing_workflows.rst b/doc/introduction/importing_workflows.rst index dab8ff3ea86..01f24b23946 100644 --- a/doc/introduction/importing_workflows.rst +++ b/doc/introduction/importing_workflows.rst @@ -36,7 +36,6 @@ differentiate and optimize the circuit using :ref:`quantum-specific optimizers < ~pennylane.from_pyquil ~pennylane.from_qasm - ~pennylane.from_qasm_file ~pennylane.from_qiskit ~pennylane.from_quil ~pennylane.from_quil_file diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index 5cab7b9fc65..0b381609d9a 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -65,6 +65,9 @@

Breaking changes 💔

+* ``qml.from_qasm_file`` has been removed. The user can open files and load their content using `qml.from_qasm`. + [(#5659)](https://github.com/PennyLaneAI/pennylane/pull/5659) + * ``qml.load`` has been removed in favour of more specific functions, such as ``qml.from_qiskit``, etc. [(#5654)](https://github.com/PennyLaneAI/pennylane/pull/5654) diff --git a/pennylane/io.py b/pennylane/io.py index c0abab7bfe9..088477b3b59 100644 --- a/pennylane/io.py +++ b/pennylane/io.py @@ -15,13 +15,10 @@ This module contains functions to load circuits from other frameworks as PennyLane templates. """ -import warnings from collections import defaultdict from importlib import metadata from sys import version_info -import pennylane as qml - # Error message to show when the PennyLane-Qiskit plugin is required but missing. _MISSING_QISKIT_PLUGIN_MESSAGE = ( "Conversion from Qiskit requires the PennyLane-Qiskit plugin. " @@ -450,43 +447,6 @@ def from_qasm(quantum_circuit: str): return plugin_converter(quantum_circuit) -def from_qasm_file(qasm_filename: str): - """Loads quantum circuits from a QASM file using the converter in the - PennyLane-Qiskit plugin. - - **Example:** - - >>> my_circuit = qml.from_qasm_file("hadamard_circuit.qasm") - - The ``my_circuit`` template can now be used within QNodes, as a - two-wire quantum template. - - >>> @qml.qnode(dev) - >>> def circuit(x): - >>> qml.RX(x, wires=1) - >>> my_circuit(wires=(1, 0)) - >>> return qml.expval(qml.Z(0)) - - Args: - qasm_filename (str): path to a QASM file containing a valid quantum circuit - - Returns: - function: the PennyLane template created based on the QASM file - - .. warning:: - qml.from_qasm_file is deprecated and will be removed in a future release. - Please use qml.from_qasm instead. - - """ - warnings.warn( - "qml.from_qasm_file is deprecated and will be removed in a future release. " - "Please use qml.from_qasm instead.", - qml.PennyLaneDeprecationWarning, - ) - plugin_converter = plugin_converters["qasm_file"].load() - return plugin_converter(qasm_filename) - - def from_pyquil(pyquil_program): """Loads pyQuil Program objects by using the converter in the PennyLane-Rigetti plugin. diff --git a/tests/test_io.py b/tests/test_io.py index 1f110a6f286..489a5509fa9 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -14,7 +14,7 @@ """ Unit tests for the :mod:`pennylane.io` module. """ -from unittest.mock import Mock, mock_open, patch +from unittest.mock import Mock import pytest @@ -109,14 +109,6 @@ def test_qiskit_converter_load_fails(self, monkeypatch, method, entry_point_name with pytest.raises(ValueError, match=r"Some Other Error"): method("Test") - def test_from_qasm_file_deprecated(self, monkeypatch): - """Tests that qml.from_qasm_file is deprecated.""" - mock_converter_dict = {entry: MockPluginConverter(entry) for entry in load_entry_points} - monkeypatch.setattr(qml.io, "plugin_converters", mock_converter_dict) - with pytest.warns(qml.PennyLaneDeprecationWarning, match="deprecated"): - with patch("builtins.open", mock_open(read_data="Test")): - _ = qml.from_qasm_file("test.qasm") - @pytest.mark.parametrize( "method, entry_point_name", [