Skip to content

Fix operator precedence in condition NaN/non-positive mask - #3408

Merged
C-Achard merged 1 commit into
DeepLabCut:external/hwang-misc-fixesfrom
Denny-Hwang:fix/conds-mask-precedence
Jul 16, 2026
Merged

Fix operator precedence in condition NaN/non-positive mask#3408
C-Achard merged 1 commit into
DeepLabCut:external/hwang-misc-fixesfrom
Denny-Hwang:fix/conds-mask-precedence

Conversation

@Denny-Hwang

Copy link
Copy Markdown
Contributor

The mask 'conds <= 0 | np.isnan(conds)' parses as
'conds <= (0 | np.isnan(conds))' because bitwise | binds tighter than the <= comparison, so the NaN check was not OR-ed with the non-positive check as intended. Parenthesize to '(conds <= 0) | np.isnan(conds)'.

Verified: for conds=[0.5, -0.1, nan] the buggy expression yields [False, True, False] (misses the NaN), while the fixed expression yields [False, True, True].

The mask 'conds <= 0 | np.isnan(conds)' parses as
'conds <= (0 | np.isnan(conds))' because bitwise | binds tighter than
the <= comparison, so the NaN check was not OR-ed with the
non-positive check as intended. Parenthesize to '(conds <= 0) |
np.isnan(conds)'.

Verified: for conds=[0.5, -0.1, nan] the buggy expression yields
[False, True, False] (misses the NaN), while the fixed expression
yields [False, True, True].
@C-Achard C-Achard added the bug fix! fix for a real buggy one... label Jul 15, 2026
@C-Achard
C-Achard changed the base branch from main to external/hwang-misc-fixes July 16, 2026 07:36
@C-Achard
C-Achard merged commit 2271e6d into DeepLabCut:external/hwang-misc-fixes Jul 16, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix! fix for a real buggy one...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants