Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #1504

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ repos:
args: ['--fix=no']

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
rev: v0.8.1
hooks:
- id: ruff
- id: ruff-format

- repo: https://github.com/PyCQA/bandit
rev: 1.7.10
rev: 1.8.0
hooks:
- id: bandit
args: [--skip, "B101", --recursive, pyuvdata]
2 changes: 1 addition & 1 deletion src/pyuvdata/utils/io/ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ def write_ms_spectral_window(
ch_mask = ... if id_array is None else id_array == spw_id
sw_table.addrows()
sw_table.putcell("NUM_CHAN", idx, np.sum(ch_mask))
sw_table.putcell("NAME", idx, "SPW%d" % spw_id)
sw_table.putcell("NAME", idx, f"SPW{spw_id}")
sw_table.putcell("ASSOC_SPW_ID", idx, spw_id)
sw_table.putcell("ASSOC_NATURE", idx, "") # Blank for now
sw_table.putcell("CHAN_FREQ", idx, freq_array[ch_mask])
Expand Down
2 changes: 1 addition & 1 deletion src/pyuvdata/utils/phasing.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def _rotate_matmul_wrapper(*, xyz_array, rot_matrix, n_rot):
# Do a quick check to make sure that things look sensible
if rot_matrix.shape != (n_rot, 3, 3):
raise ValueError(
"rot_matrix must be of shape (n_rot, 3, 3), where n_rot=%i." % n_rot
f"rot_matrix must be of shape (n_rot, 3, 3), where n_rot={n_rot}."
)
if (xyz_array.ndim == 3) and (
(xyz_array.shape[0] not in [1, n_rot]) or (xyz_array.shape[-2] != 3)
Expand Down
13 changes: 6 additions & 7 deletions src/pyuvdata/uvdata/mir.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ def read_mir(
select_where += [("tel1", "eq", antenna_names)]
select_where += [("tel2", "eq", antenna_names)]
if bls is not None:
select_where += [
("blcd", "eq", ["%i-%i" % (tup[0], tup[1]) for tup in bls])
]
select_where += [("blcd", "eq", [f"{tup[0]}-{tup[1]}" for tup in bls])]
if time_range is not None:
# Have to convert times from UTC JD -> TT MJD for mIR
select_where += [
Expand Down Expand Up @@ -438,9 +436,10 @@ def _init_from_mir_parser(
):
if not np.allclose(val, mir_data.sp_data[item][data_mask]):
warnings.warn(
"Discrepancy in %s for win %i sb %i pol %i. Values of "
"`freq_array` and `channel_width` should be checked for "
"channels corresponding to spw_id %i." % (item, *spdx, spw_id)
f"Discrepancy in {item} for win {spdx[0]} sb {spdx[1]} "
f"pol {spdx[2]}. Values of `freq_array` and `channel_width` "
"should be checked for channels corresponding to spw_id "
f"{spw_id}."
)

# Get the data in the right units and dtype
Expand Down Expand Up @@ -530,7 +529,7 @@ def _init_from_mir_parser(
self.telescope = Telescope()
self._set_telescope_requirements()
self.telescope.Nants = 8
self.telescope.antenna_names = ["Ant%i" % idx for idx in range(1, 9)]
self.telescope.antenna_names = [f"Ant{idx}" for idx in range(1, 9)]
self.telescope.antenna_numbers = np.arange(1, 9)

# Prepare the XYZ coordinates of the antenna positions.
Expand Down
9 changes: 2 additions & 7 deletions src/pyuvdata/uvdata/mir_meta_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2947,13 +2947,8 @@ def _writefile(self, filepath=None, *, append_data=False, datamask=...):
with open(filepath, "a" if append_data else "w+") as file:
for antpos in self._data[datamask]:
file.write(
"%i %.17e %.17e %.17e\n"
% (
antpos["antenna"],
antpos["xyz_pos"][0],
antpos["xyz_pos"][1],
antpos["xyz_pos"][2],
)
f"{antpos['antenna']} {antpos['xyz_pos'][0]:.17e} "
f"{antpos['xyz_pos'][1]:.17e} {antpos['xyz_pos'][2]:.17e}\n"
)


Expand Down
10 changes: 6 additions & 4 deletions src/pyuvdata/uvdata/mir_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1438,8 +1438,8 @@ def apply_tsys(self, *, invert=False, force=False, use_cont_det=None):
)
except KeyError:
warnings.warn(
"No tsys for blhid %i found (%i-%i baseline, inhid %i). "
"Baseline record will be flagged." % (blhid, jdx, ldx, idx)
f"No tsys for blhid {blhid} found ({jdx}-{ldx} baseline, "
f"inhid {idx}). Baseline record will be flagged."
)

if invert:
Expand Down Expand Up @@ -4091,10 +4091,12 @@ def redoppler_data(
# If we need to "fix" the values, do it now.
if (fix_freq is None and (self.codes_data["filever"] == ["4"])) or fix_freq:
# Figure out which receiver this is.
rx_code = np.median(self.bl_data["irec"][self.bl_data["ant1rx"] == 0])
rx_code = int(
np.median(self.bl_data["irec"][self.bl_data["ant1rx"] == 0])
)
rx_name = self.codes_data["rec"][rx_code]
if rx_name not in ("230", "345"):
raise ValueError("Receiver code %i not recognized." % rx_code)
raise ValueError(f"Receiver code {rx_code} not recognized.")
bhazelton marked this conversation as resolved.
Show resolved Hide resolved

freq_shift *= 2 if (rx_name == "230") else 3
# We have to do a bit of special handling for the so-called "RxB"
Expand Down
12 changes: 6 additions & 6 deletions src/pyuvdata/uvdata/uvfits.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,9 +1416,9 @@ def write_uvfits(
fits_tables = [hdu, ant_hdu]
# If needed, add the FQ table
if self.Nspws > 1:
fmt_d = "%iD" % self.Nspws
fmt_e = "%iE" % self.Nspws
fmt_j = "%iJ" % self.Nspws
fmt_d = f"{self.Nspws}D"
fmt_e = f"{self.Nspws}E"
fmt_j = f"{self.Nspws}J"

# TODO Karto: Temp implementation until we fix some other things in UVData
if_freq = start_freq_array - ref_freq
Expand All @@ -1445,9 +1445,9 @@ def write_uvfits(
fits_tables.append(fq_hdu)

# Always write the SU table
fmt_d = "%iD" % self.Nspws
fmt_e = "%iE" % self.Nspws
fmt_j = "%iJ" % self.Nspws
fmt_d = f"{self.Nspws}D"
fmt_e = f"{self.Nspws}E"
fmt_j = f"{self.Nspws}J"

int_zeros = np.zeros(self.Nphase, dtype=int)
flt_zeros = np.zeros(self.Nphase, dtype=np.float64)
Expand Down
2 changes: 1 addition & 1 deletion tests/uvdata/test_mir_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ def test_apply_tsys_warn(mir_data):
with check_warnings(
UserWarning,
[
("No tsys for blhid %i found (1-4 baseline, inhid 1)." % idx)
(f"No tsys for blhid {idx} found (1-4 baseline, inhid 1).")
for idx in range(1, 5)
],
):
Expand Down
Loading