From 0a2b75f6de199af4a99064d6a0fea9ec550d075a Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Tue, 1 Mar 2022 12:39:52 -0500 Subject: [PATCH 1/3] _np_dtype: eliminate "is True". Writing "if X is True" is almost always a mistake. --- wfdb/io/_signal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wfdb/io/_signal.py b/wfdb/io/_signal.py index a7f124fb..dbe7d046 100644 --- a/wfdb/io/_signal.py +++ b/wfdb/io/_signal.py @@ -1891,7 +1891,7 @@ def _np_dtype(bit_res, discrete): if bit_res <= np_res: break - if discrete is True: + if discrete: return 'int' + str(np_res) else: # No float8 dtype From e2ce76b163fb656a823f513338d28c4db2e7cd84 Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Tue, 1 Mar 2022 12:41:13 -0500 Subject: [PATCH 2/3] check_read_inputs: eliminate "is True" and "is False". Writing "if X is True" is almost always a mistake. --- wfdb/io/record.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wfdb/io/record.py b/wfdb/io/record.py index 077c03b5..bc51cda8 100644 --- a/wfdb/io/record.py +++ b/wfdb/io/record.py @@ -409,12 +409,12 @@ def check_read_inputs(self, sampfrom, sampto, channels, physical, if return_res not in [64, 32, 16, 8]: raise ValueError("return_res must be one of the following: 64, 32, 16, 8") - if physical is True and return_res == 8: + if physical and return_res == 8: raise ValueError("return_res must be one of the following when physical is True: 64, 32, 16") # Cannot expand multiple samples/frame for multi-segment records if isinstance(self, MultiRecord): - if smooth_frames is False: + if not smooth_frames: raise ValueError('This package version cannot expand all samples when reading multi-segment records. Must enable frame smoothing.') From ebd9d40a3b61b049d4d03f3b736fdfc6c6eb50c1 Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Tue, 1 Mar 2022 12:45:29 -0500 Subject: [PATCH 3/3] convert_dtype: eliminate "is True" and "is False". Writing "if X is True" is almost always a mistake. This change allows rdrecord to be called with "physical=1" ("physical=0" would work previously, but "physical=1" wouldn't) or with "smooth_frames=0" ("smooth_frames=1" would work previously, but "smooth_frames=0" wouldn't.) --- wfdb/io/_signal.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wfdb/io/_signal.py b/wfdb/io/_signal.py index dbe7d046..868d3596 100644 --- a/wfdb/io/_signal.py +++ b/wfdb/io/_signal.py @@ -698,9 +698,9 @@ def convert_dtype(self, physical, return_res, smooth_frames): N/A """ - if physical is True: + if physical: return_dtype = 'float'+str(return_res) - if smooth_frames is True: + if smooth_frames: current_dtype = self.p_signal.dtype if current_dtype != return_dtype: self.p_signal = self.p_signal.astype(return_dtype, copy=False) @@ -715,7 +715,7 @@ def convert_dtype(self, physical, return_res, smooth_frames): self.p_signal[ch] = self.p_signal[ch].astype(return_dtype, copy=False) else: return_dtype = 'int'+str(return_res) - if smooth_frames is True: + if smooth_frames: current_dtype = self.d_signal.dtype if current_dtype != return_dtype: # Do not allow changing integer dtype to lower value due to over/underflow