Skip to content

Commit

Permalink
Fix issues found during pre-commit update attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamJamieson committed Oct 17, 2024
1 parent 9849e3a commit 97f7ef8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 21 deletions.
6 changes: 3 additions & 3 deletions romancal/dark_current/tests/test_dark.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_dark_step_interface(instrument, exptype):

# Test dark results
assert (result.data == ramp_model.data).all()
assert type(result) == RampModel
assert isinstance(result, RampModel)
assert result.validate() is None
assert result.data.shape == shape
assert result.groupdq.shape == shape
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_dark_step_output_dark_file(tmp_path, instrument, exptype):
dark_out_file_model = rdm.open(path)

# Test dark file results
assert type(dark_out_file_model) == DarkRefModel
assert isinstance(dark_out_file_model, DarkRefModel)
assert dark_out_file_model.validate() is None
assert dark_out_file_model.data.shape == shape
assert dark_out_file_model.dq.shape == shape[1:]
Expand Down Expand Up @@ -132,7 +132,7 @@ def test_dark_step_getbestrefs(tmp_path, instrument, exptype):
dark_out_file_model = rdm.open(path)

# Test dark file results
assert type(dark_out_file_model) == DarkRefModel
assert isinstance(dark_out_file_model, DarkRefModel)
assert dark_out_file_model.validate() is None
assert dark_out_file_model.data.shape == shape
assert dark_out_file_model.dq.shape == shape[1:]
Expand Down
3 changes: 1 addition & 2 deletions romancal/linearity/tests/test_linearity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

import numpy as np
import pytest
from roman_datamodels import maker_utils
from roman_datamodels import dqflags, maker_utils
from roman_datamodels.datamodels import LinearityRefModel, ScienceRawModel

from romancal.dq_init import DQInitStep
from romancal.lib import dqflags
from romancal.linearity import LinearityStep


Expand Down
4 changes: 1 addition & 3 deletions romancal/resample/tests/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,9 @@ def test_resampledata_init_default(exposure_1):
@pytest.mark.parametrize("input_models", [list()])
def test_resampledata_init_invalid_input(input_models):
"""Test that ResampleData will raise an exception on invalid inputs."""
with pytest.raises(Exception) as exec_info:
with pytest.raises(ValueError):
ResampleData(input_models)

assert type(exec_info.value) == ValueError


def test_resampledata_do_drizzle_many_to_one_default_no_rotation_single_exposure(
exposure_1,
Expand Down
22 changes: 9 additions & 13 deletions romancal/tweakreg/tests/test_tweakreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ def test_tweakreg_raises_error_on_invalid_abs_refcat(tmp_path, base_image):
img = base_image(shift_1=1000, shift_2=1000)
add_tweakreg_catalog_attribute(tmp_path, img)

with pytest.raises(Exception) as exec_info:
with pytest.raises(TypeError):
trs.TweakRegStep.call(
[img],
save_abs_catalog=True,
Expand All @@ -695,8 +695,6 @@ def test_tweakreg_raises_error_on_invalid_abs_refcat(tmp_path, base_image):
output_dir=str(tmp_path),
)

assert type(exec_info.value) == TypeError


def test_tweakreg_combine_custom_catalogs_and_asn_file(tmp_path, base_image):
"""
Expand Down Expand Up @@ -737,7 +735,7 @@ def test_tweakreg_combine_custom_catalogs_and_asn_file(tmp_path, base_image):
catfile=catfile,
)

assert type(res) == ModelLibrary
assert isinstance(res, ModelLibrary)

with res:
for i, (model, target) in enumerate(zip(res, [img1, img2, img3])):
Expand All @@ -750,7 +748,7 @@ def test_tweakreg_combine_custom_catalogs_and_asn_file(tmp_path, base_image):

assert model.meta.filename == target.meta.filename

assert type(model) == type(target)
assert type(model) is type(target)

assert (model.data == target.data).all()

Expand Down Expand Up @@ -853,7 +851,7 @@ def test_tweakreg_parses_asn_correctly(tmp_path, base_image):

res = trs.TweakRegStep.call(asn_filepath)

assert type(res) == ModelLibrary
assert isinstance(res, ModelLibrary)

with res:
models = list(res)
Expand All @@ -872,8 +870,8 @@ def test_tweakreg_parses_asn_correctly(tmp_path, base_image):
assert models[0].meta.filename == img_1.meta.filename
assert models[1].meta.filename == img_2.meta.filename

assert type(models[0]) == type(img_1)
assert type(models[1]) == type(img_2)
assert type(models[0]) is type(img_1)
assert type(models[1]) is type(img_2)

assert (models[0].data == img_1.data).all()
assert (models[1].data == img_2.data).all()
Expand All @@ -891,7 +889,7 @@ def test_fit_results_in_meta(tmp_path, base_image):

res = trs.TweakRegStep.call([img])

assert type(res) == ModelLibrary
assert isinstance(res, ModelLibrary)
with res:
for i, model in enumerate(res):
assert hasattr(model.meta, "wcs_fit_results")
Expand Down Expand Up @@ -995,11 +993,9 @@ def test_parse_catfile_raises_error_on_invalid_content(tmp_path, catfile_line_co
with open(catfile, mode="w") as f:
print(catfile_content.getvalue(), file=f)

with pytest.raises(Exception) as exec_info:
with pytest.raises(ValueError):
trs._parse_catfile(catfile)

assert type(exec_info.value) == ValueError


def test_update_source_catalog_coordinates(tmp_path, base_image):
"""Test that TweakReg updates the catalog coordinates with the tweaked WCS."""
Expand Down Expand Up @@ -1234,7 +1230,7 @@ def test_tweakreg_skips_invalid_exposure_types(exposure_type, tmp_path, base_ima
img2.meta.exposure.type = exposure_type
res = trs.TweakRegStep.call([img1, img2])

assert type(res) == ModelLibrary
assert isinstance(res, ModelLibrary)
with res:
for i, model in enumerate(res):
assert hasattr(model.meta.cal_step, "tweakreg")
Expand Down

0 comments on commit 97f7ef8

Please sign in to comment.