Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 13, 2025
1 parent e77661d commit 9d47863
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 88 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def check_sphinx_version(expected_version):

# General information about the project
project = setup_cfg["name"]
author = f'{setup_cfg["authors"][0]["name"]} <{setup_cfg["authors"][0]["email"]}>'
author = f"{setup_cfg['authors'][0]['name']} <{setup_cfg['authors'][0]['email']}>"
copyright = f"{datetime.datetime.now().year}, {author}"

# The version info for the project you're documenting, acts as replacement for
Expand Down
4 changes: 1 addition & 3 deletions docs/exts/numfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ def doctree_resolved(app, doctree, docname):
if app.builder.name == "html":
target_doc = app.builder.env.figid_docname_map[target]
link = f"{app.builder.get_relative_uri(docname, target_doc)}#{target}"
html = (
f'<a class="pageref" href="{link}">{labelfmt %(figids[target])}</a>'
)
html = f'<a class="pageref" href="{link}">{labelfmt % (figids[target])}</a>'
ref_info.replace_self(raw(html, html, format="html"))
else:
ref_info.replace_self(Text(labelfmt % (figids[target])))
Expand Down
2 changes: 1 addition & 1 deletion romancal/associations/lib/process_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def update(self, process_list, full=False):
self.only_on_match = process_list.only_on_match

def __str__(self):
result = f"{self.__class__.__name__}(n_items: {len(self.items)}, {({str_attr: getattr(self, str_attr) for str_attr in self._str_attrs})})"
result = f"{self.__class__.__name__}(n_items: {len(self.items)}, { ({str_attr: getattr(self, str_attr) for str_attr in self._str_attrs}) })"

Check warning on line 157 in romancal/associations/lib/process_list.py

View check run for this annotation

Codecov / codecov/patch

romancal/associations/lib/process_list.py#L157

Added line #L157 was not covered by tests
return result


Expand Down
6 changes: 2 additions & 4 deletions romancal/associations/lib/rules_elpp_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,7 @@ def _dms_product_name(association):
if subarray:
subarray = "-" + subarray

product_name = (
"r{program}-{acid}" "_{target}" "_{instrument}" "_{opt_elem}{subarray}"
)
product_name = "r{program}-{acid}_{target}_{instrument}_{opt_elem}{subarray}"
if "Full" in association.data["asn_rule"]:
subarray = "Full"

Expand Down Expand Up @@ -396,7 +394,7 @@ def _add(self, item):
members.append(member)
if member["exposerr"] not in _EMPTY:
logger.warning(
f"Member {item['filename']} has exposure error \"{member['exposerr']}\""
f'Member {item["filename"]} has exposure error "{member["exposerr"]}"'
)

