diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 68b075549..6a8504379 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,8 @@ +exclude: ".*\\.asdf$" + repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-added-large-files - id: check-ast @@ -15,49 +17,20 @@ repos: # - id: end-of-file-fixer # - id: trailing-whitespace - - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.10.0 - hooks: - - id: rst-directive-colons - - id: rst-inline-touching-normal - - id: text-unicode-replacement-char - - # - repo: https://github.com/codespell-project/codespell - # rev: v2.2.5 - # hooks: - # - id: codespell - # args: ["--write-changes"] - # additional_dependencies: - # - tomli - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.5" + rev: 'v0.6.8' hooks: - id: ruff - args: ["--fix", "--show-fixes"] + args: ["--fix"] # - id: ruff-format - - repo: https://github.com/MarcoGorelli/cython-lint - rev: v0.15.0 + - repo: https://github.com/PyCQA/bandit + rev: 1.7.10 hooks: - - id: cython-lint - # - id: double-quote-cython-strings + - id: bandit + args: ["-r", "-ll", "src", "tests"] - - repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort - name: isort (cython) - types: [cython] - - - repo: https://github.com/adamchainz/blacken-docs - rev: 1.16.0 + - repo: https://github.com/MarcoGorelli/cython-lint + rev: v0.16.2 hooks: - - id: blacken-docs - additional_dependencies: - - black==22.12.0 - - # - repo: https://github.com/pre-commit/mirrors-prettier - # rev: "v3.0.1" - # hooks: - # - id: prettier + - id: cython-lint diff --git a/changes/295.general.rst b/changes/295.general.rst new file mode 100644 index 000000000..3481271cf --- /dev/null +++ b/changes/295.general.rst @@ -0,0 +1 @@ +Adjust code style checks. diff --git a/pyproject.toml b/pyproject.toml index 7469834dd..90a85b2df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -120,69 +120,12 @@ src = [ ] [tool.ruff.lint] -select = [ - #"F", # Pyflakes (part of default flake8) - #"W", "E", # pycodestyle (part of default flake8) - #"I", # isort (import sorting) - # "N", # pep8-naming - #"D", # pydocstyle (docstring style guide) - #"UP", # pyupgrade (upgrade code to modern python) - "YTT", # flake8-2020 (system version info) - "ANN", # flake8-annotations (best practices for type annotations) - #"S", # flake8-bandit (security checks) - "BLE", # flake8-blind-except (prevent blind except statements) - #"B", # flake8-bugbear (prevent common gotcha bugs) - "A", # flake8-builtins (prevent shadowing of builtins) - "C4", # flake8-comprehensions (best practices for comprehensions) - "T10", # flake8-debugger (prevent debugger statements in code) - #"EM", # flake8-errormessages (best practices for error messages) - "FA", # flake8-future-annotations (correct usage future annotations) - "ISC", # flake8-implicit-str-concat (prevent implicit string concat) - "ICN", # flake8-import-conventions (enforce import conventions) - #"G", # flake8-logging-format (best practices for logging) - "INP", # flake8-no-pep420 (prevent use of PEP420, i.e. implicit name spaces) - #"PIE", # flake8-pie (misc suggested improvement linting) - # "T20", # flake8-print (prevent print statements in code) - #"PT", # flake8-pytest-style (best practices for pytest) - #"Q", # flake8-quotes (best practices for quotes) - "RSE", # flake8-raise (best practices for raising exceptions) - #"RET", # flake8-return (best practices for return statements) - #"SLF", # flake8-self (prevent private member access) - "SLOT", # flake8-slots (require __slots__ for immutable classes) - #"SIM", # flake8-simplify (suggest simplifications to code where possible) - "TID", # flake8-tidy-imports (prevent banned api and best import practices) - "TCH", # flake8-type-checking (move type checking imports into type checking blocks) - "INT", # flake8-gettext (when to use printf style strings) - # "ARG", # flake8-unused-arguments (prevent unused arguments) - #"PTH", # flake8-use-pathlib (prefer pathlib over os.path) - # "ERA", # eradicate (remove commented out code) - "PGH", # pygrep (simple grep checks) - #"PL", # pylint (general linting, flake8 alternative) - #"TRY", # tryceratops (linting for try/except blocks) - "FLY", # flynt (f-string conversion where possible) - #"NPY", # NumPy-specific checks (recommendations from NumPy) - #"PERF", # Perflint (performance linting) - "LOG", - #"RUF", # ruff specific checks +extend-select = [ + "I", # isort ] ignore = [ - "ISC001", # interferes with formatter - "PLR0912", # Too many branches - "PLR0913", # Too many arguments - "PLR0915", # Too many statements - "PLR2004", # Magic value used in comparison - "ANN101", # Missing type annotation for self in method - "ANN102", # Missing type annotation for cls in classmethod - - # Pydocstyle (to fix over time - "D100", # Undocumented public module - "D101", # Undocumented public class - "D102", # Undocumented public method - "D103", # Undocumented public function - "D104", # Undocumented public package - "D205", # 1 blank line required between summary line and description - "D401", # First line of docstring should be in imperative mood - "D404", # First word of docstring should not be This + # "E741", # ambiguous variable name (O/0, l/I, etc.) + # "E722", # Do not use bare `except` ] exclude = [ "docs", @@ -192,18 +135,6 @@ exclude = [ ".eggs", ] -[tool.ruff.lint.extend-per-file-ignores] -"tests/*.py" = [ - "S101", - "D", -] - -[tool.ruff.lint.pydocstyle] -convention = "numpy" - -[tool.ruff.lint.flake8-annotations] -ignore-fully-untyped = true # Turn of annotation checking for fully untyped code - [tool.mypy] python_version = "3.12" warn_return_any = true diff --git a/src/stcal/alignment/util.py b/src/stcal/alignment/util.py index 90eb9420d..e3aade7a5 100644 --- a/src/stcal/alignment/util.py +++ b/src/stcal/alignment/util.py @@ -4,8 +4,8 @@ import functools import logging import re -from typing import TYPE_CHECKING import warnings +from typing import TYPE_CHECKING if TYPE_CHECKING: from collections.abc import Callable, Sequence diff --git a/src/stcal/jump/jump.py b/src/stcal/jump/jump.py index 9eaecf664..8c17c2325 100644 --- a/src/stcal/jump/jump.py +++ b/src/stcal/jump/jump.py @@ -3,12 +3,10 @@ import time import warnings -import numpy as np -import cv2 as cv import astropy.stats as stats - -from astropy.convolution import Ring2DKernel -from astropy.convolution import convolve +import cv2 as cv +import numpy as np +from astropy.convolution import Ring2DKernel, convolve from . import constants from . import twopoint_difference as twopt @@ -760,7 +758,6 @@ def extend_ellipses( saty, satx = np.where(sat_pix == sat_flag) jump_ellipse[saty, satx] = 0 out_gdq_cube[intg, flg_grp, :, :] = np.bitwise_or(gdq_cube[intg, flg_grp, :, :], jump_ellipse) - diff_cube = out_gdq_cube - gdq_cube return out_gdq_cube, num_ellipses def find_last_grp(grp, ngrps, num_grps_masked): diff --git a/src/stcal/jump/twopoint_difference.py b/src/stcal/jump/twopoint_difference.py index 5be6b595a..6b480df45 100644 --- a/src/stcal/jump/twopoint_difference.py +++ b/src/stcal/jump/twopoint_difference.py @@ -2,7 +2,6 @@ import warnings import numpy as np -import warnings from astropy import stats log = logging.getLogger(__name__) @@ -490,7 +489,6 @@ def calc_med_first_diffs(in_first_diffs): return np.nan if first_diffs.ndim == 2: # in the case where input is a single pixel - nansum = np.sum(np.isnan(first_diffs), axis=(0, 1)) num_usable_diffs = first_diffs.size - np.sum(np.isnan(first_diffs), axis=(0, 1)) if num_usable_diffs >= 4: # if 4+, clip largest and return median mask = np.ones_like(first_diffs).astype(bool) @@ -500,7 +498,6 @@ def calc_med_first_diffs(in_first_diffs): elif num_usable_diffs == 3: # if 3, no clipping just return median return np.nanmedian(first_diffs) elif num_usable_diffs == 2: # if 2, return diff with minimum abs - TEST = np.nanargmin(np.abs(first_diffs)) diff_min_idx = np.nanargmin(first_diffs) location = np.unravel_index(diff_min_idx, first_diffs.shape) return first_diffs[location] diff --git a/src/stcal/outlier_detection/utils.py b/src/stcal/outlier_detection/utils.py index 886fac379..d0a43a4b2 100644 --- a/src/stcal/outlier_detection/utils.py +++ b/src/stcal/outlier_detection/utils.py @@ -1,18 +1,18 @@ """ Utility functions for outlier detection routines """ -import warnings +import logging + +import gwcs import numpy as np from astropy.stats import sigma_clip from drizzle.cdrizzle import tblot from scipy import ndimage from skimage.util import view_as_windows -import gwcs from stcal.alignment.util import wcs_bbox_from_shape -import logging log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) diff --git a/src/stcal/ramp_fitting/likely_algo_classes.py b/src/stcal/ramp_fitting/likely_algo_classes.py index fc71fd9f2..2d9e472a6 100644 --- a/src/stcal/ramp_fitting/likely_algo_classes.py +++ b/src/stcal/ramp_fitting/likely_algo_classes.py @@ -278,6 +278,9 @@ def calc_bias(self, countrates, sig, cvec, da=1e-7): Bias of the best-fit count rate from using cvec plus the observed resultants to estimate the covariance matrix. """ + + from .likely_fit import fit_ramps + alpha = countrates[np.newaxis, :] * self.alpha_phnoise[:, np.newaxis] alpha += sig**2 * self.alpha_readnoise[:, np.newaxis] beta = countrates[np.newaxis, :] * self.beta_phnoise[:, np.newaxis] @@ -291,8 +294,6 @@ def calc_bias(self, countrates, sig, cvec, da=1e-7): # try to avoid problems with roundoff error da_incr = da * (countrates[np.newaxis, :] + sig**2) - dalpha = da_incr * self.alpha_phnoise[:, np.newaxis] - dbeta = da_incr * self.beta_phnoise[:, np.newaxis] result_high_a = fit_ramps(z, self, sig, countrateguess=countrates + da_incr) # finite difference approximation to dw/da diff --git a/src/stcal/ramp_fitting/likely_fit.py b/src/stcal/ramp_fitting/likely_fit.py index 7a17fa971..a009c9a5c 100644 --- a/src/stcal/ramp_fitting/likely_fit.py +++ b/src/stcal/ramp_fitting/likely_fit.py @@ -1,20 +1,13 @@ #! /usr/bin/env python import logging -import multiprocessing -import time -import scipy -import sys import warnings -from multiprocessing import cpu_count -from pprint import pprint - import numpy as np +import scipy -from . import ramp_fit_class, utils -from .likely_algo_classes import IntegInfo, RampResult, Covar - +from . import utils +from .likely_algo_classes import Covar, IntegInfo, RampResult DELIM = "=" * 80 SQRT2 = np.sqrt(2) diff --git a/src/stcal/ramp_fitting/ols_fit.py b/src/stcal/ramp_fitting/ols_fit.py index 801990808..3a283d4a6 100644 --- a/src/stcal/ramp_fitting/ols_fit.py +++ b/src/stcal/ramp_fitting/ols_fit.py @@ -2,16 +2,15 @@ import logging import multiprocessing +import sys import time import warnings from multiprocessing import cpu_count -import sys import numpy as np -from .slope_fitter import ols_slope_fitter # c extension from . import ramp_fit_class, utils - +from .slope_fitter import ols_slope_fitter # c extension log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) diff --git a/src/stcal/ramp_fitting/ramp_fit.py b/src/stcal/ramp_fitting/ramp_fit.py index b5981c071..050e538d5 100755 --- a/src/stcal/ramp_fitting/ramp_fit.py +++ b/src/stcal/ramp_fitting/ramp_fit.py @@ -19,9 +19,9 @@ from astropy import units as u from . import ( - gls_fit, # used only if algorithm is "GLS" - likely_fit, # used only if algorithm is "LIKELY" - ols_fit, # used only if algorithm is "OLS" + gls_fit, # used only if algorithm is "GLS" + likely_fit, # used only if algorithm is "LIKELY" + ols_fit, # used only if algorithm is "OLS" ramp_fit_class, ) @@ -261,9 +261,9 @@ def ramp_fit_data( # a minimum of a four group ramp is needed. ngroups = ramp_data.data.shape[1] if algorithm.upper() == "LIKELY" and ngroups < likely_fit.LIKELY_MIN_NGROUPS: - log.info(f"When selecting the LIKELY ramp fitting algorithm the" - " ngroups needs to be a minimum of {likely_fit.LIKELY_MIN_NGROUPS}," - " but ngroups = {ngroups}. Due to this, the ramp fitting algorithm" + log.info("When selecting the LIKELY ramp fitting algorithm the" + f" ngroups needs to be a minimum of {likely_fit.LIKELY_MIN_NGROUPS}," + f" but ngroups = {ngroups}. Due to this, the ramp fitting algorithm" " is being changed to OLS_C") algorithm = "OLS_C" diff --git a/src/stcal/ramp_fitting/ramp_fit_class.py b/src/stcal/ramp_fitting/ramp_fit_class.py index f611881d6..0989c1cb1 100644 --- a/src/stcal/ramp_fitting/ramp_fit_class.py +++ b/src/stcal/ramp_fitting/ramp_fit_class.py @@ -209,10 +209,10 @@ def dbg_print_basic_info(self): def dbg_print_pixel_info(self, row, col): print("-" * 80) - print(f" data") + print(" data") for integ in range(self.data.shape[0]): print(f"[{integ}] {self.data[integ, :, row, col]}") - print(f" groupdq") + print(" groupdq") for integ in range(self.data.shape[0]): print(f"[{integ}] {self.groupdq[integ, :, row, col]}") # print(f" err :\n{self.err[:, :, row, col]}") @@ -280,8 +280,8 @@ def dbg_write_ramp_data_pix_pixel(self, fname, row, col, gain, rnoise, fd): # XXX Make this a separate function delimiter = "-" * 40 - fd.write(f"{indent}# {delimiter}\n\n"); - fd.write(f"{indent}# ({row}, {col})\n\n"); + fd.write(f"{indent}# {delimiter}\n\n") + fd.write(f"{indent}# ({row}, {col})\n\n") nints = self.data.shape[0] diff --git a/src/stcal/ramp_fitting/utils.py b/src/stcal/ramp_fitting/utils.py index e735ce9b6..26209dd36 100644 --- a/src/stcal/ramp_fitting/utils.py +++ b/src/stcal/ramp_fitting/utils.py @@ -6,7 +6,6 @@ import numpy as np - log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) diff --git a/tests/outlier_detection/test_utils.py b/tests/outlier_detection/test_utils.py index fd72d9dc4..dc9cd3c68 100644 --- a/tests/outlier_detection/test_utils.py +++ b/tests/outlier_detection/test_utils.py @@ -1,20 +1,20 @@ import warnings import gwcs -import pytest import numpy as np +import pytest import scipy.signal from astropy.modeling import models from stcal.outlier_detection.utils import ( _abs_deriv, + calc_gwcs_pixmap, compute_weight_threshold, flag_crs, flag_resampled_crs, gwcs_blot, - calc_gwcs_pixmap, - reproject, medfilt, + reproject, ) diff --git a/tests/test_alignment.py b/tests/test_alignment.py index 6868985fa..946336426 100644 --- a/tests/test_alignment.py +++ b/tests/test_alignment.py @@ -10,17 +10,17 @@ from stcal.alignment import resample_utils from stcal.alignment.util import ( + _compute_fiducial_from_footprints, + _sregion_to_footprint, _validate_wcs_list, compute_fiducial, - _compute_fiducial_from_footprints, compute_s_region_imaging, compute_s_region_keyword, compute_scale, reproject, - _sregion_to_footprint, wcs_bbox_from_shape, wcs_from_footprints, - wcs_from_sregions + wcs_from_sregions, ) diff --git a/tests/test_infrastructure.py b/tests/test_infrastructure.py index 37e68482e..b09c37acf 100644 --- a/tests/test_infrastructure.py +++ b/tests/test_infrastructure.py @@ -1,16 +1,17 @@ """Tests of custom testing infrastructure""" -import pytest import numpy as np +import pytest + from stcal.testing_helpers import MemoryThreshold, MemoryThresholdExceeded def test_memory_threshold(): with MemoryThreshold("10 KB"): - buff = np.ones(1000, dtype=np.uint8) + buff = np.ones(1000, dtype=np.uint8) # noqa: F841 def test_memory_threshold_exceeded(): with pytest.raises(MemoryThresholdExceeded): with MemoryThreshold("500. B"): - buff = np.ones(10000, dtype=np.uint8) \ No newline at end of file + buff = np.ones(10000, dtype=np.uint8) # noqa: F841 diff --git a/tests/test_jump.py b/tests/test_jump.py index c06a76a9b..805a81b7b 100644 --- a/tests/test_jump.py +++ b/tests/test_jump.py @@ -1,16 +1,16 @@ import numpy as np import pytest from astropy.io import fits + from stcal.jump.jump import ( calc_num_slices, + detect_jumps, extend_saturation, find_ellipses, find_faint_extended, + find_last_grp, flag_large_events, point_inside_ellipse, - find_first_good_group, - detect_jumps, - find_last_grp ) DQFLAGS = {"JUMP_DET": 4, "SATURATED": 2, "DO_NOT_USE": 1, "GOOD": 0, "NO_GAIN_VALUE": 8, @@ -207,7 +207,6 @@ def test_extend_saturation_simple(): cube = np.zeros(shape=(5, 7, 7), dtype=np.uint8) persist_jumps = np.zeros(shape=(7, 7), dtype=np.uint8) grp = 1 - min_sat_radius_extend = 1 cube[1, 3, 3] = DQFLAGS["SATURATED"] cube[1, 2, 3] = DQFLAGS["SATURATED"] cube[1, 3, 4] = DQFLAGS["SATURATED"] @@ -485,42 +484,6 @@ def test_find_faint_extended_sigclip(): # Check that the flags are not applied in the 3rd group after the event assert np.all(gdq[0, 4, 12:22, 14:23]) == 0 -# No shower is found because the event is identical in all ints -def test_find_faint_extended_sigclip(): - nint, ngrps, ncols, nrows = 101, 6, 30, 30 - data = np.zeros(shape=(nint, ngrps, nrows, ncols), dtype=np.float32) - gdq = np.zeros_like(data, dtype=np.uint8) - pdq = np.zeros(shape=(nrows, ncols), dtype=np.int32) - gain = 4 - readnoise = np.ones(shape=(nrows, ncols), dtype=np.float32) * 6.0 * gain - rng = np.random.default_rng(12345) - data[0, 1:, 14:20, 15:20] = 6 * gain * 1.7 - data = data + rng.normal(size=(nint, ngrps, nrows, ncols)) * readnoise - gdq, num_showers = find_faint_extended(data, gdq, pdq, readnoise, 1, 100, - snr_threshold=1.3, - min_shower_area=20, inner=1, - outer=2, sat_flag=2, jump_flag=4, - ellipse_expand=1.1, num_grps_masked=3, - dqflags=DQFLAGS) - # Check that all the expected samples in group 2 are flagged as jump and - # that they are not flagged outside - assert (np.all(gdq[0, 1, 22, 14:23] == 0)) - assert (np.all(gdq[0, 1, 21, 16:20] == 0)) - assert (np.all(gdq[0, 1, 20, 15:22] == 0)) - assert (np.all(gdq[0, 1, 19, 15:23] == 0)) - assert (np.all(gdq[0, 1, 18, 14:23] == 0)) - assert (np.all(gdq[0, 1, 17, 14:23] == 0)) - assert (np.all(gdq[0, 1, 16, 14:23] == 0)) - assert (np.all(gdq[0, 1, 15, 14:22] == 0)) - assert (np.all(gdq[0, 1, 14, 16:22] == 0)) - assert (np.all(gdq[0, 1, 13, 17:21] == 0)) - assert (np.all(gdq[0, 1, 12, 14:23] == 0)) - assert (np.all(gdq[0, 1, 12:23, 24] == 0)) - assert (np.all(gdq[0, 1, 12:23, 13] == 0)) - - # Check that the flags are not applied in the 3rd group after the event - assert (np.all(gdq[0, 4, 12:22, 14:23]) == 0) - def test_inside_ellipse5(): ellipse = ((0, 0), (1, 2), -10) diff --git a/tests/test_ramp_fitting.py b/tests/test_ramp_fitting.py index b99eeace7..750898a9c 100644 --- a/tests/test_ramp_fitting.py +++ b/tests/test_ramp_fitting.py @@ -1,14 +1,12 @@ -import pytest -import numpy as np - import sys +import numpy as np + from stcal.ramp_fitting.ramp_fit import ramp_fit_data from stcal.ramp_fitting.ramp_fit_class import RampData from stcal.ramp_fitting.slope_fitter import ols_slope_fitter # c extension from stcal.ramp_fitting.utils import compute_num_slices - DELIM = "=" * 70 # single group integrations fail in the GLS fitting @@ -1476,7 +1474,6 @@ def test_one_group(): sdata, sdq, svp, svr, serr = slopes # XXX JP-3121: this is the value from python, which may not be correct - chk_data = 1.9618962 chk_dq = 0 chk_var_p = 0.02923839 chk_var_r = 0.03470363 @@ -1484,7 +1481,6 @@ def test_one_group(): # XXX Investigate. Now python may be wrong. - # assert abs(sdata[0, 0] - chk_data) < tol assert sdq[0, 0] == chk_dq assert abs(svp[0, 0] - chk_var_p) < tol assert abs(svr[0, 0] - chk_var_r) < tol @@ -1578,7 +1574,6 @@ def test_cext_chargeloss(): rnval, gval = 0.7071, 1. # frame_time, nframes, groupgap = 1., 1, 0 frame_time, nframes, groupgap = 10.6, 1, 0 - group_time = 10.6 dims = nints, ngroups, nrows, ncols var = rnval, gval @@ -1843,7 +1838,8 @@ def dbg_print(string): """ Print string with line number and filename. """ - import inspect, os + import inspect + import os cf = inspect.currentframe() line_number = cf.f_back.f_lineno finfo = inspect.getframeinfo(cf.f_back) diff --git a/tests/test_ramp_fitting_cases.py b/tests/test_ramp_fitting_cases.py index 913b86dc3..0fdf9918b 100644 --- a/tests/test_ramp_fitting_cases.py +++ b/tests/test_ramp_fitting_cases.py @@ -1,7 +1,6 @@ import inspect from pathlib import Path -import pytest import numpy as np import numpy.testing as npt diff --git a/tests/test_ramp_fitting_likely_fit.py b/tests/test_ramp_fitting_likely_fit.py index 09ac883b8..2d5ed911b 100644 --- a/tests/test_ramp_fitting_likely_fit.py +++ b/tests/test_ramp_fitting_likely_fit.py @@ -1,10 +1,9 @@ import numpy as np import pytest -from stcal.ramp_fitting.ramp_fit import ramp_fit_class, ramp_fit_data -from stcal.ramp_fitting.ramp_fit_class import RampData from stcal.ramp_fitting.likely_fit import likely_ramp_fit - +from stcal.ramp_fitting.ramp_fit import ramp_fit_data +from stcal.ramp_fitting.ramp_fit_class import RampData test_dq_flags = { "GOOD": 0, @@ -611,7 +610,7 @@ def dbg_print_slopes(slope, pix=(0, 0), label=None): def dbg_print_cube(cube, pix=(0, 0), label=None): data, dq, vp, vr, err = cube - data1, dq1, vp1, vr1, err1 = cube1 + data1, dq1, vp1, vr1, err1 = cube1 # noqa: F821 row, col = pix nints = data1.shape[0] diff --git a/tests/test_tweakreg.py b/tests/test_tweakreg.py index 335c62c68..18d893d25 100644 --- a/tests/test_tweakreg.py +++ b/tests/test_tweakreg.py @@ -1,13 +1,14 @@ """Test astrometric utility functions for alignment""" +import contextlib import copy from copy import deepcopy from pathlib import Path import asdf -import contextlib import numpy as np import pytest +import requests from astropy.modeling.models import Shift from astropy.table import Table from astropy.time import Time @@ -23,7 +24,6 @@ relative_align, ) from stcal.tweakreg.utils import _wcsinfo_from_wcs_transform -import requests # Define input GWCS specification to be used for these tests WCS_NAME = "mosaic_long_i2d_gwcs.asdf" # Derived using B7.5 Level 3 product diff --git a/tests/test_twopoint_difference.py b/tests/test_twopoint_difference.py index ce6d7b145..c54d88783 100644 --- a/tests/test_twopoint_difference.py +++ b/tests/test_twopoint_difference.py @@ -1,6 +1,6 @@ import numpy as np -from astropy.io import fits import pytest +from astropy.io import fits from stcal.jump.twopoint_difference import calc_med_first_diffs, find_crs @@ -645,7 +645,6 @@ def test_5grps_satat4_crat3(setup_cube): rej_threshold, rej_threshold, nframes, False, 200, 10, DQFLAGS) # assert(4 == np.max(out_gdq)) # no CR was found - result = out_gdq[0, :, 1, 1] assert np.array_equal( [0, 0, DQFLAGS['JUMP_DET'], DQFLAGS['SATURATED'], DQFLAGS['SATURATED']], out_gdq[0, :, 1, 1]) @@ -758,7 +757,6 @@ def test_median_with_saturation(setup_cube): out_gdq, row_below_gdq, rows_above_gdq, total_crs, stddev = find_crs(data, gdq, read_noise, rej_threshold, rej_threshold, rej_threshold, nframes, False, 200, 10, DQFLAGS) - gdq_value = out_gdq[0, :, 1, 1] assert (np.array_equal([0, 0, 0, 0, 0, 4, 0, 2, 2, 2], out_gdq[0, :, 1, 1]))