diff --git a/doc/development/deprecations.rst b/doc/development/deprecations.rst index 91c57b78429..af7c0e0c099 100644 --- a/doc/development/deprecations.rst +++ b/doc/development/deprecations.rst @@ -58,15 +58,15 @@ Other deprecations - Deprecated in v0.36 - Will be removed in v0.37 +Completed deprecation cycles +---------------------------- + * The ``qml.load`` function is a general-purpose way to convert circuits into PennyLane from other - libraries. It is being deprecated in favour of the more specific functions ``from_qiskit``, + libraries. It has been deprecated in favour of the more specific functions ``from_qiskit``, ``from_qasm``, etc. - Deprecated in v0.36 - - Will be removed in v0.37 - -Completed deprecation cycles ----------------------------- + - Removed in v0.37 * ``single_tape_transform``, ``batch_transform``, ``qfunc_transform``, ``op_transform``, ``gradient_transform`` and ``hessian_transform`` are deprecated. Instead switch to using the new diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index ad7395f90b5..8b9ecbbc6e4 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -65,6 +65,9 @@

Breaking changes 💔

+* The ``qml.load`` has been deprecated in favour of the more specific functions. + [(#...)](https://github.com/PennyLaneAI/pennylane/pull/...) +

Deprecations 👋

Documentation 📝

diff --git a/pennylane/io.py b/pennylane/io.py index c61b320a769..c0abab7bfe9 100644 --- a/pennylane/io.py +++ b/pennylane/io.py @@ -40,71 +40,6 @@ plugin_converters = {entry.name: entry for entry in __plugin_devices} -def load(quantum_circuit_object, format: str, **load_kwargs): - r"""Load external quantum assembly and quantum circuits from supported frameworks - into PennyLane templates. - - .. warning:: - ``qml.load`` is deprecated. Instead, please use the functions outlined in the - :ref:`Importing Circuits ` quickstart guide, such as ``qml.from_qiskit``. - - .. note:: - - For more details on which formats are supported - please consult the corresponding plugin documentation: - https://pennylane.ai/plugins.html - - **Example:** - - >>> qc = qiskit.QuantumCircuit(2) - >>> qc.rz(0.543, [0]) - >>> qc.cx(0, 1) - >>> my_circuit = qml.load(qc, format='qiskit') - - 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: - quantum_circuit_object: the quantum circuit that will be converted - to a PennyLane template - format (str): the format of the quantum circuit object to convert from - **load_kwargs: keyword arguments to pass when converting the quantum circuit - using the plugin. See below for details about supported keyword arguments. - - Keyword Args: - measurements (list[MeasurementProcess]): the list of PennyLane measurements that - overrides the terminal measurements that may be present in the imput circuit. - Currently, only supported for Qiskit's `QuantumCircuit `_. - - Returns: - function: the PennyLane template created from the quantum circuit object - - """ - - _format = "pyquil" if format == "pyquil_program" else format - warnings.warn( - f"qml.load() is deprecated. Instead, please use the more specific qml.from_{_format}()", - qml.PennyLaneDeprecationWarning, - ) - - if format in plugin_converters: - # loads the plugin load function - plugin_converter = plugin_converters[format].load() - # calls the load function of the converter on the quantum circuit object - return plugin_converter(quantum_circuit_object, **load_kwargs) - - raise ValueError( - "Converter does not exist. Make sure the required plugin is installed " - "and supports conversion." - ) - - def from_qiskit(quantum_circuit, measurements=None): r"""Converts a Qiskit `QuantumCircuit `_ into a PennyLane :ref:`quantum function `. diff --git a/tests/test_io.py b/tests/test_io.py index 4a919da6204..1f110a6f286 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -73,13 +73,6 @@ def mock_plugin_converters_fixture(monkeypatch): class TestLoad: """Test that the convenience load functions access the correct entrypoint.""" - def test_load_is_deprecated(self, monkeypatch): - """Test that qml.load 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"): - _ = qml.load("test", format="qiskit") - @pytest.mark.parametrize( "method, entry_point_name", [(qml.from_qiskit, "qiskit"), (qml.from_qiskit_op, "qiskit_op")],