Skip to content

Commit

Permalink
additional flake8 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tnking97 committed Apr 23, 2021
1 parent ea30eb6 commit a611c62
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 39 deletions.
12 changes: 6 additions & 6 deletions jwql/instrument_monitors/common_monitors/bad_pixel_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
from jwql.database.database_interface import FGSBadPixelQueryHistory, FGSBadPixelStats
from jwql.instrument_monitors import pipeline_tools
from jwql.utils import crds_tools, instrument_properties
from jwql.utils.constants import JWST_INSTRUMENT_NAMES, JWST_INSTRUMENT_NAMES_MIXEDCASE, \
FLAT_EXP_TYPES, DARK_EXP_TYPES
from jwql.utils.constants import JWST_INSTRUMENT_NAMES, JWST_INSTRUMENT_NAMES_MIXEDCASE
from jwql.utils.constants import FLAT_EXP_TYPES, DARK_EXP_TYPES
from jwql.utils.logging_functions import log_info, log_fail
from jwql.utils.mast_utils import mast_query
from jwql.utils.monitor_utils import initialize_instrument_monitor, update_monitor_table
Expand Down Expand Up @@ -685,8 +685,8 @@ def most_recent_search(self, file_type='dark'):
elif file_type.lower() == 'flat':
run_field = self.query_table.run_bpix_from_flats

query = session.query(self.query_table).filter(self.query_table.aperture==self.aperture). \
filter(run_field==True)
query = session.query(self.query_table).filter(self.query_table.aperture == self.aperture). \
filter(run_field == True)

dates = np.zeros(0)
if file_type.lower() == 'dark':
Expand Down Expand Up @@ -888,7 +888,7 @@ def process(self, illuminated_raw_files, illuminated_slope_files, dark_raw_files
logging.info('\tFound {} new {} pixels'.format(len(bad_location_list[0]), bad_type))

if bad_type in badpix_types_from_flats:
self.add_bad_pix(bad_location_list, bad_type, illuminated_slope_files,
self.add_bad_pix(bad_location_list, bad_type, illuminated_slope_files,
min_illum_time, mid_illum_time, max_illum_time, baseline_file)
elif bad_type in badpix_types_from_darks:
self.add_bad_pix(bad_location_list, bad_type, dark_slope_files,
Expand Down Expand Up @@ -958,7 +958,7 @@ def run(self):
lamp = 'LINE2'

# What lamp is most appropriate for FGS?
#if self.instrument == 'fgs':
# if self.instrument == 'fgs':
# lamp = 'G2LAMP1'

logging.info('')
Expand Down
2 changes: 1 addition & 1 deletion jwql/instrument_monitors/common_monitors/bias_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def run(self):

# Get a list of all possible full-frame apertures for this instrument
siaf = Siaf(self.instrument)
possible_apertures = [aperture for aperture in siaf.apertures if siaf[aperture].AperType=='FULLSCA']
possible_apertures = [aperture for aperture in siaf.apertures if siaf[aperture].AperType == 'FULLSCA']

for aperture in possible_apertures:

Expand Down
11 changes: 5 additions & 6 deletions jwql/instrument_monitors/common_monitors/dark_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ def most_recent_search(self):
Date (in MJD) of the ending range of the previous MAST query
where the dark monitor was run.
"""
query = session.query(self.query_table).filter(self.query_table.aperture==self.aperture). \
filter(self.query_table.run_monitor==True)
query = session.query(self.query_table).filter(self.query_table.aperture == self.aperture). \
filter(self.query_table.run_monitor == True)

dates = np.zeros(0)
for instance in query:
Expand Down Expand Up @@ -993,8 +993,7 @@ def stats_by_amp(self, image, amps):
degrees_of_freedom = len(hist) - 3.
total_pix = np.sum(hist[positive])
p_i = gauss_fit[positive] / total_pix
gaussian_chi_squared[key] = (np.sum((hist[positive] - (total_pix * p_i) ** 2) / (total_pix * p_i)) /
degrees_of_freedom)
gaussian_chi_squared[key] = (np.sum((hist[positive] - (total_pix * p_i) ** 2) / (total_pix * p_i)) / degrees_of_freedom)

# Double Gaussian fit only for full frame data (and only for
# NIRISS, NIRCam at the moment.)
Expand All @@ -1018,10 +1017,10 @@ def stats_by_amp(self, image, amps):

logging.info('\tMean dark rate by amplifier: {}'.format(amp_means))
logging.info('\tStandard deviation of dark rate by amplifier: {}'.format(amp_means))
logging.info('\tBest-fit Gaussian parameters [amplitude, peak, width]'.format(gaussian_params))
logging.info('\tBest-fit Gaussian parameters [amplitude, peak, width]: {}'.format(gaussian_params))
logging.info('\tReduced chi-squared associated with Gaussian fit: {}'.format(gaussian_chi_squared))
logging.info('\tBest-fit double Gaussian parameters [amplitude1, peak1, width1, amplitude2, peak2, '
'width2]'.format(double_gaussian_params))
'width2]: {}'.format(double_gaussian_params))
logging.info('\tReduced chi-squared associated with double Gaussian fit: {}'
.format(double_gaussian_chi_squared))

Expand Down
2 changes: 1 addition & 1 deletion jwql/jwql_monitors/generate_preview_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def group_filenames(filenames):
subgroup.append(file_to_match)

else:
# filename_dict['filename_type'] may be 'guider' or 'time_series', for instance. Treat individually.
# filename_dict['filename_type'] may be 'guider' or 'time_series', for instance. Treat individually.
matched_names.append(filename)
subgroup.append(filename)

Expand Down
4 changes: 2 additions & 2 deletions jwql/tests/test_calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def test_gaussian1d_fit():

assert np.isclose(peak[0], mean_value, atol=0.0035, rtol=0.)
assert np.isclose(width[0], sigma_value, atol=0.0035, rtol=0.)
assert ((mean_value <= peak[0]+7*peak[1]) & (mean_value >= peak[0]-7*peak[1]))
assert ((sigma_value <= width[0]+7*width[1]) & (sigma_value >= width[0]-7*width[1]))
assert ((mean_value <= peak[0] + 7 * peak[1]) & (mean_value >= peak[0] - 7 * peak[1]))
assert ((sigma_value <= width[0] + 7 * width[1]) & (sigma_value >= width[0] - 7 * width[1]))


def test_mean_image():
Expand Down
2 changes: 1 addition & 1 deletion jwql/tests/test_dark_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_mast_query_darks():
'jw82600016001_02102_00001_nrca1_dark.fits']

assert len(query) == 14
assert apernames == [aperture]*len(query)
assert apernames == [aperture] * len(query)
assert filenames == truth_filenames


Expand Down
4 changes: 2 additions & 2 deletions jwql/tests/test_database_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def test_anomaly_records():
"""Test to see that new records can be entered"""

# Add some data
random_rootname = ''.join(random.SystemRandom().choice(string.ascii_lowercase + \
string.ascii_uppercase + \
random_rootname = ''.join(random.SystemRandom().choice(string.ascii_lowercase +
string.ascii_uppercase +
string.digits) for _ in range(10))
di.session.add(di.FGSAnomaly(rootname=random_rootname,
flag_date=datetime.datetime.today(),
Expand Down
2 changes: 1 addition & 1 deletion jwql/tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_file_group(test_file):
# attempt to retrieve a group name different from default
group_index = 0
test_group = grp.getgrgid(os.getgroups()[group_index]).gr_name
test_group_2 = grp.getgrgid(os.getgroups()[group_index+1]).gr_name
test_group_2 = grp.getgrgid(os.getgroups()[group_index + 1]).gr_name

# Change the file group
set_permissions(test_file, group=test_group, owner=owner)
Expand Down
2 changes: 1 addition & 1 deletion jwql/utils/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
DEFAULT_GROUP = 'jwql_dev'

# set the default mode for DEFAULT_OWNER
DEFAULT_MODE = stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP # equivalent to '?rwxr-x---'
DEFAULT_MODE = stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP # equivalent to '?rwxr-x---'


def get_group_string(pathname):
Expand Down
16 changes: 8 additions & 8 deletions jwql/website/apps/jwql/bokeh_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,18 @@ def dashboard_files_per_day(self):
tab2 = Panel(child=p2, title='Storage')

p1.xaxis.formatter = DatetimeTickFormatter(
hours=["%d %B %Y"],
days=["%d %B %Y"],
months=["%d %B %Y"],
years=["%d %B %Y"],
hours=["%d %B %Y"],
days=["%d %B %Y"],
months=["%d %B %Y"],
years=["%d %B %Y"],
)
p1.xaxis.major_label_orientation = pi / 4

p2.xaxis.formatter = DatetimeTickFormatter(
hours=["%d %B %Y"],
days=["%d %B %Y"],
months=["%d %B %Y"],
years=["%d %B %Y"],
hours=["%d %B %Y"],
days=["%d %B %Y"],
months=["%d %B %Y"],
years=["%d %B %Y"],
)
p2.xaxis.major_label_orientation = pi / 4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def bad_pixel_history(self, bad_pixel_type):

# Sum the number of bad pixels found from the earliest entry up to
# each new entry
num_bad_pixels = [np.sum(num[0:i]) for i in range(1, len(num)+1)]
num_bad_pixels = [np.sum(num[0:i]) for i in range(1, len(num) + 1)]

return num_bad_pixels, dates

Expand Down Expand Up @@ -287,7 +287,7 @@ def load_dummy_data(self):
hover_values = np.array([datetime.datetime.strftime(t, "%d-%b-%Y") for t in times])

self.bad_history[bad_pixel_type] = (times, num, hover_values)
self.bad_latest[bad_pixel_type] = (datetime.datetime(1999, 12, 31), [500+delta, 501+delta, 502+delta], [4, 4, 4])
self.bad_latest[bad_pixel_type] = (datetime.datetime(1999, 12, 31), [500 + delta, 501 + delta, 502 + delta], [4, 4, 4])

def most_recent_data(self):
"""Get the bad pixel type and coordinates associated with the most
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def update_plots(self, full=False):
if new_sizes:
stype_dict = {'dates': new_sizes['timestamp'].datetime64}
stype_dict.update({x: new_sizes[y].data / (1024.**3)
for x, y in zip(self.types_y, self.allowed_types)})
for x, y in zip(self.types_y, self.allowed_types)})
self.refs['source_sizes'].data = stype_dict

if not self.statistics:
Expand Down
10 changes: 5 additions & 5 deletions jwql/website/apps/jwql/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ def authorize(request):
token = JWQL_OAUTH.mast_auth.authorize_access_token(request)

# Determine domain
base_url = get_base_url()
if '127' in base_url:
domain = '127.0.0.1'
else:
domain = base_url.split('//')[-1]
# base_url = get_base_url()
# if '127' in base_url:
# domain = '127.0.0.1'
# else:
# domain = base_url.split('//')[-1]

# Set secure cookie parameters
cookie_args = {}
Expand Down
2 changes: 1 addition & 1 deletion style_guide/typing_demo/typing_demo_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
a_string: str = "jwql"
a_list: List[int] = [1]
a_set: Set[int] = {1, 2, 3}
a_dict: Dict[str, bool] = {'jwql':True} # Have to specify both keys and values
a_dict: Dict[str, bool] = {'jwql': True} # Have to specify both keys and values

# For python versions prior to 3.6, the variable annotation syntax uses comments:
# annotated_variable = 1 # type: int
Expand Down
1 change: 1 addition & 0 deletions style_guide/typing_demo/typing_demo_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def do_mutate(mut_dict: MutableMapping[Any, Any]) -> Set[Any]:
mut_dict['jwql'] = True
return set(mut_dict.keys())


# Variables can be annotated without initializing
stream: IO[str]
print(__annotations__['stream'])
Expand Down
1 change: 1 addition & 0 deletions style_guide/typing_demo/typing_demo_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def ive_got_your_number(num: int) -> bool:
else:
return "Jenny don't change your number"


ive_got_your_number("jenny") # no runtime error
ive_got_your_number(555_1212) # no runtime error

Expand Down
2 changes: 1 addition & 1 deletion style_guide/typing_demo/typing_demo_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ def get_favorite_number():


num = get_favorite_number()
print("Twice your favorite number is", num*2)
print("Twice your favorite number is", num * 2)

0 comments on commit a611c62

Please sign in to comment.