From 632565e17077f63626a1a880e67ac68bb6c167ba Mon Sep 17 00:00:00 2001 From: Scott Noyes Date: Mon, 5 Sep 2022 09:04:52 -0500 Subject: [PATCH 1/4] Correctly check hostname contents `and` cannot be used to check for two substrings like this. Correctly check for both words in the socket hostname. --- jwql/database/database_interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jwql/database/database_interface.py b/jwql/database/database_interface.py index 08d775149..9851e359e 100755 --- a/jwql/database/database_interface.py +++ b/jwql/database/database_interface.py @@ -144,7 +144,7 @@ def load_connection(connection_string): # Import a global session. If running from readthedocs or GitHub Actions, # pass a dummy connection string -if 'build' and 'project' in socket.gethostname() or ON_GITHUB_ACTIONS: +if all(word in socket.gethostname() for word in ('build', 'project')) or ON_GITHUB_ACTIONS: dummy_connection_string = 'postgresql+psycopg2://account:password@hostname:0000/db_name' session, base, engine, meta = load_connection(dummy_connection_string) else: From 4d5bdcc44b4fcc804b57fde770dacae663a83cd0 Mon Sep 17 00:00:00 2001 From: Scott Noyes Date: Mon, 5 Sep 2022 10:45:51 -0500 Subject: [PATCH 2/4] remove extra space --- jwql/database/database_interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jwql/database/database_interface.py b/jwql/database/database_interface.py index 9851e359e..93d4a0b04 100755 --- a/jwql/database/database_interface.py +++ b/jwql/database/database_interface.py @@ -144,7 +144,7 @@ def load_connection(connection_string): # Import a global session. If running from readthedocs or GitHub Actions, # pass a dummy connection string -if all(word in socket.gethostname() for word in ('build', 'project')) or ON_GITHUB_ACTIONS: +if all(word in socket.gethostname() for word in ('build', 'project')) or ON_GITHUB_ACTIONS: dummy_connection_string = 'postgresql+psycopg2://account:password@hostname:0000/db_name' session, base, engine, meta = load_connection(dummy_connection_string) else: From 0ebd97d977c3dfacf9b5153de103ae43b6b9a081 Mon Sep 17 00:00:00 2001 From: Scott Noyes Date: Tue, 6 Sep 2022 07:55:57 -0500 Subject: [PATCH 3/4] Compare to 2, not greater than 2 Later code assumes that the list has at least two elements. --- jwql/utils/interactive_preview_image.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jwql/utils/interactive_preview_image.py b/jwql/utils/interactive_preview_image.py index 01c99e808..bca24a416 100644 --- a/jwql/utils/interactive_preview_image.py +++ b/jwql/utils/interactive_preview_image.py @@ -89,12 +89,12 @@ def __init__(self, filename, low_lim=None, high_lim=None, scaling='log', contras if self.contrast is None: self.contrast = 0.25 if isinstance(group, list): - if len(group) > 2: + if len(group) != 2: raise ValueError( 'group must be an integer or 2-element list') self.group = group if isinstance(integ, list): - if len(integ) > 2: + if len(integ) != 2: raise ValueError( 'integ must be an integer or 2-element list') self.integ = integ From 6e2a8da0e8c55a28c00718eece12ecc4ccf1d3c4 Mon Sep 17 00:00:00 2001 From: Scott Noyes Date: Tue, 6 Sep 2022 08:39:53 -0500 Subject: [PATCH 4/4] minor typo --- jwql/tests/test_calculations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jwql/tests/test_calculations.py b/jwql/tests/test_calculations.py index 1c3fef2e5..dba2f8b9a 100644 --- a/jwql/tests/test_calculations.py +++ b/jwql/tests/test_calculations.py @@ -77,7 +77,7 @@ def test_mean_image(): cube[i, :, :] = 5. # Insert a few signal values that will be removed by sigma clipping. - # Make sure you "remove" and equal number of 4's and 5's from each + # Make sure you "remove" an equal number of 4's and 5's from each # pixel in order to keep the mean at 4.5 and dev at 0.5 cube[0, 0, 0] = 55. cube[1, 0, 0] = -78.