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

Core dump error when running example napari parameter sweep #153

Closed
GenevieveBuckley opened this issue Feb 15, 2021 · 3 comments · Fixed by #154
Closed

Core dump error when running example napari parameter sweep #153

GenevieveBuckley opened this issue Feb 15, 2021 · 3 comments · Fixed by #154
Labels
bug Something isn't working

Comments

@GenevieveBuckley
Copy link
Contributor

Describe the bug

I'm getting a core dumped error when I try and run the napari parameter sweep example (copy-pasted from here: https://github.com/napari/magicgui/blob/master/examples/napari_param_sweep.py)

$ python napari_param_sweep.py 
WARNING: Traceback (most recent call last):
  File "/home/genevieve/anaconda3/envs/napari-test/lib/python3.7/site-packages/magicgui/widgets/_bases/value_widget.py", line 44, in <lambda>
    lambda *x: self.changed(value=x[0] if x else None)
  File "/home/genevieve/anaconda3/envs/napari-test/lib/python3.7/site-packages/magicgui/events.py", line 603, in __call__
    self._invoke_callback(cb, event)
  File "/home/genevieve/anaconda3/envs/napari-test/lib/python3.7/site-packages/magicgui/events.py", line 625, in _invoke_callback
    cb_event=(cb, event),
  File "/home/genevieve/anaconda3/envs/napari-test/lib/python3.7/site-packages/magicgui/events.py", line 619, in _invoke_callback
    cb(event)
  File "/home/genevieve/anaconda3/envs/napari-test/lib/python3.7/site-packages/magicgui/widgets/_bases/container_widget.py", line 193, in <lambda>
    widget.changed.connect(lambda x: self.changed(value=self))
  File "/home/genevieve/anaconda3/envs/napari-test/lib/python3.7/site-packages/magicgui/events.py", line 603, in __call__
    self._invoke_callback(cb, event)
  File "/home/genevieve/anaconda3/envs/napari-test/lib/python3.7/site-packages/magicgui/events.py", line 625, in _invoke_callback
    cb_event=(cb, event),
  File "/home/genevieve/anaconda3/envs/napari-test/lib/python3.7/site-packages/magicgui/events.py", line 619, in _invoke_callback
    cb(event)
  File "/home/genevieve/anaconda3/envs/napari-test/lib/python3.7/site-packages/magicgui/widgets/_function_gui.py", line 190, in <lambda>
    self.changed.connect(lambda e: self.__call__())
  File "/home/genevieve/anaconda3/envs/napari-test/lib/python3.7/site-packages/magicgui/widgets/_function_gui.py", line 272, in __call__
    callback(self, value, return_type)
  File "/home/genevieve/anaconda3/envs/napari-test/lib/python3.7/site-packages/napari/utils/_magicgui.py", line 341, in add_layer_to_viewer
    viewer.add_layer(result)
  File "/home/genevieve/anaconda3/envs/napari-test/lib/python3.7/site-packages/napari/components/viewer_model.py", line 479, in add_layer
    self.layers.append(layer)
  File "/home/genevieve/anaconda3/envs/napari-test/lib/python3.7/_collections_abc.py", line 971, in append
    self.insert(len(self), value)
  File "/home/genevieve/anaconda3/envs/napari-test/lib/python3.7/site-packages/napari/components/layerlist.py", line 68, in insert
    new_layer = self._type_check(value)
  File "/home/genevieve/anaconda3/envs/napari-test/lib/python3.7/site-packages/napari/utils/events/containers/_typed.py", line 165, in _type_check
    f'Cannot add object with type {type(e)!r} to '
TypeError: Cannot add object with type <class 'numpy.ndarray'> to TypedList expecting type (<class 'napari.layers.base.base.Layer'>,)
Aborted (core dumped)

To Reproduce
Steps to reproduce the behavior:

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: [e.g. Windows, Mac] Ubuntu
  • backend: [e.g. Qt 5.13.0] Qt, whatever you get when you pip install napari[all]
  • magicgui version [e.g. 0.1.0] magicgui 0.2.6

Name Version Build Channel

