Visitar URL original
Fix operator precedence in condition NaN/non-positive mask by Denny-Hwang · Pull Request #3408 · DeepLabCut/DeepLabCut · GitHub
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

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 mentioned this pull request Jul 16, 2026
9 tasks done
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants