@@ -818,22 +818,31 @@ def detect_clearsky(measured, clearsky, times=None, infer_limits=False,
818818 sample_interval , samples_per_window = \
819819 tools ._get_sample_intervals (times , window_length )
820820
821- if samples_per_window < 3 :
822- raise ValueError (f"Samples per window of { samples_per_window } "
823- " found. Each window must contain at least 3 data"
824- " points."
825- f" Window length of { window_length } found; increase"
826- f" window length to { 3 * sample_interval } or longer." )
827-
828821 # if infer_limits, find threshold values using the sample interval
829822 if infer_limits :
830- window_length , mean_diff , max_diff , lower_line_length , \
831- upper_line_length , var_diff , slope_dev = \
832- _clearsky_get_threshold (sample_interval )
823+ (
824+ window_length ,
825+ mean_diff ,
826+ max_diff ,
827+ lower_line_length ,
828+ upper_line_length ,
829+ var_diff ,
830+ slope_dev ,
831+ ) = _clearsky_get_threshold (sample_interval )
833832
834833 # recalculate samples_per_window using returned window_length
835- _ , samples_per_window = \
836- tools ._get_sample_intervals (times , window_length )
834+ sample_interval , samples_per_window = tools ._get_sample_intervals (
835+ times , window_length
836+ )
837+
838+ if samples_per_window < 3 :
839+ raise ValueError (
840+ f"Samples per window of { samples_per_window } "
841+ " found. Each window must contain at least 3 data"
842+ " points."
843+ f" Window length of { window_length } found. Increase"
844+ f" window length to { 3 * sample_interval } or longer."
845+ )
837846
838847 # check that we have enough data to produce a nonempty hankel matrix
839848 if len (times ) < samples_per_window :
0 commit comments