# Update meta info
Expand Down
4 changes: 1 addition & 3 deletions romancal/associations/skycell_asn.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ def _cli(args=None):
"--rule",
type=str,
default="DMS_ELPP_Base",
help=(
"The rule to base the association structure on." ' Default: "%(default)s"'
),
help=('The rule to base the association structure on. Default: "%(default)s"'),
)
parser.add_argument(
"-i",
Expand Down
2 changes: 1 addition & 1 deletion romancal/ramp_fitting/ramp_fit_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def ols_cas22(self, input_model, readnoise_model, gain_model, dark_model):
# Force read pattern to be pure lists not LNodes
read_pattern = [list(reads) for reads in input_model.meta.exposure.read_pattern]
if len(read_pattern) != resultants.shape[0]:
raise RuntimeError("mismatch between resultants shape and " "read_pattern.")
raise RuntimeError("mismatch between resultants shape and read_pattern.")

# add dark current back into resultants so that Poisson noise is
# properly accounted for
Expand Down
91 changes: 46 additions & 45 deletions romancal/regtest/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,38 +31,37 @@ def test_resample_single_file(rtdata, ignore_asdf_paths):

step.log.info(
"ResampleStep recorded as complete? :"
f' {resample_out.meta.cal_step.resample == "COMPLETE"}'
f" {resample_out.meta.cal_step.resample == 'COMPLETE'}"
)
assert resample_out.meta.cal_step.resample == "COMPLETE"

step.log.info(
"ResampleStep created 'meta.resample'? :"
f' {hasattr(resample_out.meta, "resample")}'
f" {hasattr(resample_out.meta, 'resample')}"
)
assert hasattr(resample_out.meta, "resample")

step.log.info(
f"""DMS342 MSG: Was ICRS used as the mosaic astrometric reference frame? :\
{
resample_out.meta.coordinates.reference_frame == "ICRS"
}
{resample_out.meta.coordinates.reference_frame == "ICRS"}
"""
)
assert resample_out.meta.coordinates.reference_frame == "ICRS"

step.log.info(
f"""DMS343 MSG: ResampleStep created new attribute data quality information? :\
{
all(
hasattr(resample_out, x) for x in [
"data",
"err",
"var_poisson",
"var_rnoise",
"var_flat",
]
)
}"""
all(
hasattr(resample_out, x)
for x in [
"data",
"err",
"var_poisson",
"var_rnoise",
"var_flat",
]
)
}"""
)
assert all(
hasattr(resample_out, x)
Expand All @@ -72,13 +71,14 @@ def test_resample_single_file(rtdata, ignore_asdf_paths):
step.log.info(
f"""DMS343 MSG: Were the variance arrays populated (variance propagation)? :\
{
all(
np.sum(~np.isnan(getattr(resample_out, x))) for x in [
"var_poisson",
"var_rnoise",
]
)
}"""
all(
np.sum(~np.isnan(getattr(resample_out, x)))
for x in [
"var_poisson",
"var_rnoise",
]
)
}"""
)
assert all(
np.sum(~np.isnan(getattr(resample_out, x)))
Expand All @@ -88,16 +88,17 @@ def test_resample_single_file(rtdata, ignore_asdf_paths):
step.log.info(
f"""DMS343 MSG: Are there NaNs or zeros in the variance arrays, indicating poor data quality? :\
{
any(
np.sum(
np.logical_or(
np.isnan(getattr(resample_out, x)),
np.equal(getattr(resample_out, x), 0)
)
) > 0 for x in ["var_poisson", "var_rnoise", "var_flat"]
any(
np.sum(
np.logical_or(
np.isnan(getattr(resample_out, x)),
np.equal(getattr(resample_out, x), 0),
)
)
}"""
> 0
for x in ["var_poisson", "var_rnoise", "var_flat"]
)
}"""
)
assert all(
np.sum(np.isnan(getattr(resample_out, x)))
Expand All @@ -114,19 +115,19 @@ def test_resample_single_file(rtdata, ignore_asdf_paths):
step.log.info(
f"""DMS345 MSG: ResampleStep included all metadata relevant to the creation of the mosaic? :\
{
all(
hasattr(resample_out.meta.resample, x)
and bool(getattr(resample_out.meta.resample, x))
for x in [
"pixel_scale_ratio",
"pixfrac",
"pointings",
"product_exposure_time",
"weight_type",
"members",
]
)
}"""
all(
hasattr(resample_out.meta.resample, x)
and bool(getattr(resample_out.meta.resample, x))
for x in [
"pixel_scale_ratio",
"pixfrac",
"pointings",
"product_exposure_time",
"weight_type",
"members",
]
)
}"""
)
assert all(
hasattr(resample_out.meta.resample, x)
Expand All @@ -142,5 +143,5 @@ def test_resample_single_file(rtdata, ignore_asdf_paths):
)

diff = compare_asdf(rtdata.output, rtdata.truth, **ignore_asdf_paths)
step.log.info("Was the proper Resample data produced?" f" : {diff.identical}")
step.log.info(f"Was the proper Resample data produced? : {diff.identical}")
assert diff.identical, diff.report()
2 changes: 1 addition & 1 deletion romancal/regtest/test_tweakreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_tweakreg(rtdata, ignore_asdf_paths, tmp_path):

step.log.info(
"DMS280 MSG: TweakReg step recorded as complete? :"
f' {tweakreg_out.meta.cal_step.tweakreg == "COMPLETE"}'
f" {tweakreg_out.meta.cal_step.tweakreg == 'COMPLETE'}"
)
assert tweakreg_out.meta.cal_step.tweakreg == "COMPLETE"

