Skip to content

Commit 590c372

Browse files
AlecThomsontjgalvinpre-commit-ci[bot]Tim Galvin
authored
Tjgalvin beams (#76)
* mock up of target beams * beams mock / added to cli * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * added a test on _get_target_beam * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * corrected inverted check for nchans * typo and assert fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * added checks for nan in target beam props / tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Ruff * Ruff --------- Co-authored-by: tgalvin <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tim Galvin <[email protected]>
1 parent d8cfb48 commit 590c372

File tree

15 files changed

+348
-179
lines changed

15 files changed

+348
-179
lines changed

.pre-commit-config.yaml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
4-
hooks:
5-
- id: trailing-whitespace
6-
- id: end-of-file-fixer
7-
- id: check-yaml
8-
- id: check-added-large-files
9-
- repo: https://github.com/psf/black
10-
rev: 24.4.2
11-
hooks:
12-
- id: black
13-
- repo: https://github.com/PyCQA/isort
14-
rev: 5.13.2
15-
hooks:
16-
- id: isort
17-
args: ["--profile=black"]
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
10+
- repo: https://github.com/astral-sh/ruff-pre-commit
11+
rev: "v0.9.2"
12+
hooks:
13+
- id: ruff
14+
args: ["--fix", "--show-fixes"]
15+
- id: ruff-format
16+
1817
ci:
1918
autofix_commit_msg: |
2019
[pre-commit.ci] auto fixes from pre-commit.com hooks
21-
2220
for more information, see https://pre-commit.ci
2321
autofix_prs: true
2422
autoupdate_branch: ''

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Docker Build and Push](https://github.com/AlecThomson/RACS-tools/actions/workflows/docker.yml/badge.svg)](https://github.com/AlecThomson/RACS-tools/actions/workflows/docker.yml) ![Tests](https://github.com/AlecThomson/RACS-tools/actions/workflows/pytest.yml/badge.svg) [![Python package](https://github.com/AlecThomson/RACS-tools/actions/workflows/python-package.yml/badge.svg)](https://github.com/AlecThomson/RACS-tools/actions/workflows/python-package.yml) [![PyPi](https://github.com/AlecThomson/RACS-tools/actions/workflows/pypi.yml/badge.svg)](https://github.com/AlecThomson/RACS-tools/actions/workflows/pypi.yml) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/AlecThomson/RACS-tools/master.svg)](https://results.pre-commit.ci/latest/github/AlecThomson/RACS-tools/master)
1+
[![Docker Build and Push](https://github.com/AlecThomson/RACS-tools/actions/workflows/docker.yml/badge.svg)](https://github.com/AlecThomson/RACS-tools/actions/workflows/docker.yml) ![Tests](https://github.com/AlecThomson/RACS-tools/actions/workflows/pytest.yml/badge.svg) [![Python package](https://github.com/AlecThomson/RACS-tools/actions/workflows/python-package.yml/badge.svg)](https://github.com/AlecThomson/RACS-tools/actions/workflows/python-package.yml) [![PyPi](https://github.com/AlecThomson/RACS-tools/actions/workflows/pypi.yml/badge.svg)](https://github.com/AlecThomson/RACS-tools/actions/workflows/pypi.yml)[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/AlecThomson/RACS-tools/master.svg)](https://results.pre-commit.ci/latest/github/AlecThomson/RACS-tools/master)
22

33
# RACS-tools
44
Useful scripts for RACS

pyproject.toml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ numba = "*"
1919
mpi4py = {version = ">=3", optional = true}
2020

2121
[tool.poetry.dev-dependencies]
22-
black = "*"
23-
isort = "*"
22+
ruff = {version = "*", optional = true}
2423

2524
[tool.poetry.extras]
2625
mpi = ["mpi4py"]
@@ -38,3 +37,32 @@ vcs = "git"
3837
[build-system]
3938
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
4039
build-backend = "poetry_dynamic_versioning.backend"
40+
41+
[tool.ruff]
42+
src = ["racs_tools"]
43+
44+
[tool.ruff.lint]
45+
extend-select = [
46+
# "B", # flake8-bugbear
47+
"I", # isort
48+
"ARG", # flake8-unused-arguments
49+
# "C4", # flake8-comprehensions
50+
# "EM", # flake8-errmsg
51+
"ICN", # flake8-import-conventions
52+
# "G", # flake8-logging-format
53+
# "PGH", # pygrep-hooks
54+
# "PIE", # flake8-pie
55+
# "PL", # pylint
56+
# "PT", # flake8-pytest-style
57+
# "PTH", # flake8-use-pathlib
58+
# "RET", # flake8-return
59+
# "RUF", # Ruff-specific
60+
# "SIM", # flake8-simplify
61+
# "T20", # flake8-print
62+
"UP", # pyupgrade
63+
# "YTT", # flake8-2020
64+
# "EXE", # flake8-executable
65+
# "NPY", # NumPy specific rules
66+
# "PD", # pandas-vet,
67+
# "RET", # flake8-return
68+
]

racs_tools/au2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env python3
2-
""" For getting fluxes right in Jy/beam """
2+
"""For getting fluxes right in Jy/beam"""
3+
34
__author__ = "Tessa Vernstrom"
45

56
import math
6-
from typing import List, Tuple
77

88
import numpy as np
99

@@ -75,8 +75,8 @@ def gaussianDeconvolve(smaj, smin, spa, bmaj, bmin, bpa):
7575

7676

7777
def gauss_factor(
78-
beamConv: List[float], beamOrig: List[float], dx1: float = 1, dy1: float = 1
79-
) -> Tuple[float, float, float, float, float]:
78+
beamConv: list[float], beamOrig: list[float], dx1: float = 1, dy1: float = 1
79+
) -> tuple[float, float, float, float, float]:
8080
"""
8181
Calculates the scaling factor to be applied after convolving
8282
a map in Jy/beam with a gaussian to get fluxes in Jy/beam again.

racs_tools/beamcon_2D.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env python
2-
""" Convolve ASKAP images to common resolution """
2+
"""Convolve ASKAP images to common resolution"""
3+
34
from __future__ import annotations
45

56
__author__ = "Alec Thomson"
67

78

89
import logging
910
import sys
10-
import traceback
1111
from pathlib import Path
12-
from typing import Literal, NamedTuple, Optional
12+
from typing import Literal, NamedTuple
1313

1414
import numpy as np
1515
from astropy import units as u
@@ -290,7 +290,7 @@ def beamcon_2d_on_fits(
290290
def get_common_beam(
291291
files: list[Path],
292292
conv_mode: Literal["robust", "scipy", "astropy", "astropy_fft"] = "robust",
293-
target_beam: Optional[Beam] = None,
293+
target_beam: Beam | None = None,
294294
cutoff: float | None = None,
295295
tolerance: float = 0.0001,
296296
nsamps: float = 200,

0 commit comments

Comments
 (0)