Skip to content

Commit

Permalink
chore: update pre-commit hooks (#28)
Browse files Browse the repository at this point in the history
* chore: update pre-commit hooks

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.8.3 → v0.9.2](astral-sh/ruff-pre-commit@v0.8.3...v0.9.2)
- [github.com/python-jsonschema/check-jsonschema: 0.30.0 → 0.31.0](python-jsonschema/check-jsonschema@0.30.0...0.31.0)

* style: pre-commit fixes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Jan 22, 2025
1 parent b9ea67a commit a94f2b4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repos:
args: [--prose-wrap=always]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.8.3"
rev: "v0.9.2"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand Down Expand Up @@ -70,7 +70,7 @@ repos:
additional_dependencies: ["validate-pyproject-schema-store[all]"]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.30.0"
rev: "0.31.0"
hooks:
- id: check-dependabot
- id: check-github-workflows
Expand Down
12 changes: 6 additions & 6 deletions fixms/fix_ms_corrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,12 +547,12 @@ async def fix_ms_corrs_coro(
# throughout the observation. For example, bandpass observations vary
# this direction as each beam cycles in the footprint cycles over the
# calibrator source.
assert (
len(feed1) == 1 and len(feed2) == 1
), "Found more than one feed orientation!"
assert (
feed1[0] == feed2[0]
), f"The unique feed entries available in the data table differ, {feed1=} {feed2=}"
assert len(feed1) == 1 and len(feed2) == 1, (
"Found more than one feed orientation!"
)
assert feed1[0] == feed2[0], (
f"The unique feed entries available in the data table differ, {feed1=} {feed2=}"
)

# The two assertions above should enforce enough constraint
# to make sure the rotation matrix constructed is correct
Expand Down
72 changes: 36 additions & 36 deletions tests/test_fix_ms_corrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,24 @@ def test_get_pol_axis(ms_standard_example, ms_rotated_example):
pol_axis_fixed = get_pol_axis(ms.fixed_ms_path, col="INSTRUMENT_RECEPTOR_ANGLE")
rot_pol_axis_fixed = get_pol_axis(ms.fixed_ms_path, col="RECEPTOR_ANGLE")

assert np.isclose(
pol_axis_original, ms.pol_axis
), f"Pol axis is incorrect {pol_axis_original=}"
assert np.isclose(
pol_axis_fixed, ms.pol_axis
), f"Pol axis is incorrect {pol_axis_fixed=}"
assert np.isclose(
rot_pol_axis_fixed, 0 * u.deg
), f"Pol axis is incorrect {rot_pol_axis_fixed=}"
assert np.isclose(pol_axis_original, ms.pol_axis), (
f"Pol axis is incorrect {pol_axis_original=}"
)
assert np.isclose(pol_axis_fixed, ms.pol_axis), (
f"Pol axis is incorrect {pol_axis_fixed=}"
)
assert np.isclose(rot_pol_axis_fixed, 0 * u.deg), (
f"Pol axis is incorrect {rot_pol_axis_fixed=}"
)


def test_column_exists(ms_standard_example, ms_rotated_example):
# Check that CORRECTED_DATA is on disk
for ms in (ms_standard_example, ms_rotated_example):
with table(ms.fixed_ms_path.as_posix()) as tab:
assert (
ms.corrected_data_column in tab.colnames()
), f"{ms.corrected_data_column} not in MS"
assert ms.corrected_data_column in tab.colnames(), (
f"{ms.corrected_data_column} not in MS"
)


def test_original_data(ms_standard_example, ms_rotated_example):
Expand Down Expand Up @@ -290,66 +290,66 @@ def get_wsclean_stokes(ms):
def test_rotated_data_I(ms_standard_example):
mueller_a = askap_stokes(ms_standard_example)
mueller_a_mat = askap_stokes_mat(ms_standard_example)
assert np.allclose(
mueller_a.stokes_I, mueller_a_mat.stokes_I, atol=1e-4
), "Stokes rotation I failed"
assert np.allclose(mueller_a.stokes_I, mueller_a_mat.stokes_I, atol=1e-4), (
"Stokes rotation I failed"
)


def test_rotated_data_Q(ms_standard_example):
mueller_a = askap_stokes(ms_standard_example)
mueller_a_mat = askap_stokes_mat(ms_standard_example)
assert np.allclose(
mueller_a.stokes_Q, mueller_a_mat.stokes_Q, atol=1e-4
), f"Stokes rotation Q failed for {ms_standard_example.fixed_ms_path.name}"
assert np.allclose(mueller_a.stokes_Q, mueller_a_mat.stokes_Q, atol=1e-4), (
f"Stokes rotation Q failed for {ms_standard_example.fixed_ms_path.name}"
)


def test_rotated_data_U(ms_standard_example):
mueller_a = askap_stokes(ms_standard_example)
mueller_a_mat = askap_stokes_mat(ms_standard_example)
assert np.allclose(
mueller_a.stokes_U, mueller_a_mat.stokes_U, atol=1e-4
), f"Stokes rotation U failed for {ms_standard_example.fixed_ms_path.name}"
assert np.allclose(mueller_a.stokes_U, mueller_a_mat.stokes_U, atol=1e-4), (
f"Stokes rotation U failed for {ms_standard_example.fixed_ms_path.name}"
)


def test_rotated_data_V(ms_standard_example):
mueller_a = askap_stokes(ms_standard_example)
mueller_a_mat = askap_stokes_mat(ms_standard_example)
assert np.allclose(
mueller_a.stokes_V, mueller_a_mat.stokes_V, atol=1e-4
), f"Stokes rotation V failed for {ms_standard_example.fixed_ms_path.name}"
assert np.allclose(mueller_a.stokes_V, mueller_a_mat.stokes_V, atol=1e-4), (
f"Stokes rotation V failed for {ms_standard_example.fixed_ms_path.name}"
)


def test_stokes_I(ms_standard_example, ms_rotated_example):
for ms in (ms_standard_example, ms_rotated_example):
mueller_a = askap_stokes_mat(ms)
mueller_w = get_wsclean_stokes(ms)
assert np.allclose(
mueller_a.stokes_I, mueller_w.stokes_I, atol=1e-4
), f"ASKAP and WSClean disagree on Stokes I in {ms.fixed_ms_path.name}"
assert np.allclose(mueller_a.stokes_I, mueller_w.stokes_I, atol=1e-4), (
f"ASKAP and WSClean disagree on Stokes I in {ms.fixed_ms_path.name}"
)


def test_stokes_Q(ms_standard_example, ms_rotated_example):
for ms in (ms_standard_example, ms_rotated_example):
mueller_a = askap_stokes_mat(ms)
mueller_w = get_wsclean_stokes(ms)
assert np.allclose(
mueller_a.stokes_Q, mueller_w.stokes_Q, atol=1e-1
), f"ASKAP and WSClean disagree on Stokes Q in {ms.fixed_ms_path.name}"
assert np.allclose(mueller_a.stokes_Q, mueller_w.stokes_Q, atol=1e-1), (
f"ASKAP and WSClean disagree on Stokes Q in {ms.fixed_ms_path.name}"
)


def test_stokes_U(ms_standard_example, ms_rotated_example):
for ms in (ms_standard_example, ms_rotated_example):
mueller_a = askap_stokes_mat(ms)
mueller_w = get_wsclean_stokes(ms)
assert np.allclose(
mueller_a.stokes_U, mueller_w.stokes_U, atol=1e-4
), f"ASKAP and WSClean disagree on Stokes U in {ms.fixed_ms_path.name}"
assert np.allclose(mueller_a.stokes_U, mueller_w.stokes_U, atol=1e-4), (
f"ASKAP and WSClean disagree on Stokes U in {ms.fixed_ms_path.name}"
)


def test_stokes_V(ms_standard_example, ms_rotated_example):
for ms in (ms_standard_example, ms_rotated_example):
mueller_a = askap_stokes_mat(ms)
mueller_w = get_wsclean_stokes(ms)
assert np.allclose(
mueller_a.stokes_V, mueller_w.stokes_V, atol=1e-4
), f"ASKAP and WSClean disagree on Stokes V in {ms.fixed_ms_path.name}"
assert np.allclose(mueller_a.stokes_V, mueller_w.stokes_V, atol=1e-4), (
f"ASKAP and WSClean disagree on Stokes V in {ms.fixed_ms_path.name}"
)

0 comments on commit a94f2b4

Please sign in to comment.