From 1b8dfd08ae918134bdb62a97f9931044ce96eb4c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 19:53:45 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- simpleDS/delay_spectrum.py | 124 ++++++++++++++++---------- simpleDS/parameter.py | 2 +- simpleDS/tests/test_delay_spectrum.py | 14 +-- 3 files changed, 85 insertions(+), 55 deletions(-) diff --git a/simpleDS/delay_spectrum.py b/simpleDS/delay_spectrum.py index 3df5de2..64c9461 100644 --- a/simpleDS/delay_spectrum.py +++ b/simpleDS/delay_spectrum.py @@ -477,11 +477,7 @@ def __init__(self, uv=None, uvb=None, trcvr=None, taper=None): expected_units=_conversion_units, ) _tconversion_units = ( - ( - units.mK**2 - * units.Mpc**3 - / (units.K * units.sr * units.Hz**3) ** 2 - ), + (units.mK**2 * units.Mpc**3 / (units.K * units.sr * units.Hz**3) ** 2), ( units.mK**2 * (units.Mpc / littleh) ** 3 @@ -1478,9 +1474,11 @@ def _select_preprocess( "numbers and converting to antenna pairs." ) bls = [ - uvutils.baseline_to_antnums(bl, self.Nants_telescope) - if isinstance(bl, (int, np.int_, np.intc)) - else bl + ( + uvutils.baseline_to_antnums(bl, self.Nants_telescope) + if isinstance(bl, (int, np.int_, np.intc)) + else bl + ) for bl in bls ] else: @@ -2316,9 +2314,11 @@ def _get_data( nsamples = nsamples[slice] else: slice = tuple( - np.s_[:] - if _cnt != visdata_axes[axis_ind] - else (visdata_ind_set[axis_ind] or np.s_[:]) + ( + np.s_[:] + if _cnt != visdata_axes[axis_ind] + else (visdata_ind_set[axis_ind] or np.s_[:]) + ) for _cnt in range(len(visdata_dset.shape)) ) if count == 0: @@ -2363,9 +2363,11 @@ def _get_data( if _power: slice = tuple( - np.s_[:] - if _cnt != power_axes[axis_ind] - else (power_ind_set[axis_ind] or np.s_[:]) + ( + np.s_[:] + if _cnt != power_axes[axis_ind] + else (power_ind_set[axis_ind] or np.s_[:]) + ) for _cnt in range(len(power_dset.shape)) ) if count == 0: @@ -2377,9 +2379,11 @@ def _get_data( if _noise: slice = tuple( - np.s_[:] - if _cnt != power_axes[axis_ind] - else (power_ind_set[axis_ind] or np.s_[:]) + ( + np.s_[:] + if _cnt != power_axes[axis_ind] + else (power_ind_set[axis_ind] or np.s_[:]) + ) for _cnt in range(len(noise_power_dset.shape)) ) if count == 0: @@ -2406,9 +2410,11 @@ def _get_data( for count, axis_ind in enumerate(power_inds): slice = tuple( - np.s_[:] - if _cnt != power_axes[axis_ind] - else (power_ind_set[axis_ind] or np.s_[:]) + ( + np.s_[:] + if _cnt != power_axes[axis_ind] + else (power_ind_set[axis_ind] or np.s_[:]) + ) for _cnt in range(len(thermal_dset.shape)) ) if count == 0: @@ -3068,18 +3074,26 @@ def write_partial(self, filename): non_reg = [np.ravel(indices[i]) for i in non_reg_inds] for mesh_ind in product(*non_reg): _inds = tuple( - indices[_cnt] - if _cnt in reg_spaced - else mesh_ind[np.nonzero(_cnt == non_reg_inds)[0].item()] + ( + indices[_cnt] + if _cnt in reg_spaced + else mesh_ind[ + np.nonzero(_cnt == non_reg_inds)[0].item() + ] + ) for _cnt in range(len(visdata_dset.shape)) ) data_inds = tuple( - indices[_cnt] - if _cnt in reg_spaced - else np.nonzero( - non_reg[np.nonzero(_cnt == non_reg_inds)[0].item()] - == mesh_ind[np.nonzero(_cnt == non_reg_inds)[0].item()] - )[0].item() + ( + indices[_cnt] + if _cnt in reg_spaced + else np.nonzero( + non_reg[np.nonzero(_cnt == non_reg_inds)[0].item()] + == mesh_ind[ + np.nonzero(_cnt == non_reg_inds)[0].item() + ] + )[0].item() + ) for _cnt in range(len(visdata_dset.shape)) ) visdata_dset[_inds] = self.data_array[data_inds].to_value( @@ -3126,18 +3140,26 @@ def write_partial(self, filename): non_reg = [np.ravel(indices[i]) for i in non_reg_inds] for mesh_ind in product(*non_reg): _inds = tuple( - indices[_cnt] - if _cnt in reg_spaced - else mesh_ind[np.nonzero(_cnt == non_reg_inds)[0].item()] + ( + indices[_cnt] + if _cnt in reg_spaced + else mesh_ind[ + np.nonzero(_cnt == non_reg_inds)[0].item() + ] + ) for _cnt in range(len(visdata_dset.shape)) ) data_inds = tuple( - indices[_cnt] - if _cnt in reg_spaced - else np.nonzero( - non_reg[np.nonzero(_cnt == non_reg_inds)[0].item()] - == mesh_ind[np.nonzero(_cnt == non_reg_inds)[0].item()] - )[0].item() + ( + indices[_cnt] + if _cnt in reg_spaced + else np.nonzero( + non_reg[np.nonzero(_cnt == non_reg_inds)[0].item()] + == mesh_ind[ + np.nonzero(_cnt == non_reg_inds)[0].item() + ] + )[0].item() + ) for _cnt in range(len(visdata_dset.shape)) ) data_power_dset[_inds] = self.power_array[data_inds].to_value( @@ -3168,18 +3190,26 @@ def write_partial(self, filename): non_reg = [np.ravel(indices[i]) for i in non_reg_inds] for mesh_ind in product(*non_reg): _inds = tuple( - indices[_cnt] - if _cnt in reg_spaced - else mesh_ind[np.nonzero(_cnt == non_reg_inds)[0].item()] + ( + indices[_cnt] + if _cnt in reg_spaced + else mesh_ind[ + np.nonzero(_cnt == non_reg_inds)[0].item() + ] + ) for _cnt in range(len(thermal_dset.shape)) ) data_inds = tuple( - indices[_cnt] - if _cnt in reg_spaced - else np.nonzero( - non_reg[np.nonzero(_cnt == non_reg_inds)[0].item()] - == mesh_ind[np.nonzero(_cnt == non_reg_inds)[0].item()] - )[0].item() + ( + indices[_cnt] + if _cnt in reg_spaced + else np.nonzero( + non_reg[np.nonzero(_cnt == non_reg_inds)[0].item()] + == mesh_ind[ + np.nonzero(_cnt == non_reg_inds)[0].item() + ] + )[0].item() + ) for _cnt in range(len(thermal_dset.shape)) ) diff --git a/simpleDS/parameter.py b/simpleDS/parameter.py index 838ba36..f1aea59 100644 --- a/simpleDS/parameter.py +++ b/simpleDS/parameter.py @@ -333,7 +333,7 @@ def __eq__(self, other): self_lower[key], other_lower[key] ): values_close = False - except (TypeError): + except TypeError: # this isn't a type that can be # handled by np.isclose, # test for equality diff --git a/simpleDS/tests/test_delay_spectrum.py b/simpleDS/tests/test_delay_spectrum.py index 2904223..6b0c02f 100644 --- a/simpleDS/tests/test_delay_spectrum.py +++ b/simpleDS/tests/test_delay_spectrum.py @@ -219,7 +219,7 @@ def test_properties(self): this_param = getattr(self.dspec_object, v) try: assert rand_num == this_param.value - except (AssertionError): + except AssertionError: print( "setting {prop_name} to a random number failed".format(prop_name=k) ) @@ -1072,9 +1072,7 @@ def test_delay_spectrum_thermal_power_units(): dspec_object.calculate_delay_spectrum() dspec_object.add_trcvr(144 * units.K) - assert (units.mK**2 * units.Mpc**3).is_equivalent( - dspec_object.thermal_power.unit - ) + assert (units.mK**2 * units.Mpc**3).is_equivalent(dspec_object.thermal_power.unit) def test_delay_spectrum_thermal_power_shape(): @@ -1555,9 +1553,11 @@ def test_select(ds_uvfits_and_uvb, input): } if "bls" in uvd_input and not isinstance(uvd_input["bls"], tuple): uvd_input["bls"] = [ - uvd.baseline_to_antnums(bl) - if isinstance(bl, (int, np.int_, np.intc)) - else bl + ( + uvd.baseline_to_antnums(bl) + if isinstance(bl, (int, np.int_, np.intc)) + else bl + ) for bl in uvd_input["bls"] ]