Skip to content

Commit

Permalink
Do the ruffing
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecThomson committed Jan 12, 2024
1 parent 862ebc9 commit da90e16
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 11 deletions.
2 changes: 1 addition & 1 deletion flint/bandpass.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def plot_solutions(solutions_path: Path, ref_ant: Optional[int] = 0) -> None:
logger.info(f"Plotting {solutions_path}")

ao_sols = AOSolutions.load(path=solutions_path)
plot_paths = ao_sols.plot_solutions(ref_ant=ref_ant)
_ = ao_sols.plot_solutions(ref_ant=ref_ant)


def flag_bandpass_offset_pointings(ms: Union[MS, Path]) -> MS:
Expand Down
4 changes: 2 additions & 2 deletions flint/calibrate/aocalibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,8 @@ def flag_aosolutions(
logger.info(f"Creating {str(plot_dir)}")
try:
plot_dir.mkdir(parents=True)
except:
logger.warn(f"Failed to create {str(plot_dir)}.")
except Exception as e:
logger.error(f"Failed to create {str(plot_dir)} {e}.")

# Note that although the solutions variable (an instance of AOSolutions) is immutable,
# which includes the reference to the numpy array, the _actual_ numpy array is! So,
Expand Down
2 changes: 1 addition & 1 deletion flint/convol.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def cli() -> None:
get_common_beam(image_paths=args.images, cutoff=args.cutoff)
if args.mode == "convol":
common_beam = get_common_beam(image_paths=args.images, cutoff=args.cutoff)
conv_paths = convolve_images(
_ = convolve_images(
image_paths=args.images,
beam_shape=common_beam,
cutoff=args.cutoff,
Expand Down
6 changes: 3 additions & 3 deletions flint/naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def processed_ms_format(in_name: Union[str, Path]) -> ProcessedNameComponents:


def extract_components_from_name(
name: Union[str, Path]
name: Union[str, Path],
) -> Union[RawNameComponents, ProcessedNameComponents]:
"""Attempts to break down a file name of a recognised format into its principal compobnents.
Presumably this is a measurement set or something derived from it (i.e. images).
Expand Down Expand Up @@ -201,8 +201,8 @@ def create_ms_name(
try:
sbid = get_sbid_from_path(path=ms_path)
sbid_text = f"SB{sbid}"
except:
pass
except Exception as e:
logger.error(e)
ms_name_list.append(sbid_text)

if field:
Expand Down
2 changes: 1 addition & 1 deletion flint/source_finding/aegean.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def python_run_bane_and_aegean(image: Path, cores: int = 8) -> AegeanOutputs:
# TODO: These options need to have an associated class
logger.info("About to run aegean. ")
source_finder = SourceFinder()
sf_results = source_finder.find_sources_in_image(
_ = source_finder.find_sources_in_image(
filename=str(image),
hdu_index=0,
cube_index=0,
Expand Down
1 change: 0 additions & 1 deletion flint/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from astropy.wcs import WCS
from matplotlib.axes import Axes
from matplotlib.figure import Figure
from matplotlib.gridspec import GridSpec

from flint.logging import logger

Expand Down
63 changes: 63 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,66 @@ flint_masking = "flint.masking:cli"
flint_flow_bandpass_calibrate = "flint.prefect.flows.bandpass_pipeline:cli"
flint_flow_continuum_pipeline = "flint.prefect.flows.continuum_pipeline:cli"
flint_flow_continuum_mask_pipeline = "flint.prefect.flows.continuum_mask_pipeline:cli"

[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]

# Same as Black.
line-length = 88
indent-width = 4

# Assume Python 3.8
target-version = "py38"

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
select = ["E4", "E7", "E9", "F"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
4 changes: 2 additions & 2 deletions tests/test_aocalibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_aosols_bandpass_ref_nu_rank_error(ao_sols):
ao = AOSolutions.load(path=ao_sols)

# This should raise an assertion error since the data shape is not right
with pytest.raises(AssertionError) as ae:
with pytest.raises(AssertionError) as _:
divide_bandpass_by_ref_ant(complex_gains=ao.bandpass, ref_ant=0)


Expand Down Expand Up @@ -77,7 +77,7 @@ def test_ref_ant_selection_with_assert(ao_sols):
ao = AOSolutions.load(path=ao_sols)

# This ref ant selection function expects a rank of 4
with pytest.raises(AssertionError) as ae:
with pytest.raises(AssertionError) as _:
select_refant(bandpass=ao.bandpass[0])


Expand Down

0 comments on commit da90e16

Please sign in to comment.