File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 11# pylint: disable=too-many-lines
22import logging
3+ import math
34import os
45import time
56import warnings
5556# The system defaults can be stupidly long
5657# It used to take >8 min to timeout to a bad IP address
5758DEFAULT_REQUEST_TIMEOUT = 10 # seconds
59+ # There may be numerical noise if the confidence is ever saved in two different systems.
60+ # The confidence threshold is not that precise anyways, so we apply a tollerance within which
61+ # confidences are considered the same.
62+ DETECTOR_CONFIDENCE_TOLERANCE = 0.0001
5863
5964
6065class GroundlightClientError (Exception ):
@@ -555,7 +560,9 @@ def get_or_create_detector( # noqa: PLR0913
555560 f"Found existing detector with name={ name } (id={ existing_detector .id } ) but the group names don't"
556561 f" match. The existing group name is '{ existing_detector .group_name } '." ,
557562 )
558- if confidence_threshold is not None and existing_detector .confidence_threshold != confidence_threshold :
563+ if confidence_threshold is not None and not math .isclose (
564+ existing_detector .confidence_threshold , confidence_threshold , abs_tol = DETECTOR_CONFIDENCE_TOLERANCE
565+ ):
559566 raise ValueError (
560567 f"Found existing detector with name={ name } (id={ existing_detector .id } ) but the confidence"
561568 " thresholds don't match. The existing confidence threshold is"
You can’t perform that action at this time.
0 commit comments