Skip to content

Commit 273e30b

Browse files
author
Uli Köhler
committed
Fix remaining E501 line too long errors
- Break long URLs, docstrings, f-strings and function signatures into multiple lines - Physics/RTD.py: Split long source URL comment - SignalProcessing/FFT.py: Split long docstrings and function signatures - SignalProcessing/Filter.py: Split long error message - SignalProcessing/Ramp.py: Split long f-string exception messages - SignalProcessing/Utils.py: Split long __repr__ f-string - Utils/Range.py: Split long __repr__ f-string
1 parent a50360e commit 273e30b

6 files changed

Lines changed: 33 additions & 11 deletions

File tree

UliEngineering/Physics/RTD.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def normalize_resistance(resistance: NormalizableArgument) -> NormalizedComputab
4747

4848
PTCoefficientStandard = namedtuple("PTCoefficientStandard", ["a", "b", "c"])
4949

50-
# Source: http://www.code10.info/index.php%3Foption%3Dcom_content%26view%3Darticle%26id%3D82:measuring-temperature-platinum-resistance-thermometers%26catid%3D60:temperature%26Itemid%3D83
50+
# Source: http://www.code10.info/index.php%3Foption%3Dcom_content%26view%3Darticle%26id%3D82:
51+
# measuring-temperature-platinum-resistance-thermometers%26catid%3D60:temperature%26Itemid%3D83
5152
ptx_ipts68 = PTCoefficientStandard(+3.90802e-03, -5.80195e-07, -4.27350e-12)
5253
ptx_its90 = PTCoefficientStandard(+3.9083E-03, -5.7750E-07, -4.1830E-12)
5354

UliEngineering/SignalProcessing/FFT.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def __init__(self, frequencies, amplitudes, angles=None):
4040
self.angles = angles
4141

4242
def __getitem__(self, arg):
43-
"""Select a frequency range: fft[1.0:100.0] selects the 1.0 ... 100.0 Hz frequency range. fft[1.0:] selects everything from 1.0 Hz to the max frequency. fft[:100.0] selects everything from 1.0 Hz to the max frequency. fft[10.0] selects (frequency, value, angle) of."""
43+
"""Select a frequency range: fft[1.0:100.0] selects the 1.0 ... 100.0 Hz frequency range.
44+
fft[1.0:] selects everything from 1.0 Hz to the max frequency. fft[:100.0] selects
45+
everything from 1.0 Hz to the max frequency. fft[10.0] selects (frequency, value, angle) of."""
4446
if isinstance(arg, slice) or isinstance(arg, tuple):
4547
if isinstance(arg, slice):
4648
start, end = arg.start, arg.stop
@@ -56,7 +58,10 @@ def __getitem__(self, arg):
5658
elif isinstance(arg, (float, int)):
5759
return self.closest_value(arg)
5860
else: # Delegate to tuple impl
59-
raise ValueError("FFT [] operator selects a frequency range([start:stop]) or (value, angle) at the closest frequency ([frequency])! {} is an illegal argument".format(arg))
61+
raise ValueError(
62+
"FFT [] operator selects a frequency range([start:stop]) or "
63+
"(value, angle) at the closest frequency ([frequency])! "
64+
"{} is an illegal argument".format(arg))
6065

