napari failing on labels v0.2 version of idr:6001247
Closed this issue · 3 comments
(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
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:
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?
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.
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.