From f06f642976b554a0663e4cce7622758c20215e3e Mon Sep 17 00:00:00 2001 From: Simon Humpohl Date: Thu, 20 Jun 2024 16:23:49 +0200 Subject: [PATCH 1/3] Remove qctoolkit alias --- changes.d/841.removal | 1 + qctoolkit/__init__.py | 34 ---------------------------------- tests/qctoolkit_alias_tests.py | 16 ---------------- 3 files changed, 1 insertion(+), 50 deletions(-) create mode 100644 changes.d/841.removal delete mode 100644 qctoolkit/__init__.py delete mode 100644 tests/qctoolkit_alias_tests.py diff --git a/changes.d/841.removal b/changes.d/841.removal new file mode 100644 index 00000000..9ae7d7ac --- /dev/null +++ b/changes.d/841.removal @@ -0,0 +1 @@ +Remove qctoolkit alias for qupulse. \ No newline at end of file diff --git a/qctoolkit/__init__.py b/qctoolkit/__init__.py deleted file mode 100644 index 208c2083..00000000 --- a/qctoolkit/__init__.py +++ /dev/null @@ -1,34 +0,0 @@ -# SPDX-FileCopyrightText: 2014-2024 Quantum Technology Group and Chair of Software Engineering, RWTH Aachen University -# -# SPDX-License-Identifier: GPL-3.0-or-later - -"""This is a (hopefully temporary) alias package to not break existing code. If you know a better way please change""" -import sys -import re -import pkgutil -import importlib -import warnings -import logging - -qupulse = importlib.import_module('qupulse') -sys.modules[__name__] = qupulse - -aliased = {} - -""" import all subpackages and submodules to assert that -from qupulse.pulse import TablePT as T1 -from qctoolkit.pulse import TablePT as T2 -assert T1 is T2 -""" -for _, name, ispkg in pkgutil.walk_packages(qupulse.__path__, 'qupulse.'): - alias = re.sub('^qupulse.', '%s.' % __name__, name) - - try: - imported = importlib.import_module(name) - except ImportError: - warnings.warn('Could not import %s. The alias %s was NOT created.' % (name, alias)) - continue - sys.modules[alias] = imported - aliased[alias] = name - -logging.info('Created module aliases:', aliased) diff --git a/tests/qctoolkit_alias_tests.py b/tests/qctoolkit_alias_tests.py deleted file mode 100644 index 1ae44677..00000000 --- a/tests/qctoolkit_alias_tests.py +++ /dev/null @@ -1,16 +0,0 @@ -import unittest - - -class QctoolkitAliasTest(unittest.TestCase): - def test_alias(self): - import qctoolkit.pulses - import qupulse.pulses - - self.assertIs(qctoolkit.pulses, qupulse.pulses) - self.assertIs(qctoolkit.pulses.TablePT, qupulse.pulses.TablePT) - - def test_class_identity(self): - from qupulse.program.loop import Loop as Loop_qu - from qctoolkit.program.loop import Loop as Loop_qc - - self.assertIs(Loop_qc, Loop_qu) From b2b64252d6c133d2c9b10bd027035fe22bbfa5ec Mon Sep 17 00:00:00 2001 From: Simon Humpohl Date: Fri, 21 Jun 2024 10:29:12 +0200 Subject: [PATCH 2/3] Remove qctoolkit test trigger --- .github/workflows/pythontest.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pythontest.yaml b/.github/workflows/pythontest.yaml index 38cadd54..032e28e6 100644 --- a/.github/workflows/pythontest.yaml +++ b/.github/workflows/pythontest.yaml @@ -11,7 +11,6 @@ on: - '**' paths: - 'qupulse/**y' - - 'qctoolkit/**' - 'tests/**' - 'setup.*' - 'pyproject.toml' From 4c92abadf58ae22556855d55689fdbc5d49672b5 Mon Sep 17 00:00:00 2001 From: Simon Humpohl Date: Fri, 21 Jun 2024 10:34:53 +0200 Subject: [PATCH 3/3] Adjust error on disabled qctoolkit import --- tests/serialization_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/serialization_tests.py b/tests/serialization_tests.py index 537e642c..a49ae7e6 100644 --- a/tests/serialization_tests.py +++ b/tests/serialization_tests.py @@ -736,7 +736,7 @@ def my_callable(): self.assertIs(finder['qctoolkit.asd'], my_callable) finder.qctoolkit_alias = False - with self.assertRaises(KeyError): + with self.assertRaises(ModuleNotFoundError): finder['qctoolkit.asd']