Skip to content

Commit

Permalink
API: Remove deprecated noise_threshold parameter
Browse files Browse the repository at this point in the history
...from wait_for_match, detect_match, and press_until_match.

This has been deprecated for almost 2 years now. I'm removing it as part
of the effort to streamline the documentation.
  • Loading branch information
drothlis committed Mar 26, 2015
1 parent 3fb1fd1 commit bb8fcbe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 42 deletions.
4 changes: 4 additions & 0 deletions docs/release-notes.md
Expand Up @@ -59,6 +59,10 @@ and adds no information.
if m.image == "error.png":
recover()

* Removed the `noise_threshold` parameter of `wait_for_match`, `detect_match`
and `press_until_match`. This parameter had been deprecated for almost two
years, since stb-tester 0.13.

* `stbt power status` now always requires the outlet to be explicitly specified
for network controlled PDUs, rather than printing the statuses of each outlet
in some implementation-dependent format.
Expand Down
36 changes: 2 additions & 34 deletions stbt/__init__.py
Expand Up @@ -608,8 +608,7 @@ def match(image, frame=None, match_parameters=None, region=Region.ALL):
return result


def detect_match(image, timeout_secs=10, noise_threshold=None,
match_parameters=None):
def detect_match(image, timeout_secs=10, match_parameters=None):
"""Generator that yields a sequence of one `MatchResult` for each frame
processed from the system-under-test's video stream.
Expand All @@ -619,23 +618,9 @@ def detect_match(image, timeout_secs=10, noise_threshold=None,
Returns after `timeout_secs` seconds. (Note that the caller can also choose
to stop iterating over this function's results at any time.)
The templatematch parameter `noise_threshold` is marked for deprecation
but appears in the args for backward compatibility with positional
argument syntax. It will be removed in a future release; please use
`match_parameters.confirm_threshold` intead.
Specify `match_parameters` to customise the image matching algorithm. See
the documentation for `MatchParameters` for details.
"""
if noise_threshold is not None:
warnings.warn(
"noise_threshold is deprecated and will be removed in a future "
"release of stb-tester. Please use "
"match_parameters.confirm_threshold instead.",
DeprecationWarning, stacklevel=2)
match_parameters = match_parameters or MatchParameters()
match_parameters.confirm_threshold = noise_threshold

template = _load_template(image)

debug("Searching for " + template.friendly_name)
Expand Down Expand Up @@ -753,7 +738,7 @@ def detect_motion(timeout_secs=10, noise_threshold=None, mask=None):


def wait_for_match(image, timeout_secs=10, consecutive_matches=1,
noise_threshold=None, match_parameters=None):
match_parameters=None):
"""Search for an image in the system-under-test's video stream.
:param image: The image to search for. See `match`.
Expand All @@ -778,14 +763,6 @@ def wait_for_match(image, timeout_secs=10, consecutive_matches=1,
if match_parameters is None:
match_parameters = MatchParameters()

if noise_threshold is not None:
warnings.warn(
"noise_threshold is deprecated and will be removed in a future "
"release of stb-tester. Please use "
"match_parameters.confirm_threshold instead.",
DeprecationWarning, stacklevel=2)
match_parameters.confirm_threshold = noise_threshold

match_count = 0
last_pos = Position(0, 0)
image = _load_template(image)
Expand All @@ -807,7 +784,6 @@ def press_until_match(
key,
image,
interval_secs=None,
noise_threshold=None,
max_presses=None,
match_parameters=None):
"""Call `press` as many times as necessary to find the specified image.
Expand Down Expand Up @@ -846,14 +822,6 @@ def press_until_match(
if match_parameters is None:
match_parameters = MatchParameters()

if noise_threshold is not None:
warnings.warn(
"noise_threshold is deprecated and will be removed in a future "
"release of stb-tester. Please use "
"match_parameters.confirm_threshold instead.",
DeprecationWarning, stacklevel=2)
match_parameters.confirm_threshold = noise_threshold

i = 0

while True:
Expand Down
8 changes: 0 additions & 8 deletions tests/test-match.sh
Expand Up @@ -47,14 +47,6 @@ test_wait_for_match_opencv_image_can_be_used_as_template() {
stbt run -v --control none test.py
}

test_wait_for_match_noise_threshold_raises_warning() {
cat > test.py <<-EOF
wait_for_match(
"$testdir/videotestsrc-redblue.png", noise_threshold=0.2)
EOF
stbt run -v test.py 2>&1 | grep 'DeprecationWarning'
}

test_wait_for_match_match_method_param_affects_first_pass() {
# This works on the fact that match_method="ccorr-normed" registers a
# first_pass_result greater than 0.80 which is then falsely confirmed as
Expand Down

0 comments on commit bb8fcbe

Please sign in to comment.