Expand Down
12 changes: 6 additions & 6 deletions romancal/regtest/test_wfi_dq_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ def test_dq_init_image_step(rtdata, ignore_asdf_paths):
"mask file applied."
)

step.log.info(f'DMS25 MSG: First data file: {rtdata.input.rsplit("/", 1)[1]}')
step.log.info(f"DMS25 MSG: First data file: {rtdata.input.rsplit('/', 1)[1]}")
ref_file_path = step.get_reference_file(model, "mask")
step.log.info(
f'DMS25 MSG: CRDS matched mask file: {ref_file_path.rsplit("/", 1)[1]}'
f"DMS25 MSG: CRDS matched mask file: {ref_file_path.rsplit('/', 1)[1]}"
)
ref_file_name = os.path.split(ref_file_path)[-1]

Expand All @@ -52,7 +52,7 @@ def test_dq_init_image_step(rtdata, ignore_asdf_paths):
ramp_out = rdm.open(rtdata.output)
step.log.info(
"DMS25 MSG: Does ramp data contain pixeldq from mask file? :"
f' {("roman.pixeldq" in ramp_out.to_flat_dict())}'
f" {('roman.pixeldq' in ramp_out.to_flat_dict())}"
)
assert "roman.pixeldq" in ramp_out.to_flat_dict()

Expand Down Expand Up @@ -85,10 +85,10 @@ def test_dq_init_grism_step(rtdata, ignore_asdf_paths):
"mask file applied."
)

step.log.info(f'DMS25 MSG: First data file: {rtdata.input.rsplit("/", 1)[1]}')
step.log.info(f"DMS25 MSG: First data file: {rtdata.input.rsplit('/', 1)[1]}")
ref_file_path = step.get_reference_file(model, "mask")
step.log.info(
f'DMS25 MSG: CRDS matched mask file: {ref_file_path.rsplit("/", 1)[1]}'
f"DMS25 MSG: CRDS matched mask file: {ref_file_path.rsplit('/', 1)[1]}"
)
ref_file_name = os.path.split(ref_file_path)[-1]

Expand All @@ -107,7 +107,7 @@ def test_dq_init_grism_step(rtdata, ignore_asdf_paths):
ramp_out = rdm.open(rtdata.output)
step.log.info(
"DMS25 MSG: Does ramp data contain pixeldq from mask file? :"
f' {("roman.pixeldq" in ramp_out.to_flat_dict())}'
f" {('roman.pixeldq' in ramp_out.to_flat_dict())}"
)
assert "roman.pixeldq" in ramp_out.to_flat_dict()

Expand Down
20 changes: 8 additions & 12 deletions romancal/regtest/test_wfi_flat_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ def test_flat_field_crds_match_image_step(rtdata, ignore_asdf_paths):
" correct use after date"
)

step.log.info(f'DMS79 MSG: First data file: {rtdata.input.rsplit("/", 1)[1]}')
step.log.info(f"DMS79 MSG: First data file: {rtdata.input.rsplit('/', 1)[1]}")
step.log.info(f"DMS79 MSG: Observation date: {model.meta.exposure.start_time}")

ref_file_path = step.get_reference_file(model, "flat")
step.log.info(
f'DMS79 MSG: CRDS matched flat file: {ref_file_path.rsplit("/", 1)[1]}'
f"DMS79 MSG: CRDS matched flat file: {ref_file_path.rsplit('/', 1)[1]}"
)
flat = rdm.open(ref_file_path)
step.log.info(f"DMS79 MSG: flat file UseAfter date: {flat.meta.useafter}")
Expand All @@ -118,9 +118,7 @@ def test_flat_field_crds_match_image_step(rtdata, ignore_asdf_paths):

diff = compare_asdf(rtdata.output, rtdata.truth, **ignore_asdf_paths)
step.log.info(
"DMS79 MSG: Was proper flat fielded "
"Level 2 data produced? : "
f"{diff.identical}"
f"DMS79 MSG: Was proper flat fielded Level 2 data produced? : {diff.identical}"
)
assert diff.identical, diff.report()

Expand All @@ -137,12 +135,12 @@ def test_flat_field_crds_match_image_step(rtdata, ignore_asdf_paths):
step = FlatFieldStep()
model = rdm.open(rtdata.input)

step.log.info(f'DMS79 MSG: Second data file: {rtdata.input.rsplit("/", 1)[1]}')
step.log.info(f"DMS79 MSG: Second data file: {rtdata.input.rsplit('/', 1)[1]}")
step.log.info(f"DMS79 MSG: Observation date: {model.meta.exposure.start_time}")

ref_file_path_b = step.get_reference_file(model, "flat")
step.log.info(
f'DMS79 MSG: CRDS matched flat file: {ref_file_path_b.rsplit("/", 1)[1]}'
f"DMS79 MSG: CRDS matched flat file: {ref_file_path_b.rsplit('/', 1)[1]}"
)
flat = rdm.open(ref_file_path_b)
step.log.info(f"DMS79 MSG: flat file UseAfter date: {flat.meta.useafter}")
Expand All @@ -164,18 +162,16 @@ def test_flat_field_crds_match_image_step(rtdata, ignore_asdf_paths):
rtdata.get_truth(f"truth/WFI/image/{output}")
diff = compare_asdf(rtdata.output, rtdata.truth, **ignore_asdf_paths)
step.log.info(
"DMS79 MSG: Was proper flat fielded "
"Level 2 data produced? : "
f"{diff.identical}"
f"DMS79 MSG: Was proper flat fielded Level 2 data produced? : {diff.identical}"
)
assert diff.identical, diff.report()

# Test differing flat matches
step.log.info(
"DMS79 MSG REQUIRED TEST: Are the two data files "
"matched to different flat files? : "
f'{("/".join(ref_file_path.rsplit("/", 3)[1:]))} != '
f'{("/".join(ref_file_path_b.rsplit("/", 3)[1:]))}'
f"{('/'.join(ref_file_path.rsplit('/', 3)[1:]))} != "
f"{('/'.join(ref_file_path_b.rsplit('/', 3)[1:]))}"
)
assert "/".join(ref_file_path.rsplit("/", 1)[1:]) != "/".join(
ref_file_path_b.rsplit("/", 1)[1:]
Expand Down
4 changes: 2 additions & 2 deletions romancal/regtest/test_wfi_photom.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_absolute_photometric_calibration(rtdata, ignore_asdf_paths):
"CRDS selected photom file applied."
)

step.log.info(f'DMS140 MSG: Image data file: {rtdata.input.rsplit("/", 1)[1]}')
step.log.info(f"DMS140 MSG: Image data file: {rtdata.input.rsplit('/', 1)[1]}")

# Note: if any of the following tests fail, check for a different
# photom match from CRDS. Values come from roman_wfi_photom_0034.asdf
Expand All @@ -52,7 +52,7 @@ def test_absolute_photometric_calibration(rtdata, ignore_asdf_paths):

step.log.info(
"DMS140 MSG: Photom step recorded as complete? :"
f' {photom_out.meta.cal_step.photom == "COMPLETE"}'
f" {photom_out.meta.cal_step.photom == 'COMPLETE'}"
)
assert photom_out.meta.cal_step.photom == "COMPLETE"

Expand Down
2 changes: 1 addition & 1 deletion romancal/resample/gwcs_drizzle.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def dodrizzle(
pixmap = resample_utils.calc_gwcs_pixmap(input_wcs, output_wcs, insci.shape)
# inwht[np.isnan(pixmap[:,:,0])] = 0.

log.debug(f"Pixmap shape: {pixmap[:,:,0].shape}")
log.debug(f"Pixmap shape: {pixmap[:, :, 0].shape}")
log.debug(f"Input Sci shape: {insci.shape}")
log.debug(f"Output Sci shape: {outsci.shape}")

Expand Down
2 changes: 1 addition & 1 deletion romancal/resample/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def drizzle_arrays(
# for use in drizzle.cdrizzle.tdriz
pixmap = resample_utils.calc_gwcs_pixmap(input_wcs, output_wcs, insci.shape)

log.debug(f"Pixmap shape: {pixmap[:,:,0].shape}")
log.debug(f"Pixmap shape: {pixmap[:, :, 0].shape}")
log.debug(f"Input Sci shape: {insci.shape}")
log.debug(f"Output Sci shape: {outsci.shape}")

Expand Down
Loading

0 comments on commit 9d47863

Please sign in to comment.