From 405b57fde34f1fabb83e06dc832fac6e58fcff33 Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sun, 12 Mar 2023 21:42:52 +0100 Subject: [PATCH 1/9] Update version to 0.2.0.dev. --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 7b32b52..8f91ec1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.0.dev +0.2.0.dev From 1cced6af83b43742395f96eb902f97b341fcb701 Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sun, 12 Mar 2023 21:45:22 +0100 Subject: [PATCH 2/9] Apply black checks to doc/conf.py and setup.py. --- .github/workflows/black.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 5743566..f3e7342 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -10,4 +10,4 @@ jobs: - uses: psf/black@stable with: options: "--check --diff" - src: "./src ./tests" + src: "./src ./tests ./doc/conf.py ./setup.py" From a2841ec4a487373a8395eaba2a9d341cba50d24e Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sun, 12 Mar 2023 21:45:45 +0100 Subject: [PATCH 3/9] Format doc/conf.py and setup.py with black. --- doc/conf.py | 54 ++++++++++++++++++++++++++--------------------------- setup.py | 38 ++++++++++++++++++++----------------- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index d169d33..458c43f 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -12,23 +12,21 @@ import os import pathlib import sys -sys.path.insert(0, os.path.abspath('.')) + +sys.path.insert(0, os.path.abspath(".")) # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = 'qutip_qtrl' -copyright = '2011-2023, QuTiP Community' -author = 'QuTiP Community' +project = "qutip_qtrl" +copyright = "2011-2023, QuTiP Community" +author = "QuTiP Community" def qutip_qtrl_version(): - """ Retrieve the qutip-qtrl version from ``../../VERSION``. - """ + """Retrieve the qutip-qtrl version from ``../../VERSION``.""" src_folder_root = pathlib.Path(__file__).absolute().parent.parent - version = src_folder_root.joinpath( - "VERSION" - ).read_text().strip() + version = src_folder_root.joinpath("VERSION").read_text().strip() return version @@ -41,28 +39,28 @@ def qutip_qtrl_version(): # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = [ - 'sphinx.ext.mathjax', - 'matplotlib.sphinxext.plot_directive', - 'sphinx.ext.autodoc', - 'sphinx.ext.autosummary', - 'sphinx.ext.doctest', - 'sphinx.ext.todo', - 'numpydoc', - 'sphinx.ext.extlinks', - 'sphinx.ext.viewcode', - 'sphinx.ext.ifconfig', - 'sphinx.ext.napoleon', - 'sphinxcontrib.bibtex', - 'sphinx.ext.intersphinx', + "sphinx.ext.mathjax", + "matplotlib.sphinxext.plot_directive", + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.doctest", + "sphinx.ext.todo", + "numpydoc", + "sphinx.ext.extlinks", + "sphinx.ext.viewcode", + "sphinx.ext.ifconfig", + "sphinx.ext.napoleon", + "sphinxcontrib.bibtex", + "sphinx.ext.intersphinx", ] -templates_path = ['_templates'] -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +templates_path = ["_templates"] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -html_theme = 'sphinx_rtd_theme' +html_theme = "sphinx_rtd_theme" html_static_path = [] # -- Options for numpydoc --------------------------------------- @@ -82,11 +80,11 @@ def qutip_qtrl_version(): # -- Options for biblatex --------------------------------------- -bibtex_bibfiles = ['references.bib'] -bibtex_default_style = 'unsrt' +bibtex_bibfiles = ["references.bib"] +bibtex_default_style = "unsrt" # -- Options for intersphinx --------------------------------------- intersphinx_mapping = { - 'qutip': ('https://qutip.org/docs/latest/', None), + "qutip": ("https://qutip.org/docs/latest/", None), } diff --git a/setup.py b/setup.py index 1f490a4..f4b2676 100755 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ def process_options(): Is this a release build (True) or a local development build (False) """ options = {} - options['rootdir'] = os.path.dirname(os.path.abspath(__file__)) + options["rootdir"] = os.path.dirname(os.path.abspath(__file__)) options = _determine_version(options) return options @@ -38,21 +38,22 @@ def _determine_version(options): We do that here rather than in setup.cfg so we can apply the local versioning number as well. """ - version_filename = os.path.join(options['rootdir'], 'VERSION') + version_filename = os.path.join(options["rootdir"], "VERSION") with open(version_filename, "r") as version_file: version_string = version_file.read().strip() version = packaging.version.Version(version_string) - options['short_version'] = str(version.public) - options['release'] = not version.is_devrelease - if not options['release']: + options["short_version"] = str(version.public) + options["release"] = not version.is_devrelease + if not options["release"]: # Put the version string into canonical form, if it wasn't already. version_string = str(version) version_string += "+" try: git_out = subprocess.run( - ('git', 'rev-parse', '--verify', '--short=7', 'HEAD'), + ("git", "rev-parse", "--verify", "--short=7", "HEAD"), check=True, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, ) git_hash = git_out.stdout.decode(sys.stdout.encoding).strip() version_string += git_hash or "nogit" @@ -62,7 +63,7 @@ def _determine_version(options): # or a permission error). except (subprocess.CalledProcessError, OSError): version_string += "nogit" - options['version'] = version_string + options["version"] = version_string return options @@ -73,14 +74,17 @@ def create_version_py_file(options): overwrite an existing file at that location. """ filename = os.path.join( - options['rootdir'], 'src', 'qutip_qtrl', 'version.py') - content = "\n".join([ - "# This file is automatically generated by qutip-qtrl's setup.py.", - f"short_version = '{options['short_version']}'", - f"version = '{options['version']}'", - f"release = {options['release']}", - ]) - with open(filename, 'w') as file: + options["rootdir"], "src", "qutip_qtrl", "version.py" + ) + content = "\n".join( + [ + "# This file is automatically generated by qutip-qtrl's setup.py.", + f"short_version = '{options['short_version']}'", + f"version = '{options['version']}'", + f"release = {options['release']}", + ] + ) + with open(filename, "w") as file: print(content, file=file) @@ -90,5 +94,5 @@ def create_version_py_file(options): # Most of the kwargs to setup are defined in setup.cfg; the only ones we # keep here are ones that we have done some compile-time processing on. setup( - version=options['version'], + version=options["version"], ) From 07c0e2f482bd8d58c75a478cec59ed6358e53f23 Mon Sep 17 00:00:00 2001 From: Eric Giguere Date: Fri, 31 Mar 2023 14:27:17 -0400 Subject: [PATCH 4/9] Migrate logging_utils --- src/qutip_qtrl/dynamics.py | 2 +- src/qutip_qtrl/fidcomp.py | 2 +- src/qutip_qtrl/loadparams.py | 2 +- src/qutip_qtrl/logging_utils.py | 109 ++++++++++++++++++++++++++++++++ src/qutip_qtrl/optimizer.py | 2 +- src/qutip_qtrl/propcomp.py | 2 +- src/qutip_qtrl/pulsegen.py | 2 +- src/qutip_qtrl/pulseoptim.py | 2 +- src/qutip_qtrl/tslotcomp.py | 2 +- 9 files changed, 117 insertions(+), 8 deletions(-) create mode 100644 src/qutip_qtrl/logging_utils.py diff --git a/src/qutip_qtrl/dynamics.py b/src/qutip_qtrl/dynamics.py index b477e9f..338dc24 100644 --- a/src/qutip_qtrl/dynamics.py +++ b/src/qutip_qtrl/dynamics.py @@ -43,7 +43,7 @@ import qutip_qtrl.dump as qtrldump # QuTiP logging -import qutip.logging_utils as logging +import qutip_qtrl.logging_utils as logging logger = logging.get_logger() diff --git a/src/qutip_qtrl/fidcomp.py b/src/qutip_qtrl/fidcomp.py index 83c10e6..f01a897 100644 --- a/src/qutip_qtrl/fidcomp.py +++ b/src/qutip_qtrl/fidcomp.py @@ -36,7 +36,7 @@ import qutip_qtrl.errors as errors # QuTiP logging -import qutip.logging_utils as logging +import qutip_qtrl.logging_utils as logging logger = logging.get_logger() diff --git a/src/qutip_qtrl/loadparams.py b/src/qutip_qtrl/loadparams.py index 832110f..988278b 100644 --- a/src/qutip_qtrl/loadparams.py +++ b/src/qutip_qtrl/loadparams.py @@ -19,7 +19,7 @@ # QuTiP logging from qutip import Qobj -import qutip.logging_utils as logging +import qutip_qtrl.logging_utils as logging logger = logging.get_logger() diff --git a/src/qutip_qtrl/logging_utils.py b/src/qutip_qtrl/logging_utils.py new file mode 100644 index 0000000..c91b380 --- /dev/null +++ b/src/qutip_qtrl/logging_utils.py @@ -0,0 +1,109 @@ +""" +This module contains internal-use functions for configuring and writing to +debug logs, using Python's internal logging functionality by default. +""" + +# IMPORTS +from __future__ import absolute_import +import inspect +import logging + +from qutip.settings import settings + +# EXPORTS +NOTSET = logging.NOTSET +DEBUG_INTENSE = logging.DEBUG - 4 +DEBUG_VERBOSE = logging.DEBUG - 2 +DEBUG = logging.DEBUG +INFO = logging.INFO +WARN = logging.WARN +ERROR = logging.ERROR +CRITICAL = logging.CRITICAL + +__all__ = ['get_logger'] + +# META-LOGGING + +metalogger = logging.getLogger(__name__) +metalogger.addHandler(logging.NullHandler()) + + +# FUNCTIONS + +def get_logger(name=None): + """ + Returns a Python logging object with handlers configured + in accordance with ~/.qutiprc. By default, this will do + something sensible to integrate with IPython when running + in that environment, and will print to stdout otherwise. + + Note that this function uses a bit of magic, and thus should + not be considered part of the QuTiP API. Rather, this function + is for internal use only. + + Parameters + ---------- + + name : str + Name of the logger to be created. If not passed, + the name will automatically be set to the name of the + calling module. + """ + if name is None: + try: + calling_frame = inspect.stack()[1][0] + calling_module = inspect.getmodule(calling_frame) + name = (calling_module.__name__ + if calling_module is not None else '') + + except Exception: + metalogger.warn('Error creating logger.', exc_info=1) + name = '' + + logger = logging.getLogger(name) + + policy = settings.log_handler + + if policy == 'default': + # Let's try to see if we're in IPython mode. + policy = 'basic' if settings.ipython else 'stream' + + metalogger.debug("Creating logger for {} with policy {}.".format( + name, policy + )) + + if policy == 'basic': + # Add no handlers, just let basicConfig do it all. + # This is nice for working with IPython, since + # it will use its own handlers instead of our StreamHandler + # below. + if settings.debug: + logging.basicConfig(level=logging.DEBUG) + else: + logging.basicConfig() + + elif policy == 'stream': + formatter = logging.Formatter( + '[%(asctime)s] %(name)s[%(process)s]: ' + '%(funcName)s: %(levelname)s: %(message)s', + '%Y-%m-%d %H:%M:%S') + handler = logging.StreamHandler() + handler.setFormatter(formatter) + logger.addHandler(handler) + + # We're handling things here, so no propagation out. + logger.propagate = False + + elif policy == 'null': + # We need to add a NullHandler so that debugging works + # at all, but this policy leaves it to the user to + # make their own handlers. This is particularly useful + # for capturing to logfiles. + logger.addHandler(logging.NullHandler()) + + if settings.debug: + logger.setLevel(logging.DEBUG) + else: + logger.setLevel(logging.WARN) + + return logger diff --git a/src/qutip_qtrl/optimizer.py b/src/qutip_qtrl/optimizer.py index 9390f6e..85ec5ac 100644 --- a/src/qutip_qtrl/optimizer.py +++ b/src/qutip_qtrl/optimizer.py @@ -74,7 +74,7 @@ import qutip_qtrl.pulsegen as pulsegen import qutip_qtrl.dump as qtrldump -import qutip.logging_utils as logging +import qutip_qtrl.logging_utils as logging logger = logging.get_logger() diff --git a/src/qutip_qtrl/propcomp.py b/src/qutip_qtrl/propcomp.py index 31708ee..ee422fd 100644 --- a/src/qutip_qtrl/propcomp.py +++ b/src/qutip_qtrl/propcomp.py @@ -27,7 +27,7 @@ from qutip_qtrl import errors # QuTiP logging -import qutip.logging_utils as logging +import qutip_qtrl.logging_utils as logging logger = logging.get_logger() diff --git a/src/qutip_qtrl/pulsegen.py b/src/qutip_qtrl/pulsegen.py index 8d5146e..7b62da4 100644 --- a/src/qutip_qtrl/pulsegen.py +++ b/src/qutip_qtrl/pulsegen.py @@ -17,7 +17,7 @@ import qutip_qtrl.dynamics as dynamics import qutip_qtrl.errors as errors -import qutip.logging_utils as logging +import qutip_qtrl.logging_utils as logging logger = logging.get_logger() diff --git a/src/qutip_qtrl/pulseoptim.py b/src/qutip_qtrl/pulseoptim.py index 9a52f9d..095c4e6 100644 --- a/src/qutip_qtrl/pulseoptim.py +++ b/src/qutip_qtrl/pulseoptim.py @@ -71,7 +71,7 @@ import qutip_qtrl.fidcomp as fidcomp import qutip_qtrl.propcomp as propcomp import qutip_qtrl.pulsegen as pulsegen -import qutip.logging_utils as logging +import qutip_qtrl.logging_utils as logging logger = logging.get_logger() diff --git a/src/qutip_qtrl/tslotcomp.py b/src/qutip_qtrl/tslotcomp.py index 1b15c00..6b6f835 100644 --- a/src/qutip_qtrl/tslotcomp.py +++ b/src/qutip_qtrl/tslotcomp.py @@ -44,7 +44,7 @@ import qutip_qtrl.dump as qtrldump # QuTiP logging -import qutip.logging_utils as logging +import qutip_qtrl.logging_utils as logging logger = logging.get_logger() From f161b39fd30438a93230f8944daa1168321d1942 Mon Sep 17 00:00:00 2001 From: Eric Giguere Date: Mon, 3 Apr 2023 10:05:33 -0400 Subject: [PATCH 5/9] black logging --- src/qutip_qtrl/logging_utils.py | 37 +++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/qutip_qtrl/logging_utils.py b/src/qutip_qtrl/logging_utils.py index c91b380..76e768d 100644 --- a/src/qutip_qtrl/logging_utils.py +++ b/src/qutip_qtrl/logging_utils.py @@ -20,7 +20,7 @@ ERROR = logging.ERROR CRITICAL = logging.CRITICAL -__all__ = ['get_logger'] +__all__ = ["get_logger"] # META-LOGGING @@ -30,6 +30,7 @@ # FUNCTIONS + def get_logger(name=None): """ Returns a Python logging object with handlers configured @@ -53,26 +54,29 @@ def get_logger(name=None): try: calling_frame = inspect.stack()[1][0] calling_module = inspect.getmodule(calling_frame) - name = (calling_module.__name__ - if calling_module is not None else '') + name = ( + calling_module.__name__ + if calling_module is not None + else "" + ) except Exception: - metalogger.warn('Error creating logger.', exc_info=1) - name = '' + metalogger.warn("Error creating logger.", exc_info=1) + name = "" logger = logging.getLogger(name) policy = settings.log_handler - if policy == 'default': + if policy == "default": # Let's try to see if we're in IPython mode. - policy = 'basic' if settings.ipython else 'stream' + policy = "basic" if settings.ipython else "stream" - metalogger.debug("Creating logger for {} with policy {}.".format( - name, policy - )) + metalogger.debug( + "Creating logger for {} with policy {}.".format(name, policy) + ) - if policy == 'basic': + if policy == "basic": # Add no handlers, just let basicConfig do it all. # This is nice for working with IPython, since # it will use its own handlers instead of our StreamHandler @@ -82,11 +86,12 @@ def get_logger(name=None): else: logging.basicConfig() - elif policy == 'stream': + elif policy == "stream": formatter = logging.Formatter( - '[%(asctime)s] %(name)s[%(process)s]: ' - '%(funcName)s: %(levelname)s: %(message)s', - '%Y-%m-%d %H:%M:%S') + "[%(asctime)s] %(name)s[%(process)s]: " + "%(funcName)s: %(levelname)s: %(message)s", + "%Y-%m-%d %H:%M:%S", + ) handler = logging.StreamHandler() handler.setFormatter(formatter) logger.addHandler(handler) @@ -94,7 +99,7 @@ def get_logger(name=None): # We're handling things here, so no propagation out. logger.propagate = False - elif policy == 'null': + elif policy == "null": # We need to add a NullHandler so that debugging works # at all, but this policy leaves it to the user to # make their own handlers. This is particularly useful From 01879ba85253bd3d4d2637e0c5e1aab1506adb0a Mon Sep 17 00:00:00 2001 From: Boxi Li Date: Mon, 10 Apr 2023 16:57:43 +0200 Subject: [PATCH 6/9] Use qutip_qtrl.logging_utils instead of qutip.logging_utils --- src/qutip_qtrl/dump.py | 4 ++-- src/qutip_qtrl/dynamics.py | 2 +- src/qutip_qtrl/fidcomp.py | 2 +- src/qutip_qtrl/grape.py | 4 ++-- src/qutip_qtrl/optimconfig.py | 6 +++--- src/qutip_qtrl/optimizer.py | 2 +- src/qutip_qtrl/pulsegen.py | 2 +- src/qutip_qtrl/pulseoptim.py | 10 +++++----- src/qutip_qtrl/tslotcomp.py | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/qutip_qtrl/dump.py b/src/qutip_qtrl/dump.py index 973c538..eb7dd4d 100644 --- a/src/qutip_qtrl/dump.py +++ b/src/qutip_qtrl/dump.py @@ -17,9 +17,9 @@ import qutip_qtrl.io as qtrlio # QuTiP logging -import qutip.logging_utils +import qutip_qtrl.logging_utils -logger = qutip.logging_utils.get_logger("qutip.control.dump") +logger = qutip_qtrl.logging_utils.get_logger("qutip.control.dump") DUMP_DIR = "~/.qtrl_dump" diff --git a/src/qutip_qtrl/dynamics.py b/src/qutip_qtrl/dynamics.py index 338dc24..3ca2dc0 100644 --- a/src/qutip_qtrl/dynamics.py +++ b/src/qutip_qtrl/dynamics.py @@ -135,7 +135,7 @@ class Dynamics(object): ---------- log_level : integer level of messaging output from the logger. - Options are attributes of qutip.logging_utils, + Options are attributes of qutip_qtrl.logging_utils, in decreasing levels of messaging, are: DEBUG_INTENSE, DEBUG_VERBOSE, DEBUG, INFO, WARN, ERROR, CRITICAL Anything WARN or above is effectively 'quiet' execution, diff --git a/src/qutip_qtrl/fidcomp.py b/src/qutip_qtrl/fidcomp.py index f01a897..be3c5cd 100644 --- a/src/qutip_qtrl/fidcomp.py +++ b/src/qutip_qtrl/fidcomp.py @@ -80,7 +80,7 @@ class FidelityComputer(object): ---------- log_level : integer level of messaging output from the logger. - Options are attributes of qutip.logging_utils, + Options are attributes of qutip_qtrl.logging_utils, in decreasing levels of messaging, are: DEBUG_INTENSE, DEBUG_VERBOSE, DEBUG, INFO, WARN, ERROR, CRITICAL Anything WARN or above is effectively 'quiet' execution, diff --git a/src/qutip_qtrl/grape.py b/src/qutip_qtrl/grape.py index 8beaaa3..381bca5 100644 --- a/src/qutip_qtrl/grape.py +++ b/src/qutip_qtrl/grape.py @@ -20,9 +20,9 @@ from qutip.ui.progressbar import BaseProgressBar from qutip_qtrl.cy_grape import cy_overlap, cy_grape_inner -import qutip.logging_utils +import qutip_qtrl.logging_utils -logger = qutip.logging_utils.get_logger("qutip.control.grape") +logger = qutip_qtrl.logging_utils.get_logger("qutip.control.grape") class GRAPEResult: diff --git a/src/qutip_qtrl/optimconfig.py b/src/qutip_qtrl/optimconfig.py index f368047..c5943c4 100644 --- a/src/qutip_qtrl/optimconfig.py +++ b/src/qutip_qtrl/optimconfig.py @@ -12,9 +12,9 @@ import numpy as np # QuTiP logging -import qutip.logging_utils +import qutip_qtrl.logging_utils -logger = qutip.logging_utils.get_logger("qutip.control.optimconfig") +logger = qutip_qtrl.logging_utils.get_logger("qutip.control.optimconfig") import qutip_qtrl.io as qtrlio @@ -26,7 +26,7 @@ class OptimConfig(object): ---------- log_level : integer level of messaging output from the logger. - Options are attributes of qutip.logging_utils, + Options are attributes of qutip_qtrl.logging_utils, in decreasing levels of messaging, are: DEBUG_INTENSE, DEBUG_VERBOSE, DEBUG, INFO, WARN, ERROR, CRITICAL Anything WARN or above is effectively 'quiet' execution, diff --git a/src/qutip_qtrl/optimizer.py b/src/qutip_qtrl/optimizer.py index 85ec5ac..6119cf8 100644 --- a/src/qutip_qtrl/optimizer.py +++ b/src/qutip_qtrl/optimizer.py @@ -128,7 +128,7 @@ class Optimizer(object): ---------- log_level : integer level of messaging output from the logger. Options are attributes of - qutip.logging_utils, in decreasing levels of messaging, are: + qutip_qtrl.logging_utils, in decreasing levels of messaging, are: DEBUG_INTENSE, DEBUG_VERBOSE, DEBUG, INFO, WARN, ERROR, CRITICAL Anything WARN or above is effectively 'quiet' execution, assuming everything runs as expected. The default NOTSET implies that the level diff --git a/src/qutip_qtrl/pulsegen.py b/src/qutip_qtrl/pulsegen.py index 7b62da4..a4fff2e 100644 --- a/src/qutip_qtrl/pulsegen.py +++ b/src/qutip_qtrl/pulsegen.py @@ -140,7 +140,7 @@ class PulseGen: log_level : integer level of messaging output from the logger. - Options are attributes of qutip.logging_utils, + Options are attributes of qutip_qtrl.logging_utils, in decreasing levels of messaging, are: DEBUG_INTENSE, DEBUG_VERBOSE, DEBUG, INFO, WARN, ERROR, CRITICAL Anything WARN or above is effectively 'quiet' execution, diff --git a/src/qutip_qtrl/pulseoptim.py b/src/qutip_qtrl/pulseoptim.py index 095c4e6..5d79b0e 100644 --- a/src/qutip_qtrl/pulseoptim.py +++ b/src/qutip_qtrl/pulseoptim.py @@ -331,7 +331,7 @@ def optimize_pulse( log_level : integer Level of messaging output from the logger. Options are attributes of - :obj:`qutip.logging_utils`, in decreasing levels of messaging, are: + :obj:`qutip_qtrl.logging_utils`, in decreasing levels of messaging, are: DEBUG_INTENSE, DEBUG_VERBOSE, DEBUG, INFO, WARN, ERROR, CRITICAL. Anything WARN or above is effectively 'quiet' execution, assuming everything runs as expected. The default NOTSET implies that the level @@ -740,7 +740,7 @@ def optimize_pulse_unitary( log_level : integer Level of messaging output from the logger. Options are attributes of - :obj:`qutip.logging_utils` in decreasing levels of messaging, are: + :obj:`qutip_qtrl.logging_utils` in decreasing levels of messaging, are: DEBUG_INTENSE, DEBUG_VERBOSE, DEBUG, INFO, WARN, ERROR, CRITICAL Anything WARN or above is effectively 'quiet' execution, assuming everything runs as expected. The default NOTSET implies that the level @@ -1069,7 +1069,7 @@ def opt_pulse_crab( log_level : integer level of messaging output from the logger. Options are attributes of - :obj:`qutip.logging_utils`, in decreasing levels of messaging, are: + :obj:`qutip_qtrl.logging_utils`, in decreasing levels of messaging, are: DEBUG_INTENSE, DEBUG_VERBOSE, DEBUG, INFO, WARN, ERROR, CRITICAL Anything WARN or above is effectively 'quiet' execution, assuming everything runs as expected. The default NOTSET implies that the level @@ -1382,7 +1382,7 @@ def opt_pulse_crab_unitary( log_level : integer Level of messaging output from the logger. Options are attributes of - :obj:`qutip.logging_utils`, in decreasing levels of messaging, are: + :obj:`qutip_qtrl.logging_utils`, in decreasing levels of messaging, are: DEBUG_INTENSE, DEBUG_VERBOSE, DEBUG, INFO, WARN, ERROR, CRITICAL. Anything WARN or above is effectively 'quiet' execution, assuming everything runs as expected. The default NOTSET implies that the level @@ -1727,7 +1727,7 @@ def create_pulse_optimizer( log_level : integer level of messaging output from the logger. - Options are attributes of qutip.logging_utils, + Options are attributes of qutip_qtrl.logging_utils, in decreasing levels of messaging, are: DEBUG_INTENSE, DEBUG_VERBOSE, DEBUG, INFO, WARN, ERROR, CRITICAL Anything WARN or above is effectively 'quiet' execution, diff --git a/src/qutip_qtrl/tslotcomp.py b/src/qutip_qtrl/tslotcomp.py index 6b6f835..18c1473 100644 --- a/src/qutip_qtrl/tslotcomp.py +++ b/src/qutip_qtrl/tslotcomp.py @@ -68,7 +68,7 @@ class TimeslotComputer: ---------- log_level : integer level of messaging output from the logger. - Options are attributes of qutip.logging_utils, + Options are attributes of qutip_qtrl.logging_utils, in decreasing levels of messaging, are: DEBUG_INTENSE, DEBUG_VERBOSE, DEBUG, INFO, WARN, ERROR, CRITICAL Anything WARN or above is effectively 'quiet' execution, From a6f9826eaa72ca66f03083584cdc4feeebc4de67 Mon Sep 17 00:00:00 2001 From: Patrick Hopf Date: Thu, 24 Aug 2023 12:18:26 +0200 Subject: [PATCH 7/9] fixed init, start, and update calls for BaseProgressBar --- src/qutip_qtrl/grape.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/qutip_qtrl/grape.py b/src/qutip_qtrl/grape.py index 381bca5..19e5bf9 100644 --- a/src/qutip_qtrl/grape.py +++ b/src/qutip_qtrl/grape.py @@ -142,7 +142,7 @@ def grape_unitary( with GRAPE, a time-dependent Hamiltonian that is defined by the control pulses, as well as the resulting propagator. """ - progress_bar = progress_bar or BaseProgressBar() + progress_bar = progress_bar or BaseProgressBar(R) if eps is None: eps = 0.1 * (2 * np.pi) / (times[-1]) @@ -170,9 +170,8 @@ def grape_unitary( if beta: warnings.warn("Causion: Using experimental feature time-penalty") - progress_bar.start(R) for r in range(R - 1): - progress_bar.update(r) + progress_bar.update() dt = times[1] - times[0] @@ -359,9 +358,8 @@ def cy_grape_unitary( alpha_val = alpha if alpha else 0.0 beta_val = beta if beta else 0.0 - progress_bar.start(R) for r in range(R - 1): - progress_bar.update(r) + progress_bar.update() dt = times[1] - times[0] @@ -500,7 +498,7 @@ def grape_unitary_adaptive( with GRAPE, a time-dependent Hamiltonian that is defined by the control pulses, as well as the resulting propagator. """ - progress_bar = progress_bar or BaseProgressBar() + progress_bar = progress_bar or BaseProgressBar(R) if eps is None: eps = 0.1 * (2 * np.pi) / (times[-1]) @@ -553,9 +551,8 @@ def _fidelity_function(x): _r = 0 _prev_overlap = 0 - progress_bar.start(R) for r in range(R - 1): - progress_bar.update(r) + progress_bar.update() _r = r eps_log[r] = eps_vec[best_k] From 2f7ef82c274d6735c7f0eb54a6b5acb5f0b59f90 Mon Sep 17 00:00:00 2001 From: Patrick Hopf <81010725+flowerthrower@users.noreply.github.com> Date: Mon, 27 Nov 2023 16:39:53 +0900 Subject: [PATCH 8/9] fix progress bar initialization --- src/qutip_qtrl/grape.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qutip_qtrl/grape.py b/src/qutip_qtrl/grape.py index 19e5bf9..6c4b5e2 100644 --- a/src/qutip_qtrl/grape.py +++ b/src/qutip_qtrl/grape.py @@ -315,7 +315,7 @@ def cy_grape_unitary( with GRAPE, a time-dependent Hamiltonian that is defined by the control pulses, as well as the resulting propagator. """ - progress_bar = progress_bar or BaseProgressBar() + progress_bar = progress_bar or BaseProgressBar(R) if eps is None: eps = 0.1 * (2 * np.pi) / (times[-1]) From 563991bf2f2a8a00382eb8073dc853db0d4d0ab2 Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Mon, 12 Feb 2024 22:20:21 +0100 Subject: [PATCH 9/9] Add changelog for version 0.1.1. --- doc/changelog.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/changelog.rst b/doc/changelog.rst index 80f9ba6..7986774 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -2,6 +2,18 @@ Changelog ********* +Version 0.1.1 (February 12, 2024) ++++++++++++++++++++++++++++++++++ + +This is a patch release of qutip-qtrl that provides updates to support the QuTiP 5.0.0a2 release. + +Bug Fixes +--------- + +- Fixed progress bar initialization and usage (#13, #15, Patrick Hopf). +- Replaced the logging utilities that were removed from QuTiP v5 with a vendored copy in this package (#9, Ăˆric Giguere). +- Applied black to setup.py and doc/conf.py scripts (#8, Simon Cross). + Version 0.1.0 (March 12, 2023) ++++++++++++++++++++++++++++++