Browse Source

ValueError attempt to get argmin of an empty sequence #518 (#537)

pull/1/head
Alexandr Velikiy 6 years ago committed by rozetko
parent
commit
a9971d64d0
  1. 5
      analytics/analytics/models/model.py
  2. 1
      analytics/analytics/models/peak_model.py
  3. 1
      analytics/analytics/models/trough_model.py

5
analytics/analytics/models/model.py

@ -143,10 +143,13 @@ class Model(ABC):
learning_info['pattern_timestamp'].append(segment.pattern_timestamp) learning_info['pattern_timestamp'].append(segment.pattern_timestamp)
aligned_segment = utils.get_interval(data, segment_center, self.state['WINDOW_SIZE']) aligned_segment = utils.get_interval(data, segment_center, self.state['WINDOW_SIZE'])
aligned_segment = utils.subtract_min_without_nan(aligned_segment) aligned_segment = utils.subtract_min_without_nan(aligned_segment)
if len(aligned_segment) == 0:
logging.warning('cant add segment to learning because segment is empty where segments center is: {}, window_size: {}, and len_data: {}'.format(
segment_center, self.state['WINDOW_SIZE'], len(data)))
continue
learning_info['patterns_list'].append(aligned_segment) learning_info['patterns_list'].append(aligned_segment)
if model == 'peak' or model == 'trough': if model == 'peak' or model == 'trough':
learning_info['pattern_height'].append(utils.find_confidence(aligned_segment)[1]) learning_info['pattern_height'].append(utils.find_confidence(aligned_segment)[1])
learning_info['pattern_width'].append(utils.find_width(aligned_segment, model_type))
learning_info['patterns_value'].append(aligned_segment.values.max()) learning_info['patterns_value'].append(aligned_segment.values.max())
if model == 'jump' or model == 'drop': if model == 'jump' or model == 'drop':
pattern_height, pattern_length = utils.find_parameters(segment.data, segment.start, model) pattern_height, pattern_length = utils.find_parameters(segment.data, segment.start, model)

1
analytics/analytics/models/peak_model.py

@ -62,7 +62,6 @@ class PeakModel(Model):
del_conv = scipy.signal.fftconvolve(deleted, self.state['pattern_model']) del_conv = scipy.signal.fftconvolve(deleted, self.state['pattern_model'])
if len(del_conv): del_conv_list.append(max(del_conv)) if len(del_conv): del_conv_list.append(max(del_conv))
delete_pattern_height.append(utils.find_confidence(deleted)[1]) delete_pattern_height.append(utils.find_confidence(deleted)[1])
delete_pattern_width.append(utils.find_width(deleted, True))
self._update_fiting_result(self.state, learning_info['confidence'], convolve_list, del_conv_list, height_list) self._update_fiting_result(self.state, learning_info['confidence'], convolve_list, del_conv_list, height_list)

1
analytics/analytics/models/trough_model.py

@ -62,7 +62,6 @@ class TroughModel(Model):
del_conv = scipy.signal.fftconvolve(deleted, self.state['pattern_model']) del_conv = scipy.signal.fftconvolve(deleted, self.state['pattern_model'])
if len(del_conv): del_conv_list.append(max(del_conv)) if len(del_conv): del_conv_list.append(max(del_conv))
delete_pattern_height.append(utils.find_confidence(deleted)[1]) delete_pattern_height.append(utils.find_confidence(deleted)[1])
delete_pattern_width.append(utils.find_width(deleted, False))
self._update_fiting_result(self.state, learning_info['confidence'], convolve_list, del_conv_list, height_list) self._update_fiting_result(self.state, learning_info['confidence'], convolve_list, del_conv_list, height_list)

Loading…
Cancel
Save