From 1eec235fff5d61c53d514dc7930b5250ecf43db8 Mon Sep 17 00:00:00 2001 From: David Hendriks <davidhendriks93@gmail.com> Date: Sat, 22 Oct 2022 00:15:54 +0100 Subject: [PATCH] fixing flake8 issues --- binarycpython/tests/test_notebooks.py | 14 +++++++------- binarycpython/utils/ensemble.py | 6 +++--- .../utils/population_extensions/cache.py | 3 +-- .../utils/population_extensions/condor.py | 16 ++++++++-------- .../population_extensions/evolution_functions.py | 6 +++--- .../utils/population_extensions/metadata.py | 2 +- setup.py | 1 - 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/binarycpython/tests/test_notebooks.py b/binarycpython/tests/test_notebooks.py index e11877542..74d8510d6 100644 --- a/binarycpython/tests/test_notebooks.py +++ b/binarycpython/tests/test_notebooks.py @@ -19,7 +19,7 @@ def run_notebook(notebook_path): # https://www.blog.pythonlibrary.org/2018/10/16/testing-jupyter-notebooks/ nb_name, _ = os.path.splitext(os.path.basename(notebook_path)) - dirname = os.path.dirname(notebook_path) + # dirname = os.path.dirname(notebook_path) with open(notebook_path) as f: nb = nbformat.read(f, as_version=4) @@ -51,7 +51,7 @@ class TestNotebook(unittest.TestCase): def test_notebook_api_functionality(self): notebook_name = "notebook_api_functionality.ipynb" full_notebook_path = os.path.join(NOTEBOOKS_DIR, notebook_name) - nb, errors = run_notebook(full_notebook_path) + _, errors = run_notebook(full_notebook_path) msg = "\nNotebook: {}\n\n".format(notebook_name) + "\n".join( [ "{}: {}\n{}".format( @@ -65,7 +65,7 @@ class TestNotebook(unittest.TestCase): def test_notebook_population(self): notebook_name = "notebook_population.ipynb" full_notebook_path = os.path.join(NOTEBOOKS_DIR, notebook_name) - nb, errors = run_notebook(full_notebook_path) + _, errors = run_notebook(full_notebook_path) msg = "\nNotebook: {}\n\n".format(notebook_name) + "\n".join( [ "{}: {}\n{}".format( @@ -79,7 +79,7 @@ class TestNotebook(unittest.TestCase): def test_notebook_individual_systems(self): notebook_name = "notebook_individual_systems.ipynb" full_notebook_path = os.path.join(NOTEBOOKS_DIR, notebook_name) - nb, errors = run_notebook(full_notebook_path) + _, errors = run_notebook(full_notebook_path) msg = "\nNotebook: {}\n\n".format(notebook_name) + "\n".join( [ "{}: {}\n{}".format( @@ -93,7 +93,7 @@ class TestNotebook(unittest.TestCase): def test_notebook_custom_logging(self): notebook_name = "notebook_custom_logging.ipynb" full_notebook_path = os.path.join(NOTEBOOKS_DIR, notebook_name) - nb, errors = run_notebook(full_notebook_path) + _, errors = run_notebook(full_notebook_path) msg = "\nNotebook: {}\n\n".format(notebook_name) + "\n".join( [ "{}: {}\n{}".format( @@ -107,7 +107,7 @@ class TestNotebook(unittest.TestCase): def test_notebook_extra_features(self): notebook_name = "notebook_extra_features.ipynb" full_notebook_path = os.path.join(NOTEBOOKS_DIR, notebook_name) - nb, errors = run_notebook(full_notebook_path) + _, errors = run_notebook(full_notebook_path) msg = "\nNotebook: {}\n\n".format(notebook_name) + "\n".join( [ "{}: {}\n{}".format( @@ -121,7 +121,7 @@ class TestNotebook(unittest.TestCase): def test_notebook_luminosity_function_single(self): notebook_name = "notebook_luminosity_function_single.ipynb" full_notebook_path = os.path.join(NOTEBOOKS_DIR, notebook_name) - nb, errors = run_notebook(full_notebook_path) + _, errors = run_notebook(full_notebook_path) msg = "\nNotebook: {}\n\n".format(notebook_name) + "\n".join( [ "{}: {}\n{}".format( diff --git a/binarycpython/utils/ensemble.py b/binarycpython/utils/ensemble.py index 281a67ab4..949c09cbb 100644 --- a/binarycpython/utils/ensemble.py +++ b/binarycpython/utils/ensemble.py @@ -141,7 +141,7 @@ def load_ensemble( # open the file # load with some info to the terminal - if quiet == False: + if not quiet: print("Loading JSON...", flush=flush) # open the ensemble and get the file type @@ -155,7 +155,7 @@ def load_ensemble( ) sys.exit() - if quiet == True: + if quiet: tstart = time.time() if filetype == "JSON": data = simplejson.load(file_object) @@ -220,7 +220,7 @@ def load_ensemble( if select_keys: keys = list(data["ensemble"].keys()) for key in keys: - if not key in select_keys: + if key not in select_keys: del data["ensemble"][key] # perhaps convert floats? diff --git a/binarycpython/utils/population_extensions/cache.py b/binarycpython/utils/population_extensions/cache.py index eeb17c5be..782330d8f 100644 --- a/binarycpython/utils/population_extensions/cache.py +++ b/binarycpython/utils/population_extensions/cache.py @@ -12,7 +12,6 @@ Please see the LRU_* options in there. import contextlib import getpass -import importlib import os import time @@ -42,7 +41,7 @@ class cache: os.path.join(os.environ.get("TMP", error_string), "cache"), os.path.join("var", "tmp", getpass.getuser(), "cache"), ]: - if not error_string in path and os.path.isdir(path): + if error_string not in path and os.path.isdir(path): return os.path.join(path, "binary_c") return None diff --git a/binarycpython/utils/population_extensions/condor.py b/binarycpython/utils/population_extensions/condor.py index d61777467..c52efd9ef 100644 --- a/binarycpython/utils/population_extensions/condor.py +++ b/binarycpython/utils/population_extensions/condor.py @@ -17,7 +17,7 @@ import time import datasize import lib_programname -from binarycpython.utils.functions import command_string_from_list, now +from binarycpython.utils.functions import command_string_from_list class condor: @@ -271,12 +271,12 @@ class condor: else "$ClusterID" ) - # get job array index - Process = ( - self.grid_options["condor_Process"] - if self.grid_options["condor_Process"] != "" - else "$Process" - ) + # # get job array index + # Process = ( + # self.grid_options["condor_Process"] + # if self.grid_options["condor_Process"] != "" + # else "$Process" + # ) if self.grid_options["condor_njobs"] == 0: print( @@ -374,7 +374,7 @@ echo \"running\" > "{condor_dir}/status/$ClusterID.$ProcessID" ) condor_job_script += """&& echo \"Checking if we can join...\" && echo && {grid_command} "condor=3" "evolution_type=join" "joinlist={joinfile}" "condor_ClusterID=$ClusterID" "condor_Process=$Process" """.format( - bash=self.grid_options["condor_bash"], + # bash=self.grid_options["condor_bash"], grid_command=grid_command, joinfile=joinfile, ) diff --git a/binarycpython/utils/population_extensions/evolution_functions.py b/binarycpython/utils/population_extensions/evolution_functions.py index 6dd02f41a..56eddba09 100644 --- a/binarycpython/utils/population_extensions/evolution_functions.py +++ b/binarycpython/utils/population_extensions/evolution_functions.py @@ -949,9 +949,9 @@ class evolution_functions: failcolour=self.ANSI_colours["red"] if self.grid_options["_failed_count"] > 0 else "", - failreset=self.ANSI_colours[colour] - if self.grid_options["_failed_count"] > 0 - else "", + # failreset=self.ANSI_colours[colour] + # if self.grid_options["_failed_count"] > 0 + # else "", nfail=self.grid_options["_failed_count"], pfail=self.grid_options["_failed_prob"], nzero=zero_prob_stars_skipped, diff --git a/binarycpython/utils/population_extensions/metadata.py b/binarycpython/utils/population_extensions/metadata.py index b33e477ea..6d6b9dd6d 100644 --- a/binarycpython/utils/population_extensions/metadata.py +++ b/binarycpython/utils/population_extensions/metadata.py @@ -32,7 +32,7 @@ class metadata: """ # add metadata if it doesn't exist - if not "metadata" in self.grid_ensemble_results: + if "metadata" not in self.grid_ensemble_results: self.grid_ensemble_results["metadata"] = {} # add date diff --git a/setup.py b/setup.py index 22df3546f..d6ba0df87 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,6 @@ REQUIRED_BINARY_C_VERSIONS = ["2.1.7", "2.2pre1", "2.2.0", "2.2.1", "2.2.2"] ############################################################ - # Functions def version(): """ -- GitLab