_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 1_gnu conda-forge
alabaster 0.7.12 pypi_0 pypi
appdirs 1.4.4 pypi_0 pypi
babel 2.9.0 pypi_0 pypi
backcall 0.2.0 pypi_0 pypi
ca-certificates 2020.12.5 ha878542_0 conda-forge
cachey 0.2.1 pypi_0 pypi
certifi 2020.12.5 py37h89c1867_1 conda-forge
chardet 4.0.0 pypi_0 pypi
cycler 0.10.0 pypi_0 pypi
dask 2021.2.0 pypi_0 pypi
decorator 4.4.2 pypi_0 pypi
docstring-parser 0.7.3 pypi_0 pypi
docutils 0.16 pypi_0 pypi
freetype-py 2.2.0 pypi_0 pypi
heapdict 1.0.1 pypi_0 pypi
idna 2.10 pypi_0 pypi
imageio 2.9.0 pypi_0 pypi
imagesize 1.2.0 pypi_0 pypi
importlib-metadata 3.4.0 pypi_0 pypi
ipykernel 5.4.3 pypi_0 pypi
ipython 7.20.0 pypi_0 pypi
ipython-genutils 0.2.0 pypi_0 pypi
jedi 0.18.0 pypi_0 pypi
jinja2 2.11.3 pypi_0 pypi
jupyter-client 6.1.11 pypi_0 pypi
jupyter-core 4.7.1 pypi_0 pypi
kiwisolver 1.3.1 pypi_0 pypi
ld_impl_linux-64 2.35.1 hea4e1c9_2 conda-forge
libffi 3.3 h58526e2_2 conda-forge
libgcc-ng 9.3.0 h2828fa1_18 conda-forge
libgomp 9.3.0 h2828fa1_18 conda-forge
libstdcxx-ng 9.3.0 h6de172a_18 conda-forge
magicgui 0.2.6 pypi_0 pypi
markupsafe 1.1.1 pypi_0 pypi
matplotlib 3.3.4 pypi_0 pypi
napari 0.4.5 pypi_0 pypi
napari-console 0.0.3 pypi_0 pypi
napari-plugin-engine 0.1.9 pypi_0 pypi
napari-svg 0.1.4 pypi_0 pypi
ncurses 6.2 h58526e2_4 conda-forge
networkx 2.5 pypi_0 pypi
numpy 1.20.1 pypi_0 pypi
numpydoc 1.1.0 pypi_0 pypi
openssl 1.1.1i h7f98852_0 conda-forge
packaging 20.9 pypi_0 pypi
parso 0.8.1 pypi_0 pypi
pexpect 4.8.0 pypi_0 pypi
pickleshare 0.7.5 pypi_0 pypi
pillow 8.1.0 pypi_0 pypi
pip 21.0.1 pyhd8ed1ab_0 conda-forge
prompt-toolkit 3.0.16 pypi_0 pypi
psutil 5.8.0 pypi_0 pypi
ptyprocess 0.7.0 pypi_0 pypi
pydantic 1.7.3 pypi_0 pypi
pygments 2.8.0 pypi_0 pypi
pyopengl 3.1.5 pypi_0 pypi
pyparsing 2.4.7 pypi_0 pypi
pyqt5 5.15.2 pypi_0 pypi
pyqt5-sip 12.8.1 pypi_0 pypi
python 3.7.9 hffdb5ce_100_cpython conda-forge
python-dateutil 2.8.1 pypi_0 pypi
python_abi 3.7 1_cp37m conda-forge
pytz 2021.1 pypi_0 pypi
pywavelets 1.1.1 pypi_0 pypi
pyyaml 5.4.1 pypi_0 pypi
pyzmq 22.0.3 pypi_0 pypi
qtconsole 5.0.2 pypi_0 pypi
qtpy 1.9.0 pypi_0 pypi
readline 8.0 he28a2e2_2 conda-forge
requests 2.25.1 pypi_0 pypi
scikit-image 0.18.1 pypi_0 pypi
scipy 1.6.0 pypi_0 pypi
setuptools 49.6.0 py37h89c1867_3 conda-forge
six 1.15.0 pypi_0 pypi
snowballstemmer 2.1.0 pypi_0 pypi
sphinx 3.5.0 pypi_0 pypi
sphinxcontrib-applehelp 1.0.2 pypi_0 pypi
sphinxcontrib-devhelp 1.0.2 pypi_0 pypi
sphinxcontrib-htmlhelp 1.0.3 pypi_0 pypi
sphinxcontrib-jsmath 1.0.1 pypi_0 pypi
sphinxcontrib-qthelp 1.0.3 pypi_0 pypi
sphinxcontrib-serializinghtml 1.1.4 pypi_0 pypi
sqlite 3.34.0 h74cdb3f_0 conda-forge
tifffile 2021.2.1 pypi_0 pypi
tk 8.6.10 h21135ba_1 conda-forge
toolz 0.11.1 pypi_0 pypi
tornado 6.1 pypi_0 pypi
traitlets 5.0.5 pypi_0 pypi
typing-extensions 3.7.4.3 pypi_0 pypi
urllib3 1.26.3 pypi_0 pypi
vispy 0.6.6 pypi_0 pypi
wcwidth 0.2.5 pypi_0 pypi
wheel 0.36.2 pyhd3deb0d_0 conda-forge
wrapt 1.12.1 pypi_0 pypi
xz 5.2.5 h516909a_1 conda-forge
zipp 3.4.0 pypi_0 pypi
zlib 1.2.11 h516909a_1010 conda-forge

@GenevieveBuckley GenevieveBuckley added the bug Something isn't working label Feb 15, 2021
@jni
Copy link
Contributor

jni commented Feb 15, 2021

I was able to reproduce this also. I guess some issue with the new pydantic models! CC @sofroniewn

@sofroniewn
Copy link
Contributor

sofroniewn commented Feb 15, 2021

TypeError: Cannot add object with type <class 'numpy.ndarray'> to TypedList expecting type (<class 'napari.layers.base.base.Layer'>,)

I think this is an issue with how we changed magicgui return type annotation registration behavior in #2079 which was then dropped in #2198

Instead of

    def gaussian_blur(layer: Image, sigma: float = 1.0, mode="nearest") -> Image:
        """Apply a gaussian blur to ``layer``."""
        if layer:
            return skimage.filters.gaussian(layer.data, sigma=sigma, mode=mode)

you need

def gaussian_blur(
    layer: 'napari.layers.Image',
    sigma: Annotated[float, {"widget_type": "FloatSlider", "max": 6}] = 1.0,
    mode: Annotated[str, {"choices": ["reflect", "constant", "nearest", "mirror", "wrap"]}]="nearest",
) -> 'napari.types.ImageData':
    """Apply a gaussian blur to ``layer``."""
    if layer:
        return skimage.filters.gaussian(layer.data, sigma=sigma, mode=mode)

See https://github.com/napari/napari/blob/v0.4.5/examples/magic_parameter_sweep.py instead.

I guess some issue with the new pydantic models! CC @sofroniewn

I don't think this has anything to do with pydantic, fortunately :-)

@tlambert03
Copy link
Member

thanks for taking a look @sofroniewn, any chance you'd like to submit a PR so we can get you on the contributors list here? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants