diff --git a/docs/changes/799.removal.rst b/docs/changes/799.removal.rst new file mode 100644 index 000000000..00a946650 --- /dev/null +++ b/docs/changes/799.removal.rst @@ -0,0 +1 @@ +Eliminated the usage of astropy logging \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 1879ac3b0..dc0ced1b4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -34,16 +34,14 @@ try: from sphinx_astropy.conf.v1 import * # noqa except ImportError: - print( - 'ERROR: the documentation requires the sphinx-astropy package to be installed' - ) + print("ERROR: the documentation requires the sphinx-astropy package to be installed") sys.exit(1) # Get configuration information from setup.cfg conf = ConfigParser() -conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')]) -setup_cfg = dict(conf.items('metadata')) +conf.read([os.path.join(os.path.dirname(__file__), "..", "setup.cfg")]) +setup_cfg = dict(conf.items("metadata")) # -- General configuration ---------------------------------------------------- @@ -59,10 +57,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns += ['_templates', - 'notebooks/README.rst', - 'notebooks/Debug', - 'changes'] +exclude_patterns += ["_templates", "notebooks/README.rst", "notebooks/Debug", "changes"] # This is added to the end of RST files - a good place to put substitutions to # be used globally. @@ -72,20 +67,19 @@ # -- Project information ------------------------------------------------------ # This does not *have* to match the package name, but typically does -project = setup_cfg['name'] -author = setup_cfg['author'] -copyright = '{0}, {1}'.format(datetime.datetime.now().year, - setup_cfg['author']) +project = setup_cfg["name"] +author = setup_cfg["author"] +copyright = "{0}, {1}".format(datetime.datetime.now().year, setup_cfg["author"]) # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. -import_module(setup_cfg['name']) -package = sys.modules[setup_cfg['name']] +import_module(setup_cfg["name"]) +package = sys.modules[setup_cfg["name"]] # The short X.Y version. -version = package.__version__.split('-', 1)[0] +version = package.__version__.split("-", 1)[0] # The full version, including alpha/beta/rc tags. release = package.__version__ @@ -110,15 +104,17 @@ html_css_files = ["css/custom.css"] html_theme_options = { - 'logotext1': 'Sting', # white, semi-bold - 'logotext2': 'ray', # orange, light - 'logotext3': ':docs' # white, light + "logotext1": "Sting", # white, semi-bold + "logotext2": "ray", # orange, light + "logotext3": ":docs", # white, light } extensions += [ - 'matplotlib.sphinxext.plot_directive', 'sphinx.ext.autodoc', - 'sphinx.ext.napoleon', 'nbsphinx', - 'IPython.sphinxext.ipython_console_highlighting' + "matplotlib.sphinxext.plot_directive", + "sphinx.ext.autodoc", + "sphinx.ext.napoleon", + "nbsphinx", + "IPython.sphinxext.ipython_console_highlighting", ] # Custom sidebar templates, maps document names to template names. @@ -139,47 +135,43 @@ # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -html_title = '{0} v{1}'.format(project, release) +html_title = "{0} v{1}".format(project, release) # Output file base name for HTML help builder. -htmlhelp_basename = project + 'doc' +htmlhelp_basename = project + "doc" # -- Options for LaTeX output ------------------------------------------------- # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [('index', project + '.tex', project + u' Documentation', - author, 'manual')] +latex_documents = [("index", project + ".tex", project + " Documentation", author, "manual")] # -- Options for manual page output ------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [('index', project.lower(), project + u' Documentation', [author], - 1)] +man_pages = [("index", project.lower(), project + " Documentation", [author], 1)] # Trust the links from doi.org, even if they might have Client errors or other minor issues linkcheck_ignore = [r"https://doi.org/"] # -- Options for the edit_on_github extension --------------------------------- -if setup_cfg.get('edit_on_github').lower() == 'true': +if setup_cfg.get("edit_on_github").lower() == "true": + extensions += ["sphinx_astropy.ext.edit_on_github"] - extensions += ['sphinx_astropy.ext.edit_on_github'] - - edit_on_github_project = setup_cfg['github_project'] + edit_on_github_project = setup_cfg["github_project"] edit_on_github_branch = "master" edit_on_github_source_root = "" edit_on_github_doc_root = "docs" # -- Resolving issue number to links in changelog ----------------------------- -github_issues_url = 'https://github.com/{0}/issues/'.format( - setup_cfg['github_project']) +github_issues_url = "https://github.com/{0}/issues/".format(setup_cfg["github_project"]) # -- Configuration for nbsphinx ----------------------------------------------- # disable notebook execution -nbsphinx_execute = 'never' +nbsphinx_execute = "never" # -- Generate DOI listing from Zenodo ----------------------------------------- import json @@ -207,18 +199,14 @@ def zenodo_url(self): @property def github_url(self): - return ( - f"https://github.com/StingraySoftware/stingray/releases/tag/{self.version}" - ) + return f"https://github.com/StingraySoftware/stingray/releases/tag/{self.version}" @property def bibtex_url(self): return self.zenodo_url + "/export/hx" -params = urllib.parse.urlencode( - {"q": f'conceptdoi: "{CONCEPT_DOI}"', "all_versions": 1} -) +params = urllib.parse.urlencode({"q": f'conceptdoi: "{CONCEPT_DOI}"', "all_versions": 1}) try: with urllib.request.urlopen(ZENODO_API_ENDPOINT + "?" + params) as url: data = json.loads(url.read().decode("utf-8")) diff --git a/setup.py b/setup.py index 22db4c3a4..c25a07202 100755 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ http://docs.astropy.org/en/latest/development/testguide.html#running-tests """ -if 'test' in sys.argv: +if "test" in sys.argv: print(TEST_HELP) sys.exit(1) @@ -58,7 +58,7 @@ http://docs.astropy.org/en/latest/install.html#builddocs """ -if 'build_docs' in sys.argv or 'build_sphinx' in sys.argv: +if "build_docs" in sys.argv or "build_sphinx" in sys.argv: print(DOCS_HELP) sys.exit(1) @@ -75,6 +75,7 @@ setup( use_scm_version={ - 'write_to': os.path.join('stingray', 'version.py'), - 'write_to_template': VERSION_TEMPLATE - }) + "write_to": os.path.join("stingray", "version.py"), + "write_to_template": VERSION_TEMPLATE, + } +) diff --git a/stingray/deadtime/fad.py b/stingray/deadtime/fad.py index 6dc20129c..3d95c324a 100644 --- a/stingray/deadtime/fad.py +++ b/stingray/deadtime/fad.py @@ -20,6 +20,7 @@ logger = setup_logger() + def FAD( data1, data2, diff --git a/stingray/deadtime/model.py b/stingray/deadtime/model.py index b012cf5b5..8a1529477 100644 --- a/stingray/deadtime/model.py +++ b/stingray/deadtime/model.py @@ -9,6 +9,7 @@ logger = setup_logger() + def r_in(td, r_0): """Calculate incident countrate given dead time and detected countrate.""" tau = 1 / r_0 diff --git a/stingray/filters.py b/stingray/filters.py index df231a6ab..ffdaa2763 100644 --- a/stingray/filters.py +++ b/stingray/filters.py @@ -12,6 +12,7 @@ logger = setup_logger() + class Window1D(object): """ Make a top hat filter (window function) for power spectrum or cross diff --git a/stingray/loggingconfig.py b/stingray/loggingconfig.py index 5ac51fec3..72a93e710 100644 --- a/stingray/loggingconfig.py +++ b/stingray/loggingconfig.py @@ -2,8 +2,8 @@ logger = None -class CustomFormatter(logging.Formatter): +class CustomFormatter(logging.Formatter): grey = "\x1b[38;20m" yellow = "\x1b[33;20m" red = "\x1b[31;20m" @@ -16,7 +16,7 @@ class CustomFormatter(logging.Formatter): logging.INFO: grey + format + reset, logging.WARNING: yellow + format + reset, logging.ERROR: red + format + reset, - logging.CRITICAL: bold_red + format + reset + logging.CRITICAL: bold_red + format + reset, } def format(self, record): @@ -27,7 +27,7 @@ def format(self, record): def setup_logger(): global logger - + if not logger: logger = logging.getLogger(__name__) handler = logging.StreamHandler() @@ -36,5 +36,4 @@ def setup_logger(): logger.addHandler(handler) logger.setLevel(logging.DEBUG) - - return logger \ No newline at end of file + return logger