From 2638c31be1e6573e5a4598751d0672b8c7dc1de0 Mon Sep 17 00:00:00 2001 From: nmahesh1412 Date: Wed, 16 Oct 2024 20:44:39 +0000 Subject: [PATCH] fixed linting issues --- src/pyuvdata/uvbeam/uvbeam.py | 46 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/pyuvdata/uvbeam/uvbeam.py b/src/pyuvdata/uvbeam/uvbeam.py index 909e75952..c89a1efbd 100644 --- a/src/pyuvdata/uvbeam/uvbeam.py +++ b/src/pyuvdata/uvbeam/uvbeam.py @@ -4056,7 +4056,7 @@ def read_feko_beam( """ from . import feko_beam - if not isinstance(filename, (list, tuple)) and filename.endswith("yaml"): + if not isinstance(filename, list | tuple) and filename.endswith("yaml"): settings_dict = self._read_feko_beam_yaml(filename) if not isinstance(settings_dict["frequencies"], list): raise ValueError("frequencies in yaml file must be a list.") @@ -4082,8 +4082,8 @@ def read_feko_beam( for key, val in overriding_keywords.items(): if val is not None: warnings.warn( - "The {key} keyword is set, overriding the " - "value in the settings yaml file.".format(key=key) + f"The {key} keyword is set, overriding the " + "value in the settings yaml file." ) if feed_pol is None: @@ -4131,7 +4131,7 @@ def read_feko_beam( rename_extra_keys_map = {"sim_beam_type": "sim_type"} for key, value in settings_dict.items(): if key not in known_keys: - if key in rename_extra_keys_map.keys(): + if key in rename_extra_keys_map: extra_keywords[rename_extra_keys_map[key]] = value else: extra_keywords[key] = value @@ -4155,9 +4155,9 @@ def read_feko_beam( raise ValueError(f"frequency {freq} not in frequency list") freq_inds = np.array(freq_inds) frequency = freq_array[freq_inds].tolist() - cst_filename = np.array(cst_filename)[freq_inds].tolist() - if len(cst_filename) == 1: - cst_filename = cst_filename[0] + feko_filename = np.array(feko_filename)[freq_inds].tolist() + if len(feko_filename) == 1: + feko_filename = feko_filename[0] if isinstance(feed_pol, list): if rotate_pol is None: # if a mix of feed pols, don't rotate by default @@ -4182,21 +4182,19 @@ def read_feko_beam( if len(frequency.shape) > 1: raise ValueError("frequency can not be a multi-dimensional array") frequency = frequency.tolist() - if isinstance(frequency, (list, tuple)): - if len(frequency) == 1: - frequency = frequency[0] + if isinstance(frequency, list | tuple) and len(frequency) == 1: + frequency = frequency[0] if isinstance(feed_pol, np.ndarray): if len(feed_pol.shape) > 1: raise ValueError("feed_pol can not be a multi-dimensional array") feed_pol = feed_pol.tolist() - if isinstance(feed_pol, (list, tuple)): - if len(feed_pol) == 1: - feed_pol = feed_pol[0] + if isinstance(feed_pol, list | tuple) and len(feed_pol) == 1: + feed_pol = feed_pol[0] - if isinstance(feko_filename, (list, tuple)): + if isinstance(feko_filename, list | tuple): if frequency is not None: - if isinstance(frequency, (list, tuple)): + if isinstance(frequency, list | tuple): if not len(frequency) == len(feko_filename): raise ValueError( "If frequency and filename are both " @@ -4208,7 +4206,7 @@ def read_feko_beam( else: freq = None - if isinstance(feed_pol, (list, tuple)): + if isinstance(feed_pol, list | tuple): if not len(feed_pol) == len(feko_filename): raise ValueError( "If feed_pol and filename are both " @@ -4219,9 +4217,9 @@ def read_feko_beam( else: pol = feed_pol - if isinstance(freq, (list, tuple)): + if isinstance(freq, list | tuple): raise ValueError("frequency can not be a nested list") - if isinstance(pol, (list, tuple)): + if isinstance(pol, list | tuple): raise ValueError("feed_pol can not be a nested list") self.read_feko_beam( feko_filename[0], @@ -4245,16 +4243,16 @@ def read_feko_beam( fix_auto_power=fix_auto_power, ) for file_i, f in enumerate(feko_filename[1:]): - if isinstance(f, (list, tuple)): + if isinstance(f, list | tuple): raise ValueError("filename can not be a nested list") - if isinstance(frequency, (list, tuple)): + if isinstance(frequency, list | tuple): freq = frequency[file_i + 1] elif frequency is not None: freq = frequency else: freq = None - if isinstance(feed_pol, (list, tuple)): + if isinstance(feed_pol, list | tuple): pol = feed_pol[file_i + 1] else: pol = feed_pol @@ -4284,9 +4282,9 @@ def read_feko_beam( if len(feko_filename) > 1: del beam2 else: - if isinstance(frequency, (list, tuple)): + if isinstance(frequency, list | tuple): raise ValueError("Too many frequencies specified") - if isinstance(feed_pol, (list, tuple)): + if isinstance(feed_pol, list | tuple): raise ValueError("Too many feed_pols specified") feko_beam_obj = feko_beam.FEKOBeam() feko_beam_obj.read_feko_beam( @@ -4313,7 +4311,7 @@ def read_feko_beam( self._convert_from_filetype(feko_beam_obj) del feko_beam_obj - if not isinstance(filename, (list, tuple)) and filename.endswith("yaml"): + if not isinstance(filename, list | tuple) and filename.endswith("yaml"): # update filelist basename = os.path.basename(filename) self.filename = utils._combine_filenames(self.filename, [basename])