diff --git a/pupil_src/shared_modules/accuracy_visualizer.py b/pupil_src/shared_modules/accuracy_visualizer.py index 92b3bf79c6..6c1d8d96ed 100644 --- a/pupil_src/shared_modules/accuracy_visualizer.py +++ b/pupil_src/shared_modules/accuracy_visualizer.py @@ -58,6 +58,13 @@ def empty() -> "CorrelatedAndCoordinateTransformedResult": camera_space=np.ndarray([]), ) + @property + def is_valid(self) -> bool: + if len(self.norm_space.shape) != 2: + return False + # TODO: Make validity check exhaustive + return True + class CorrelationError(ValueError): pass @@ -78,6 +85,13 @@ def failed() -> "AccuracyPrecisionResult": correlation=CorrelatedAndCoordinateTransformedResult.empty(), ) + @property + def is_valid(self) -> bool: + if not self.correlation.is_valid: + return False + # TODO: Make validity check exhaustive + return True + class ValidationInput: def __init__(self): @@ -354,10 +368,12 @@ def __handle_validation_data_notification(self, note_dict: dict) -> bool: return True def recalculate(self): + NOT_ENOUGH_DATA_COLLECTED_ERR_MSG = ( + "Did not collect enough data to estimate gaze mapping accuracy." + ) + if not self.recent_input.is_complete: - logger.info( - "Did not collect enough data to estimate gaze mapping accuracy." - ) + logger.warning(NOT_ENOUGH_DATA_COLLECTED_ERR_MSG) return results = self.calc_acc_prec_errlines( @@ -371,6 +387,10 @@ def recalculate(self): succession_threshold=self.succession_threshold, ) + if not results.is_valid: + logger.warning(NOT_ENOUGH_DATA_COLLECTED_ERR_MSG) + return + accuracy = results.accuracy.result if np.isnan(accuracy): self.accuracy = None