From d1f179fac82f4a373b870dc8fb239d699595a321 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 20:34:46 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyuvdata/docstrings.py | 1 + pyuvdata/tests/test_docstrings.py | 1 + pyuvdata/tests/test_utils.py | 217 +++++++-------------------- pyuvdata/uvbeam/beamfits.py | 54 ++++--- pyuvdata/uvbeam/initializers.py | 12 +- pyuvdata/uvbeam/tests/test_uvbeam.py | 18 +-- pyuvdata/uvbeam/uvbeam.py | 34 ++--- pyuvdata/uvcal/tests/test_uvcal.py | 11 +- pyuvdata/uvcal/uvcal.py | 6 +- pyuvdata/uvdata/initializers.py | 9 +- pyuvdata/uvdata/miriad.py | 16 +- pyuvdata/uvdata/mwa_corr_fits.py | 27 ++-- pyuvdata/uvdata/tests/test_uvdata.py | 21 ++- pyuvdata/uvdata/tests/test_uvh5.py | 12 +- pyuvdata/uvdata/uvdata.py | 123 +++++++-------- pyuvdata/uvdata/uvfits.py | 8 +- pyuvdata/uvflag/uvflag.py | 28 ++-- 17 files changed, 231 insertions(+), 367 deletions(-) diff --git a/pyuvdata/docstrings.py b/pyuvdata/docstrings.py index 14dc6f9bf4..0a7d284462 100644 --- a/pyuvdata/docstrings.py +++ b/pyuvdata/docstrings.py @@ -1,4 +1,5 @@ """Functions for dealing with merging docstrings.""" + import copy import typing as tp from collections import ChainMap diff --git a/pyuvdata/tests/test_docstrings.py b/pyuvdata/tests/test_docstrings.py index 215e0bda50..4effad4bbc 100644 --- a/pyuvdata/tests/test_docstrings.py +++ b/pyuvdata/tests/test_docstrings.py @@ -1,4 +1,5 @@ """Tests of the docstrings module.""" + from docstring_parser import DocstringReturns, DocstringStyle from pyuvdata.docstrings import combine_docstrings diff --git a/pyuvdata/tests/test_utils.py b/pyuvdata/tests/test_utils.py index efedf7384f..e371ccb03a 100644 --- a/pyuvdata/tests/test_utils.py +++ b/pyuvdata/tests/test_utils.py @@ -110,15 +110,14 @@ def astrometry_args(): ) if hasmoon: - ( - default_args["moon_app_ra"], - default_args["moon_app_dec"], - ) = uvutils.transform_icrs_to_app( - default_args["time_array"], - default_args["icrs_ra"], - default_args["icrs_dec"], - default_args["moon_telescope_loc"], - telescope_frame="mcmf", + (default_args["moon_app_ra"], default_args["moon_app_dec"]) = ( + uvutils.transform_icrs_to_app( + default_args["time_array"], + default_args["icrs_ra"], + default_args["icrs_dec"], + default_args["moon_telescope_loc"], + telescope_frame="mcmf", + ) ) default_args["moon_app_coord"] = SkyCoord( @@ -403,40 +402,18 @@ def enu_mcmf_info(): def test_xyz_from_latlonalt(enu_ecef_info): """Test calculating xyz from lat lot alt.""" - ( - center_lat, - center_lon, - center_alt, - lats, - lons, - alts, - x, - y, - z, - east, - north, - up, - ) = enu_ecef_info + (center_lat, center_lon, center_alt, lats, lons, alts, x, y, z, east, north, up) = ( + enu_ecef_info + ) xyz = uvutils.XYZ_from_LatLonAlt(lats, lons, alts) assert np.allclose(np.stack((x, y, z), axis=1), xyz, atol=1e-3) def test_enu_from_ecef(enu_ecef_info): """Test calculating ENU from ECEF coordinates.""" - ( - center_lat, - center_lon, - center_alt, - lats, - lons, - alts, - x, - y, - z, - east, - north, - up, - ) = enu_ecef_info + (center_lat, center_lon, center_alt, lats, lons, alts, x, y, z, east, north, up) = ( + enu_ecef_info + ) xyz = uvutils.XYZ_from_LatLonAlt(lats, lons, alts) enu = uvutils.ENU_from_ECEF(xyz, center_lat, center_lon, center_alt) @@ -445,20 +422,9 @@ def test_enu_from_ecef(enu_ecef_info): @pytest.mark.skipif(not hasmoon, reason="lunarsky not installed") def test_enu_from_mcmf(enu_mcmf_info): - ( - center_lat, - center_lon, - center_alt, - lats, - lons, - alts, - x, - y, - z, - east, - north, - up, - ) = enu_mcmf_info + (center_lat, center_lon, center_alt, lats, lons, alts, x, y, z, east, north, up) = ( + enu_mcmf_info + ) xyz = uvutils.XYZ_from_LatLonAlt(lats, lons, alts, frame="mcmf") enu = uvutils.ENU_from_ECEF(xyz, center_lat, center_lon, center_alt, frame="mcmf") assert np.allclose(np.stack((east, north, up), axis=1), enu, atol=1e-3) @@ -479,20 +445,9 @@ def test_invalid_frame(): @pytest.mark.parametrize("shape_type", ["transpose", "Nblts,2", "Nblts,1"]) def test_enu_from_ecef_shape_errors(enu_ecef_info, shape_type): """Test ENU_from_ECEF input shape errors.""" - ( - center_lat, - center_lon, - center_alt, - lats, - lons, - alts, - x, - y, - z, - east, - north, - up, - ) = enu_ecef_info + (center_lat, center_lon, center_alt, lats, lons, alts, x, y, z, east, north, up) = ( + enu_ecef_info + ) xyz = uvutils.XYZ_from_LatLonAlt(lats, lons, alts) if shape_type == "transpose": xyz = xyz.T.copy() @@ -511,20 +466,9 @@ def test_enu_from_ecef_shape_errors(enu_ecef_info, shape_type): def test_enu_from_ecef_magnitude_error(enu_ecef_info): """Test ENU_from_ECEF input magnitude errors.""" - ( - center_lat, - center_lon, - center_alt, - lats, - lons, - alts, - x, - y, - z, - east, - north, - up, - ) = enu_ecef_info + (center_lat, center_lon, center_alt, lats, lons, alts, x, y, z, east, north, up) = ( + enu_ecef_info + ) xyz = uvutils.XYZ_from_LatLonAlt(lats, lons, alts) # error checking with pytest.raises(ValueError) as cm: @@ -554,20 +498,9 @@ def test_ecef_from_enu_roundtrip(enu_ecef_info, enu_mcmf_info, frame): @pytest.mark.parametrize("shape_type", ["transpose", "Nblts,2", "Nblts,1"]) def test_ecef_from_enu_shape_errors(enu_ecef_info, shape_type): - ( - center_lat, - center_lon, - center_alt, - lats, - lons, - alts, - x, - y, - z, - east, - north, - up, - ) = enu_ecef_info + (center_lat, center_lon, center_alt, lats, lons, alts, x, y, z, east, north, up) = ( + enu_ecef_info + ) xyz = uvutils.XYZ_from_LatLonAlt(lats, lons, alts) enu = uvutils.ENU_from_ECEF(xyz, center_lat, center_lon, center_alt) if shape_type == "transpose": @@ -585,20 +518,9 @@ def test_ecef_from_enu_shape_errors(enu_ecef_info, shape_type): def test_ecef_from_enu_single(enu_ecef_info): """Test single coordinate transform.""" - ( - center_lat, - center_lon, - center_alt, - lats, - lons, - alts, - x, - y, - z, - east, - north, - up, - ) = enu_ecef_info + (center_lat, center_lon, center_alt, lats, lons, alts, x, y, z, east, north, up) = ( + enu_ecef_info + ) xyz = uvutils.XYZ_from_LatLonAlt(lats, lons, alts) # check passing a single value enu_single = uvutils.ENU_from_ECEF(xyz[0, :], center_lat, center_lon, center_alt) @@ -608,20 +530,9 @@ def test_ecef_from_enu_single(enu_ecef_info): def test_ecef_from_enu_single_roundtrip(enu_ecef_info): """Test single coordinate roundtrip.""" - ( - center_lat, - center_lon, - center_alt, - lats, - lons, - alts, - x, - y, - z, - east, - north, - up, - ) = enu_ecef_info + (center_lat, center_lon, center_alt, lats, lons, alts, x, y, z, east, north, up) = ( + enu_ecef_info + ) xyz = uvutils.XYZ_from_LatLonAlt(lats, lons, alts) # check passing a single value enu = uvutils.ENU_from_ECEF(xyz, center_lat, center_lon, center_alt) @@ -1571,13 +1482,9 @@ def test_jphl_lookup(): # If we can't connect to JPL-Horizons, then skip this test and don't outright fail. try: - [ - ephem_times, - ephem_ra, - ephem_dec, - ephem_dist, - ephem_vel, - ] = uvutils.lookup_jplhorizons("Sun", 2456789.0) + [ephem_times, ephem_ra, ephem_dec, ephem_dist, ephem_vel] = ( + uvutils.lookup_jplhorizons("Sun", 2456789.0) + ) except (SSLError, RequestException) as err: pytest.skip("SSL/Connection error w/ JPL Horizons: " + str(err)) @@ -2581,12 +2488,10 @@ def test_redundancy_finder(): bl_positions_new = uvd.uvw_array bl_positions_new[bi] += sh - ( - baseline_groups_new, - vec_bin_centers, - lens, - ) = uvutils.get_baseline_redundancies( - uvd.baseline_array, bl_positions_new, tol=hightol + (baseline_groups_new, vec_bin_centers, lens) = ( + uvutils.get_baseline_redundancies( + uvd.baseline_array, bl_positions_new, tol=hightol + ) ) for gi, gp in enumerate(baseline_groups_new): @@ -2617,24 +2522,18 @@ def test_redundancy_finder(): # Check with conjugated baseline redundancies returned # Ensure at least one baseline has u==0 and v!=0 (for coverage of this case) bl_positions[16, 0] = 0 - ( - baseline_groups, - vec_bin_centers, - lens, - conjugates, - ) = uvutils.get_baseline_redundancies( - uvd.baseline_array, bl_positions, tol=tol, include_conjugates=True + (baseline_groups, vec_bin_centers, lens, conjugates) = ( + uvutils.get_baseline_redundancies( + uvd.baseline_array, bl_positions, tol=tol, include_conjugates=True + ) ) # restore baseline (16,0) and repeat to get correct groups bl_positions = bl_pos_backup - ( - baseline_groups, - vec_bin_centers, - lens, - conjugates, - ) = uvutils.get_baseline_redundancies( - uvd.baseline_array, bl_positions, tol=tol, include_conjugates=True + (baseline_groups, vec_bin_centers, lens, conjugates) = ( + uvutils.get_baseline_redundancies( + uvd.baseline_array, bl_positions, tol=tol, include_conjugates=True + ) ) # Apply flips to compare with get_antenna_redundancies(). @@ -2677,13 +2576,10 @@ def test_high_tolerance_redundancy_error(): tol = 20.05 # meters with pytest.raises(ValueError) as cm: - ( - baseline_groups, - vec_bin_centers, - lens, - conjugates, - ) = uvutils.get_baseline_redundancies( - uvd.baseline_array, bl_positions, tol=tol, include_conjugates=True + (baseline_groups, vec_bin_centers, lens, conjugates) = ( + uvutils.get_baseline_redundancies( + uvd.baseline_array, bl_positions, tol=tol, include_conjugates=True + ) ) assert "Some baselines are falling into" in str(cm.value) @@ -2734,13 +2630,10 @@ def test_redundancy_finder_fully_redundant_array(): tol = 1 # meters bl_positions = uvd.uvw_array - ( - baseline_groups, - vec_bin_centers, - lens, - conjugates, - ) = uvutils.get_baseline_redundancies( - uvd.baseline_array, bl_positions, tol=tol, include_conjugates=True + (baseline_groups, vec_bin_centers, lens, conjugates) = ( + uvutils.get_baseline_redundancies( + uvd.baseline_array, bl_positions, tol=tol, include_conjugates=True + ) ) # Only 1 set of redundant baselines diff --git a/pyuvdata/uvbeam/beamfits.py b/pyuvdata/uvbeam/beamfits.py index 557e151bbe..afc856c04f 100644 --- a/pyuvdata/uvbeam/beamfits.py +++ b/pyuvdata/uvbeam/beamfits.py @@ -727,9 +727,9 @@ def write_beamfits( "STOKES", "Polarization integers, see uvbeam memo", ) - primary_header[ - "CRVAL" + str(ax_nums["feed_pol"]) - ] = self.polarization_array[0] + primary_header["CRVAL" + str(ax_nums["feed_pol"])] = ( + self.polarization_array[0] + ) primary_header["CDELT" + str(ax_nums["feed_pol"])] = pol_spacing # handle case where data_array is complex (e.g. for xy beams) @@ -848,33 +848,37 @@ def write_beamfits( basisvec_ax_nums = reg_basisvec_ax_nums # set up first image axis - basisvec_header[ - "CTYPE" + str(basisvec_ax_nums["img_ax1"]) - ] = fits_axisname_dict[ - self.coordinate_system_dict[self.pixel_coordinate_system]["axes"][0] - ] - basisvec_header[ - "CRVAL" + str(basisvec_ax_nums["img_ax1"]) - ] = deg_axis1_array[0] + basisvec_header["CTYPE" + str(basisvec_ax_nums["img_ax1"])] = ( + fits_axisname_dict[ + self.coordinate_system_dict[self.pixel_coordinate_system][ + "axes" + ][0] + ] + ) + basisvec_header["CRVAL" + str(basisvec_ax_nums["img_ax1"])] = ( + deg_axis1_array[0] + ) basisvec_header["CRPIX" + str(basisvec_ax_nums["img_ax1"])] = 1 - basisvec_header[ - "CDELT" + str(basisvec_ax_nums["img_ax1"]) - ] = deg_axis1_spacing + basisvec_header["CDELT" + str(basisvec_ax_nums["img_ax1"])] = ( + deg_axis1_spacing + ) basisvec_header["CUNIT" + str(basisvec_ax_nums["img_ax1"])] = "deg" # set up second image axis - basisvec_header[ - "CTYPE" + str(basisvec_ax_nums["img_ax2"]) - ] = fits_axisname_dict[ - self.coordinate_system_dict[self.pixel_coordinate_system]["axes"][1] - ] - basisvec_header[ - "CRVAL" + str(basisvec_ax_nums["img_ax2"]) - ] = deg_axis2_array[0] + basisvec_header["CTYPE" + str(basisvec_ax_nums["img_ax2"])] = ( + fits_axisname_dict[ + self.coordinate_system_dict[self.pixel_coordinate_system][ + "axes" + ][1] + ] + ) + basisvec_header["CRVAL" + str(basisvec_ax_nums["img_ax2"])] = ( + deg_axis2_array[0] + ) basisvec_header["CRPIX" + str(basisvec_ax_nums["img_ax2"])] = 1 - basisvec_header[ - "CDELT" + str(basisvec_ax_nums["img_ax2"]) - ] = deg_axis2_spacing + basisvec_header["CDELT" + str(basisvec_ax_nums["img_ax2"])] = ( + deg_axis2_spacing + ) basisvec_header["CUNIT" + str(basisvec_ax_nums["img_ax2"])] = "deg" # set up vector component axis (length Ncomponents_vec) diff --git a/pyuvdata/uvbeam/initializers.py b/pyuvdata/uvbeam/initializers.py index f71b543ec3..3bec4444c1 100644 --- a/pyuvdata/uvbeam/initializers.py +++ b/pyuvdata/uvbeam/initializers.py @@ -25,13 +25,13 @@ def new_uvbeam( model_name: str = "default", model_version: str = "0.0", feed_array: npt.NDArray[np.str] | None = None, - polarization_array: npt.NDArray[np.str | np.int] - | list[str | int] - | tuple[str | int] - | None = None, + polarization_array: ( + npt.NDArray[np.str | np.int] | list[str | int] | tuple[str | int] | None + ) = None, x_orientation: Literal["east", "north", "e", "n", "ew", "ns"] | None = None, - pixel_coordinate_system: Literal["az_za", "orthoslant_zenith", "healpix"] - | None = None, + pixel_coordinate_system: ( + Literal["az_za", "orthoslant_zenith", "healpix"] | None + ) = None, axis1_array: npt.NDArray[np.float] | None = None, axis2_array: npt.NDArray[np.float] | None = None, nside: int | None = None, diff --git a/pyuvdata/uvbeam/tests/test_uvbeam.py b/pyuvdata/uvbeam/tests/test_uvbeam.py index 3ad2e97a1b..efb17e763c 100644 --- a/pyuvdata/uvbeam/tests/test_uvbeam.py +++ b/pyuvdata/uvbeam/tests/test_uvbeam.py @@ -740,12 +740,9 @@ def test_freq_interpolation( if antenna_type == "simple": interp_data, interp_basis_vector, interp_bandpass = interp_arrays else: - ( - interp_data, - interp_basis_vector, - interp_bandpass, - interp_coupling_matrix, - ) = interp_arrays + (interp_data, interp_basis_vector, interp_bandpass, interp_coupling_matrix) = ( + interp_arrays + ) assert isinstance(interp_data, np.ndarray) assert isinstance(interp_bandpass, np.ndarray) np.testing.assert_array_almost_equal(beam.bandpass_array, interp_bandpass) @@ -770,12 +767,9 @@ def test_freq_interpolation( if antenna_type == "simple": interp_data, interp_basis_vector, interp_bandpass = interp_arrays else: - ( - interp_data, - interp_basis_vector, - interp_bandpass, - interp_coupling_matrix, - ) = interp_arrays + (interp_data, interp_basis_vector, interp_bandpass, interp_coupling_matrix) = ( + interp_arrays + ) assert isinstance(interp_data, np.ndarray) assert isinstance(interp_bandpass, np.ndarray) np.testing.assert_array_almost_equal(beam.bandpass_array, interp_bandpass) diff --git a/pyuvdata/uvbeam/uvbeam.py b/pyuvdata/uvbeam/uvbeam.py index 4d8ba094d4..0acdad8a15 100644 --- a/pyuvdata/uvbeam/uvbeam.py +++ b/pyuvdata/uvbeam/uvbeam.py @@ -1717,11 +1717,9 @@ def _interp_az_za_rect_spline( freq_array, kind=freq_interp_kind, tol=freq_interp_tol ) if self.antenna_type == "phased_array": - ( - input_data_array, - interp_bandpass, - interp_coupling_matrix, - ) = interp_arrays + (input_data_array, interp_bandpass, interp_coupling_matrix) = ( + interp_arrays + ) else: input_data_array, interp_bandpass = interp_arrays input_nfreqs = freq_array.size @@ -2018,11 +2016,9 @@ def _interp_healpix_bilinear( freq_array, kind=freq_interp_kind, tol=freq_interp_tol ) if self.antenna_type == "phased_array": - ( - input_data_array, - interp_bandpass, - interp_coupling_matrix, - ) = interp_arrays + (input_data_array, interp_bandpass, interp_coupling_matrix) = ( + interp_arrays + ) else: input_data_array, interp_bandpass = interp_arrays input_nfreqs = freq_array.size @@ -3310,9 +3306,9 @@ def __add__( if self.future_array_shapes: this.bandpass_array[np.ix_(freq_t2o)] = other.bandpass_array if this.receiver_temperature_array is not None: - this.receiver_temperature_array[ - np.ix_(freq_t2o) - ] = other.receiver_temperature_array + this.receiver_temperature_array[np.ix_(freq_t2o)] = ( + other.receiver_temperature_array + ) if this.loss_array is not None: this.loss_array[np.ix_(freq_t2o)] = other.loss_array if this.mismatch_array is not None: @@ -3334,17 +3330,17 @@ def __add__( this.bandpass_array[np.ix_([0], freq_t2o)] = other.bandpass_array if this.receiver_temperature_array is not None: - this.receiver_temperature_array[ - np.ix_([0], freq_t2o) - ] = other.receiver_temperature_array + this.receiver_temperature_array[np.ix_([0], freq_t2o)] = ( + other.receiver_temperature_array + ) if this.loss_array is not None: this.loss_array[np.ix_([0], freq_t2o)] = other.loss_array if this.mismatch_array is not None: this.mismatch_array[np.ix_([0], freq_t2o)] = other.mismatch_array if this.s_parameters is not None: - this.s_parameters[ - np.ix_(np.arange(4), [0], freq_t2o) - ] = other.s_parameters + this.s_parameters[np.ix_(np.arange(4), [0], freq_t2o)] = ( + other.s_parameters + ) if this.antenna_type == "phased_array": this.coupling_matrix[ diff --git a/pyuvdata/uvcal/tests/test_uvcal.py b/pyuvdata/uvcal/tests/test_uvcal.py index ec89fd86a2..2855734b53 100644 --- a/pyuvdata/uvcal/tests/test_uvcal.py +++ b/pyuvdata/uvcal/tests/test_uvcal.py @@ -328,14 +328,9 @@ def test_unexpected_parameters(uvcal_data): def test_unexpected_attributes(uvcal_data): """Test for extra attributes.""" - ( - uv_cal_object, - _, - required_properties, - _, - extra_properties, - other_properties, - ) = uvcal_data + (uv_cal_object, _, required_properties, _, extra_properties, other_properties) = ( + uvcal_data + ) expected_attributes = required_properties + extra_properties + other_properties attributes = [i for i in uv_cal_object.__dict__.keys() if i[0] != "_"] for a in attributes: diff --git a/pyuvdata/uvcal/uvcal.py b/pyuvdata/uvcal/uvcal.py index b724eed24a..74d6f89263 100644 --- a/pyuvdata/uvcal/uvcal.py +++ b/pyuvdata/uvcal/uvcal.py @@ -3246,9 +3246,9 @@ def __add__( this.quality_array[ np.ix_(ants_t2o, freqs_t2o, times_t2o, jones_t2o) ] = other.quality_array - this.flag_array[ - np.ix_(ants_t2o, freqs_t2o, times_t2o, jones_t2o) - ] = other.flag_array + this.flag_array[np.ix_(ants_t2o, freqs_t2o, times_t2o, jones_t2o)] = ( + other.flag_array + ) if this.total_quality_array is not None: if other.total_quality_array is not None: this.total_quality_array[ diff --git a/pyuvdata/uvdata/initializers.py b/pyuvdata/uvdata/initializers.py index cfac343fed..fc1cae3bc5 100644 --- a/pyuvdata/uvdata/initializers.py +++ b/pyuvdata/uvdata/initializers.py @@ -263,11 +263,10 @@ def configure_blt_rectangularity( antpairs[:, 0], antpairs[:, 1], len(np.unique(unique_antpairs)) ) - ( - blts_are_rectangular, - time_axis_faster_than_bls, - ) = utils.determine_rectangularity( - time_array=times, baseline_array=baselines, nbls=nbl, ntimes=nt + (blts_are_rectangular, time_axis_faster_than_bls) = ( + utils.determine_rectangularity( + time_array=times, baseline_array=baselines, nbls=nbl, ntimes=nt + ) ) return ( diff --git a/pyuvdata/uvdata/miriad.py b/pyuvdata/uvdata/miriad.py index a98ed5e11c..8cf19851b6 100644 --- a/pyuvdata/uvdata/miriad.py +++ b/pyuvdata/uvdata/miriad.py @@ -664,11 +664,9 @@ def _read_miriad_metadata(self, uv, correct_lat_lon=True): """ # load miriad variables - ( - default_miriad_variables, - other_miriad_variables, - extra_miriad_variables, - ) = self._load_miriad_variables(uv) + (default_miriad_variables, other_miriad_variables, extra_miriad_variables) = ( + self._load_miriad_variables(uv) + ) # dict of extra variables check_variables = {} @@ -933,9 +931,11 @@ def read_miriad( raise ValueError(err_msg) # convert to pol integer if string polarizations = [ - p - if isinstance(p, (int, np.integer)) - else uvutils.polstr2num(p, x_orientation=self.x_orientation) + ( + p + if isinstance(p, (int, np.integer)) + else uvutils.polstr2num(p, x_orientation=self.x_orientation) + ) for p in polarizations ] # iterate through all possible pols and reject if not in pols diff --git a/pyuvdata/uvdata/mwa_corr_fits.py b/pyuvdata/uvdata/mwa_corr_fits.py index 62074d99a5..5a85b06d6d 100644 --- a/pyuvdata/uvdata/mwa_corr_fits.py +++ b/pyuvdata/uvdata/mwa_corr_fits.py @@ -736,9 +736,9 @@ def _read_fits_file( # make a mask where data actually is so coarse channels that # are split into two files don't overwrite eachother data_mask = coarse_chan_data != 0 - self.data_array[:, freq_ind : freq_ind + num_fine_chans, :][ - data_mask - ] = coarse_chan_data[data_mask] + self.data_array[:, freq_ind : freq_ind + num_fine_chans, :][data_mask] = ( + coarse_chan_data[data_mask] + ) return @@ -766,10 +766,11 @@ def _read_flag_file(self, filename, file_nums, num_fine_chans): # some flag files are shorter than data; assume same end time blt_ind = self.Nblts - len(flags) flags = flags[:, :, np.newaxis] - self.flag_array[ - blt_ind:, freq_ind : freq_ind + num_fine_chans, : - ] = np.logical_or( - self.flag_array[blt_ind:, freq_ind : freq_ind + num_fine_chans, :], flags + self.flag_array[blt_ind:, freq_ind : freq_ind + num_fine_chans, :] = ( + np.logical_or( + self.flag_array[blt_ind:, freq_ind : freq_ind + num_fine_chans, :], + flags, + ) ) def van_vleck_correction( @@ -951,14 +952,14 @@ def van_vleck_correction( ].flatten() # correct real kap = van_vleck_crosses_int(khat.real, sig1, sig2, cheby_approx) - self.data_array.real[ - k, :, j, np.array([yy, yx, xy, xx]) - ] = kap.reshape(self.Npols, self.Ntimes) + self.data_array.real[k, :, j, np.array([yy, yx, xy, xx])] = ( + kap.reshape(self.Npols, self.Ntimes) + ) # correct imaginary kap = van_vleck_crosses_int(khat.imag, sig1, sig2, cheby_approx) - self.data_array.imag[ - k, :, j, np.array([yy, yx, xy, xx]) - ] = kap.reshape(self.Npols, self.Ntimes) + self.data_array.imag[k, :, j, np.array([yy, yx, xy, xx])] = ( + kap.reshape(self.Npols, self.Ntimes) + ) # correct yx autos for k in good_autos: for j in range(self.Nfreqs): diff --git a/pyuvdata/uvdata/tests/test_uvdata.py b/pyuvdata/uvdata/tests/test_uvdata.py index ae4c3bcbaa..f43bc10805 100644 --- a/pyuvdata/uvdata/tests/test_uvdata.py +++ b/pyuvdata/uvdata/tests/test_uvdata.py @@ -6307,12 +6307,9 @@ def test_redundancy_contract_expand( # the test file has groups that are either all not conjugated or all conjugated. # need to conjugate some so we have mixed groups to properly test the average # method. - ( - orig_red_gps, - orig_centers, - orig_lengths, - orig_conjugates, - ) = uv0.get_redundancies(tol, include_conjugates=True) + (orig_red_gps, orig_centers, orig_lengths, orig_conjugates) = ( + uv0.get_redundancies(tol, include_conjugates=True) + ) blt_inds_to_conj = [] for gp in orig_red_gps: if len(gp) > 1: @@ -11157,9 +11154,9 @@ def test_fix_phase(hera_uvh5, tmp_path, future_shapes, use_ant_pos, phase_frame) uv_in_bad2.gst0 = None uv_in_bad2.rdate = None uv_in_bad2.timesys = None - uv_in_bad2.phase_center_catalog[1][ - "info_source" - ] = uv_in_bad_copy.phase_center_catalog[1]["info_source"] + uv_in_bad2.phase_center_catalog[1]["info_source"] = ( + uv_in_bad_copy.phase_center_catalog[1]["info_source"] + ) uv_in_bad2.extra_keywords = uv_in_bad_copy.extra_keywords assert uv_in_bad2 == uv_in_bad_copy @@ -12178,9 +12175,9 @@ def test_flex_pol_uvh5(future_shapes, multispw, sorting, uv_phase_comp, tmp_path for idx, spw in enumerate(uvd2.spw_array): new_spw = spw_renumber_dict[spw] new_spw_array[idx] = new_spw - uvd2.flex_spw_id_array[ - np.nonzero(uvd2.flex_spw_id_array == spw)[0] - ] = new_spw + uvd2.flex_spw_id_array[np.nonzero(uvd2.flex_spw_id_array == spw)[0]] = ( + new_spw + ) uvd2.spw_array = new_spw_array uvd2.check() diff --git a/pyuvdata/uvdata/tests/test_uvh5.py b/pyuvdata/uvdata/tests/test_uvh5.py index da43f3453d..f2001ccdbd 100644 --- a/pyuvdata/uvdata/tests/test_uvh5.py +++ b/pyuvdata/uvdata/tests/test_uvh5.py @@ -1794,9 +1794,9 @@ def test_uvh5_partial_write_irregular_multi4(uv_partial_write, future_shapes, tm partial_uvh5.flag_array[blt_idx, :, freq_idx, pol_idx] = flags[ iblt, :, ifreq, ipol ] - partial_uvh5.nsample_array[ - blt_idx, :, freq_idx, pol_idx - ] = nsamples[iblt, :, ifreq, ipol] + partial_uvh5.nsample_array[blt_idx, :, freq_idx, pol_idx] = ( + nsamples[iblt, :, ifreq, ipol] + ) # read in the file and make sure it matches partial_uvh5_file = UVData() @@ -3237,9 +3237,9 @@ def test_uvh5_partial_write_ints_irregular_multi4(uv_uvh5, future_shapes, tmp_pa partial_uvh5.flag_array[blt_idx, :, freq_idx, pol_idx] = flags[ iblt, :, ifreq, ipol ] - partial_uvh5.nsample_array[ - blt_idx, :, freq_idx, pol_idx - ] = nsamples[iblt, :, ifreq, ipol] + partial_uvh5.nsample_array[blt_idx, :, freq_idx, pol_idx] = ( + nsamples[iblt, :, ifreq, ipol] + ) # read in the file and make sure it matches partial_uvh5_file = UVData() diff --git a/pyuvdata/uvdata/uvdata.py b/pyuvdata/uvdata/uvdata.py index b5b7785651..9ad0761264 100644 --- a/pyuvdata/uvdata/uvdata.py +++ b/pyuvdata/uvdata/uvdata.py @@ -1721,9 +1721,9 @@ def merge_phase_centers( ) # Set everything to the first cat ID in the list - self.phase_center_id_array[ - np.isin(self.phase_center_id_array, cat_id_list) - ] = cat_id_list[0] + self.phase_center_id_array[np.isin(self.phase_center_id_array, cat_id_list)] = ( + cat_id_list[0] + ) # Finally, remove the defunct cat IDs for cat_id in cat_id_list[1:]: @@ -4757,13 +4757,13 @@ def conjugate_bls(self, convention="ant1