Skip to content

fix: handle non-numeric values in _is_nan_value to prevent save failure (closes #219)#224

Closed
botbikamordehai2-sketch wants to merge 1 commit into
DeepLabCut:mainfrom
botbikamordehai2-sketch:fix/issue-219-1780924297
Closed

fix: handle non-numeric values in _is_nan_value to prevent save failure (closes #219)#224
botbikamordehai2-sketch wants to merge 1 commit into
DeepLabCut:mainfrom
botbikamordehai2-sketch:fix/issue-219-1780924297

Conversation

@botbikamordehai2-sketch

Copy link
Copy Markdown

What

When saving labels in the napari plugin, the _is_nan_value function in misc.py attempts to call np.isnan() on values that may be non-numeric (e.g., strings, tuples in MultiIndex columns). This raises an unhandled exception that prevents the save dialog from completing, leaving no feedback to the user. The traceback shows the error originates from the write path.

Fix

Modify _is_nan_value to check if the input is numeric before calling np.isnan(). Non-numeric values are returned as False (they are not NaN). This ensures the helper function _array_has_nan works correctly on mixed-type arrays such as those with MultiIndex column labels.

Closes #219

@C-Achard C-Achard marked this pull request as draft June 9, 2026 18:16
@C-Achard C-Achard added enhancement New feature or request invalid This doesn't seem right labels Jun 9, 2026
@C-Achard

C-Achard commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

As confirmed in #219 by the user after investigation, the error was due to a duplicate bodypart in config.yaml being improperly handled.

The altered function in this PR is not related in any way to saving or writing and is used only in color display checks.
The issue is properly fixed in #220.

@C-Achard C-Achard closed this Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

napari plugin fails to save labels

2 participants