Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

napari failing on labels v0.2 version of idr:6001247 #6

Closed
joshmoore opened this issue Jun 18, 2021 · 3 comments · Fixed by #12
Closed

napari failing on labels v0.2 version of idr:6001247 #6

joshmoore opened this issue Jun 18, 2021 · 3 comments · Fixed by #12

Comments

@joshmoore
Copy link
Member

(z) /tmp $NAPARI_CATCH_ERRORS=0 napari 6001247.zarr/
/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/napari/__main__.py:419: UserWarning: pythonw executable not found.
To unfreeze the menubar on macOS, click away from napari to another app, then reactivate napari. To avoid this problem, please install python.app in conda using:
conda install -c conda-forge python.app
  warnings.warn(msg)
WARNING: Layer-backing can not be explicitly controlled on 10.14 when built against the 10.14 SDK
15:00:36 WARNING Layer-backing can not be explicitly controlled on 10.14 when built against the 10.14 SDK
Traceback (most recent call last):
  File "/usr/local/anaconda3/envs/z/bin/napari", line 8, in <module>
    sys.exit(main())
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/napari/__main__.py", line 420, in main
    _run()
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/napari/__main__.py", line 304, in _run
    viewer = view_path(  # noqa: F841
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/napari/view_layers.py", line 169, in view_path
    return _make_viewer_then('open', args, kwargs)
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/napari/view_layers.py", line 119, in _make_viewer_then
    method(*args, **kwargs)
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/napari/components/viewer_model.py", line 856, in open
    self._add_layers_with_plugins(
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/napari/components/viewer_model.py", line 929, in _add_layers_with_plugins
    added.extend(self._add_layer_from_data(*_data))
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/napari/components/viewer_model.py", line 1006, in _add_layer_from_data
    raise exc
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/napari/components/viewer_model.py", line 1003, in _add_layer_from_data
    layer = add_method(data, **(meta or {}))
  File "<string>", line 4, in add_labels
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/napari/layers/labels/labels.py", line 202, in __init__
    self._properties, self._label_index = self._prepare_properties(
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/napari/layers/labels/labels.py", line 429, in _prepare_properties
    label_index = cls._map_index(properties)
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/napari/layers/labels/labels.py", line 511, in _map_index
    max_len = max(len(x) for x in properties.values())
  File "/usr/local/anaconda3/envs/z/lib/python3.9/site-packages/napari/layers/labels/labels.py", line 511, in <genexpr>
    max_len = max(len(x) for x in properties.values())
TypeError: len() of unsized object
@jni
Copy link
Contributor

jni commented Jun 25, 2021

eek! @joshmoore what are you passing in as properties=? Looking at the _prepare_properties code, we check for None or empty dicts or dataframes... Anyway here's the offending function:

https://github.com/napari/napari/blob/d310847f0c79f062daadecb8a159e8972c074470/napari/layers/labels/labels.py#L507-L512

and as far as I can tell that input should indeed be a Dict[str: np.ndarray] unless you are passing in something unexpected here... But I might be missing something.

Can this be replicated with an IDR URL?

@joshmoore
Copy link
Member Author

Not offhand, but then I've upgraded in an attempt to get things working. I imagine I need to get the above into an integration test of some form.

@will-moore
Copy link
Member

I'd missed this issue but found the same bug yesterday. See https://forum.image.sc/t/napari-labels-layer-properties/57649

At some point in the past, I believe the labels properties was a dict of label_value (int): {"key": "value"} but it is now "key": [list, of, values, for, each, label].

Not sure when that change happened. Don't know how to find older napari docs and couldn't find a relevant PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants