diff --git a/src/ria_toolkit_oss/datatypes/datasets/radio_dataset.py b/src/ria_toolkit_oss/datatypes/datasets/radio_dataset.py index 7a70589..cf3fd23 100644 --- a/src/ria_toolkit_oss/datatypes/datasets/radio_dataset.py +++ b/src/ria_toolkit_oss/datatypes/datasets/radio_dataset.py @@ -956,10 +956,8 @@ def get_result_sizes( # noqa: C901 # TODO: Simplify function # Check that each class that will be augmented does not already suffice target_size for cls_name, target_size_value in zip(classes_to_augment, target_size): if class_sizes[cls_name] >= target_size_value: - raise ValueError( - f"""target_size of {target_size_value} is already sufficed for current size of - {class_sizes[cls_name]} for class: {cls_name}""" - ) + raise ValueError(f"""target_size of {target_size_value} is already sufficed for current size of + {class_sizes[cls_name]} for class: {cls_name}""") for index, class_name in enumerate(classes_to_augment): result_sizes[class_name] = target_size[index] diff --git a/src/ria_toolkit_oss/sdr/blade.py b/src/ria_toolkit_oss/sdr/blade.py index c8e6f3f..576a91c 100644 --- a/src/ria_toolkit_oss/sdr/blade.py +++ b/src/ria_toolkit_oss/sdr/blade.py @@ -474,10 +474,8 @@ class Blade(SDR): if gain_mode == "relative": if gain > 0: - raise SDRParameterError( - "When gain_mode = 'relative', gain must be < 0. This sets \ - the gain relative to the maximum possible gain." - ) + raise SDRParameterError("When gain_mode = 'relative', gain must be < 0. This sets \ + the gain relative to the maximum possible gain.") else: abs_gain = rx_gain_max + gain else: @@ -550,10 +548,8 @@ class Blade(SDR): if gain_mode == "relative": if gain > 0: - raise SDRParameterError( - "When gain_mode = 'relative', gain must be < 0. This sets\ - the gain relative to the maximum possible gain." - ) + raise SDRParameterError("When gain_mode = 'relative', gain must be < 0. This sets\ + the gain relative to the maximum possible gain.") else: abs_gain = tx_gain_max + gain else: diff --git a/src/ria_toolkit_oss/sdr/hackrf.py b/src/ria_toolkit_oss/sdr/hackrf.py index 06b49a7..79e00a7 100644 --- a/src/ria_toolkit_oss/sdr/hackrf.py +++ b/src/ria_toolkit_oss/sdr/hackrf.py @@ -172,10 +172,8 @@ class HackRF(SDR): tx_gain_max = 47 if gain_mode == "relative": if gain > 0: - raise SDRParameterError( - "When gain_mode = 'relative', gain must be < 0. This \ - sets the gain relative to the maximum possible gain." - ) + raise SDRParameterError("When gain_mode = 'relative', gain must be < 0. This \ + sets the gain relative to the maximum possible gain.") else: abs_gain = tx_gain_max + gain else: diff --git a/src/ria_toolkit_oss/sdr/pluto.py b/src/ria_toolkit_oss/sdr/pluto.py index 47af8df..701198a 100644 --- a/src/ria_toolkit_oss/sdr/pluto.py +++ b/src/ria_toolkit_oss/sdr/pluto.py @@ -274,20 +274,16 @@ class Pluto(SDR): data = [self._convert_tx_samples(samples), self._convert_tx_samples(samples)] else: if len(recording) > 2: - warnings.warn( - "More recordings were provided than channels in the Pluto. \ - Only the first two recordings will be used" - ) + warnings.warn("More recordings were provided than channels in the Pluto. \ + Only the first two recordings will be used") sample0 = self._convert_tx_samples(recording.data[0]) sample1 = self._convert_tx_samples(recording.data[1]) data = [sample0, sample1] elif isinstance(recording, list): if len(recording) > 2: - warnings.warn( - "More recordings were provided than channels in the Pluto. \ - Only the first two recordings will be used" - ) + warnings.warn("More recordings were provided than channels in the Pluto. \ + Only the first two recordings will be used") if isinstance(recording[0], np.ndarray): data = [self._convert_tx_samples(recording[0]), self._convert_tx_samples(recording[1])] @@ -427,10 +423,8 @@ class Pluto(SDR): if gain_mode == "relative": if gain > 0: - raise SDRParameterError( - "When gain_mode = 'relative', gain must be < 0. This sets \ - the gain relative to the maximum possible gain." - ) + raise SDRParameterError("When gain_mode = 'relative', gain must be < 0. This sets \ + the gain relative to the maximum possible gain.") else: abs_gain = rx_gain_max + gain else: @@ -540,10 +534,8 @@ class Pluto(SDR): if gain_mode == "relative": if gain > 0: - raise SDRParameterError( - "When gain_mode = 'relative', gain must be < 0. This sets\ - the gain relative to the maximum possible gain." - ) + raise SDRParameterError("When gain_mode = 'relative', gain must be < 0. This sets\ + the gain relative to the maximum possible gain.") else: abs_gain = tx_gain_max + gain else: diff --git a/src/ria_toolkit_oss/sdr/rtlsdr.py b/src/ria_toolkit_oss/sdr/rtlsdr.py index d49ab6e..bae677a 100644 --- a/src/ria_toolkit_oss/sdr/rtlsdr.py +++ b/src/ria_toolkit_oss/sdr/rtlsdr.py @@ -131,19 +131,15 @@ class RTLSDR(SDR): if gain_mode == "relative": if gain > 0: - raise SDRParameterError( - "When gain_mode = 'relative', gain must be < 0. This sets\ - the gain relative to the maximum possible gain." - ) + raise SDRParameterError("When gain_mode = 'relative', gain must be < 0. This sets\ + the gain relative to the maximum possible gain.") target_gain = max_gain + gain else: target_gain = gain if target_gain < min_gain or target_gain > max_gain: - print( - f"Requested gain {target_gain} dB out of range;\ - clamping to valid span {min_gain}-{max_gain} dB." - ) + print(f"Requested gain {target_gain} dB out of range;\ + clamping to valid span {min_gain}-{max_gain} dB.") target_gain = min(max(target_gain, min_gain), max_gain) target_gain = min(available_gains, key=lambda g: abs(g - target_gain)) diff --git a/src/ria_toolkit_oss/sdr/thinkrf.py b/src/ria_toolkit_oss/sdr/thinkrf.py index 7d108ab..adc25ff 100644 --- a/src/ria_toolkit_oss/sdr/thinkrf.py +++ b/src/ria_toolkit_oss/sdr/thinkrf.py @@ -392,10 +392,8 @@ class ThinkRF(SDR): actual_sample_rate = self.BASE_SAMPLE_RATE / decimation if abs(actual_sample_rate - requested_sample_rate) > 1e3: # More than 1 kHz difference - print( - f"ThinkRF: Requested {requested_sample_rate/1e6:.2f} MS/s → \ - Using decimation={decimation} ({actual_sample_rate/1e6:.2f} MS/s)" - ) + print(f"ThinkRF: Requested {requested_sample_rate/1e6:.2f} MS/s → \ + Using decimation={decimation} ({actual_sample_rate/1e6:.2f} MS/s)") return decimation, actual_sample_rate diff --git a/src/ria_toolkit_oss/sdr/usrp.py b/src/ria_toolkit_oss/sdr/usrp.py index f458378..70bbc46 100644 --- a/src/ria_toolkit_oss/sdr/usrp.py +++ b/src/ria_toolkit_oss/sdr/usrp.py @@ -148,10 +148,8 @@ class USRP(SDR): gain_range = self.usrp.get_rx_gain_range() if gain_mode == "relative": if gain > 0: - raise SDRParameterError( - "When gain_mode = 'relative', gain must be < 0. This sets\ - the gain relative to the maximum possible gain." - ) + raise SDRParameterError("When gain_mode = 'relative', gain must be < 0. This sets\ + the gain relative to the maximum possible gain.") else: # set gain relative to max abs_gain = gain_range.stop() + gain @@ -356,10 +354,8 @@ class USRP(SDR): gain_range = self.usrp.get_tx_gain_range() if gain_mode == "relative": if gain > 0: - raise SDRParameterError( - "When gain_mode = 'relative', gain must be < 0. This sets\ - the gain relative to the maximum possible gain." - ) + raise SDRParameterError("When gain_mode = 'relative', gain must be < 0. This sets\ + the gain relative to the maximum possible gain.") else: # set gain relative to max abs_gain = gain_range.stop() + gain diff --git a/src/ria_toolkit_oss/signal/block_generator/basic/add.py b/src/ria_toolkit_oss/signal/block_generator/basic/add.py index 9830f7b..fe59f16 100644 --- a/src/ria_toolkit_oss/signal/block_generator/basic/add.py +++ b/src/ria_toolkit_oss/signal/block_generator/basic/add.py @@ -37,10 +37,8 @@ class Add(RecordableBlock, ProcessBlock): samples = block.get_samples(num_samples) if len(samples) != num_samples: - raise ValueError( - f"Block {self.__class__.__name__} requested {num_samples} \ - from block {block.__class__.__name__} but got {len(samples)}." - ) + raise ValueError(f"Block {self.__class__.__name__} requested {num_samples} \ + from block {block.__class__.__name__} but got {len(samples)}.") return samples diff --git a/src/ria_toolkit_oss/signal/block_generator/process_block.py b/src/ria_toolkit_oss/signal/block_generator/process_block.py index 4b618cd..98eccd1 100644 --- a/src/ria_toolkit_oss/signal/block_generator/process_block.py +++ b/src/ria_toolkit_oss/signal/block_generator/process_block.py @@ -23,11 +23,9 @@ class ProcessBlock(Block, ABC): ) elif not all(isinstance(item, Block) for item in input): - raise ValueError( - f"Invalid input to block '{self.__class__.__name__}'. \ + raise ValueError(f"Invalid input to block '{self.__class__.__name__}'. \ Expected a list of Block objects but got \ - {'[' + ',' .join(f'{item.__class__.__name__}({repr(item)})' for item in input) + ']'}" - ) + {'[' + ',' .join(f'{item.__class__.__name__}({repr(item)})' for item in input) + ']'}") elif len(input) != len(self.input_type): raise ValueError( diff --git a/src/ria_toolkit_oss/signal/block_generator/recordable_block.py b/src/ria_toolkit_oss/signal/block_generator/recordable_block.py index 4b63648..28f2f2b 100644 --- a/src/ria_toolkit_oss/signal/block_generator/recordable_block.py +++ b/src/ria_toolkit_oss/signal/block_generator/recordable_block.py @@ -20,10 +20,8 @@ class RecordableBlock(Block, Recordable): :raises ValueError: If the number of samples is incorrect.""" samples = self.get_samples(num_samples) if len(samples) != num_samples: - raise ValueError( - f"Error in block {self.__class__.__name__} record(). \ - Requested {num_samples} samples but got {len(samples)}" - ) + raise ValueError(f"Error in block {self.__class__.__name__} record(). \ + Requested {num_samples} samples but got {len(samples)}") metadata = self._get_metadata() return Recording(data=samples, metadata=metadata) diff --git a/src/ria_toolkit_oss/signal/block_generator/source/recording_source.py b/src/ria_toolkit_oss/signal/block_generator/source/recording_source.py index 1b7795a..8a1e642 100644 --- a/src/ria_toolkit_oss/signal/block_generator/source/recording_source.py +++ b/src/ria_toolkit_oss/signal/block_generator/source/recording_source.py @@ -39,9 +39,7 @@ class RecordingSource(SourceBlock, RecordableBlock): :raises ValueError: If num_samples is greater than the recording length. """ if num_samples - 1 >= self.recording.data.shape[1]: - raise ValueError( - f"{num_samples} samples requested from recording source with \ - {self.recording.data.shape[1]} samples available." - ) + raise ValueError(f"{num_samples} samples requested from recording source with \ + {self.recording.data.shape[1]} samples available.") return self.recording.data[0, 0:num_samples] diff --git a/src/ria_toolkit_oss/transforms/iq_augmentations.py b/src/ria_toolkit_oss/transforms/iq_augmentations.py index ca859a0..106f151 100644 --- a/src/ria_toolkit_oss/transforms/iq_augmentations.py +++ b/src/ria_toolkit_oss/transforms/iq_augmentations.py @@ -610,10 +610,8 @@ def cut_out( # noqa: C901 # TODO: Simplify function raise ValueError("signal must be CxN complex.") if fill_type not in {"zeros", "ones", "low-snr", "avg-snr", "high-snr"}: - raise UserWarning( - """fill_type must be "zeros", "ones", "low-snr", "avg-snr", or "high-snr", - "ones" has been selected by default""" - ) + raise UserWarning("""fill_type must be "zeros", "ones", "low-snr", "avg-snr", or "high-snr", + "ones" has been selected by default""") if max_section_size < 1 or max_section_size >= n: raise ValueError("max_section_size must be at least 1 and must be less than the length of signal.")