6166
def dominant_frequency(self, low=None, high=None):
6267
"""
@@ -276,7 +281,8 @@ def normalize_fft_reduction(values, fftsize, nchunks=1, power=False):
276281
factor = 2.0 / (nchunks * fftsize)
277282
return vals * factor
278283

279-
def parallel_fft_reduce(chunkgen, samplerate, fftsize, removeDC=False, window="blackman", reducer=sum_reducer, normalize=True, executor=None, window_param=None):
284+
def parallel_fft_reduce(chunkgen, samplerate, fftsize, removeDC=False, window="blackman",
285+
reducer=sum_reducer, normalize=True, executor=None, window_param=None):
280286
"""
281287
Perform multiple FFTs on a single dataset, returning the reduction of all FFTs.
282288
@@ -322,10 +328,14 @@ def serial_fft_reduce(chunkgen, samplerate, fftsize, removeDC=False, window="bla
322328
if len(chunkgen) == 0:
323329
raise ValueError("Can't perform FFT on empty chunk generator")
324330
executor = QueuedThreadExecutor(nthreads=1)
325-
return parallel_fft_reduce(chunkgen, samplerate, fftsize, removeDC=removeDC, window=window, reducer=reducer, normalize=normalize, executor=executor, window_param=window_param)
331+
return parallel_fft_reduce(chunkgen, samplerate, fftsize, removeDC=removeDC,
332+
window=window, reducer=reducer, normalize=normalize,
333+
executor=executor, window_param=window_param)
326334

327335

328-
def parallel_spectral_power_fft_reduce(chunkgen, samplerate, fftsize, removeDC=False, window="blackman", normalize=True, start=0.0, end=None, executor=None, window_param=None):
336+
def parallel_spectral_power_fft_reduce(chunkgen, samplerate, fftsize, removeDC=False,
337+
window="blackman", normalize=True, start=0.0,
338+
end=None, executor=None, window_param=None):
329339
"""
330340
Like (parallel|serial)_fft_reduce, but computes a single power value per FFT chunk.
331341

UliEngineering/SignalProcessing/Filter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ def iir(self, order, ftype="butter", rp=0.01, rs=100.0):
140140
ftype=ftype, rp=rp, rs=rs)
141141
if not self.is_stable():
142142
self.a = self.b = None
143-
raise FilterUnstableError("The filter is numerically unstable. Use a lower order or a wider frequency range. You can use ChainedFilter to chain multiple filters of lower order to avoid this issue.")
143+
raise FilterUnstableError(
144+
"The filter is numerically unstable. Use a lower order or a wider "
145+
"frequency range. You can use ChainedFilter to chain multiple filters "
146+
"of lower order to avoid this issue.")
144147
return self
145148

146149
def as_samplerate(self, samplerate):

UliEngineering/SignalProcessing/Ramp.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,13 @@ def periodic_ramp(frequency, samplerate, amplitude=1.0, offset=0.0,
119119
min_acc_fall = factor * amplitude / (fall_time ** 2) if fall_time > 0 else 0
120120

121121
if acceleration < min_acc_rise:
122-
raise OperationImpossibleException(f"Acceleration {acceleration} is too low for rise time {rise_time} with {continuity} continuity. Min required: {min_acc_rise}")
122+
raise OperationImpossibleException(
123+
f"Acceleration {acceleration} is too low for rise time {rise_time} "
124+
f"with {continuity} continuity. Min required: {min_acc_rise}")
123125
if acceleration < min_acc_fall:
124-
raise OperationImpossibleException(f"Acceleration {acceleration} is too low for fall time {fall_time} with {continuity} continuity. Min required: {min_acc_fall}")
126+
raise OperationImpossibleException(
127+
f"Acceleration {acceleration} is too low for fall time {fall_time} "
128+
f"with {continuity} continuity. Min required: {min_acc_fall}")
125129

126130
# Generate time array
127131
num_samples = int(length * samplerate)

UliEngineering/SignalProcessing/Utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ def __dtype_name(self):
207207

208208
def __repr__(self):
209209
"""Return repr(self)."""
210-
return f"LinRange({self.start}, {self.stop}, {str(self.step) if isinstance(self.step, np.timedelta64) else self.step}{'' if self.dtype == float else f', dtype={self.__dtype_name()}'})"
210+
step_str = str(self.step) if isinstance(self.step, np.timedelta64) else self.step
211+
dtype_str = '' if self.dtype == float else f', dtype={self.__dtype_name()}'
212+
return f"LinRange({self.start}, {self.stop}, {step_str}{dtype_str})"
211213

212214
def __eq__(self, other):
213215
"""Return True if equal to other."""

UliEngineering/Utils/Range.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ def __new__(cls, min_val, max_val, unit=None, significant_digits=4):
1818

1919
def __repr__(self):
2020
"""Return string representation of the ValueRange."""
21-
return f"ValueRange('{format_value(self.min, self.unit, significant_digits=self.significant_digits)}', '{format_value(self.max, self.unit, significant_digits=self.significant_digits)}')"
21+
min_str = format_value(self.min, self.unit, significant_digits=self.significant_digits)
22+
max_str = format_value(self.max, self.unit, significant_digits=self.significant_digits)
23+
return f"ValueRange('{min_str}', '{max_str}')"
2224

2325
@property
2426
def minmax(self):

0 commit comments

Comments
 (0)