internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: napari/napari

Issue:
Screenshot test failing on main (due to vispy 0.10?)
## 🐛 Bug

The test `napari/_tests/test_with_screenshot.py:test_z_order_image_points_after_ndisplay` is failing on main:

https://github.com/napari/napari/runs/6069251907?check_suite_focus=true#step:7:294

I suspect that this is due to the VisPy 0.10 release, which happened in the last 24h or so.


Discussion:
I can confirm the change in behavior locally with vispy 0.10.
When entering 3D mode, the point "disappears". Going back to 2D brings it back.
Well, that's no good! LOL CC @brisvag 
Took a very quick look: the behaviour is intended, and our test is wrong :P It happens because now `Volume` sets its depth correctly, and in napari even 2D images become volumes of thickness `1 px` when moving to 3D.

Resolving patch:
diff --git a/napari/_vispy/visuals/volume.py b/napari/_vispy/visuals/volume.py
--- a/napari/_vispy/visuals/volume.py
+++ b/napari/_vispy/visuals/volume.py
@@ -118,6 +118,7 @@
         vec4 color3 = vec4(0.0);  // final color
         vec3 dstep = 1.5 / u_shape;  // step to sample derivative, set to match iso shader
         gl_FragColor = vec4(0.0);
+        bool discard_fragment = true;
         """,
     in_loop="""
         // check if value is different from the background value
@@ -134,8 +135,8 @@
                     gl_FragColor = color;
 
                     // set the variables for the depth buffer
-                    surface_point = iloc * u_shape;
-                    surface_found = true;
+                    frag_depth_point = iloc * u_shape;
+                    discard_fragment = false;
 
                     iter = nsteps;
                     break;
@@ -145,9 +146,8 @@
         }
         """,
     after_loop="""
-        if (surface_found == false) {
+        if (discard_fragment)
             discard;
-        }
         """,
 )
 


Test patch:
diff --git a/napari/_tests/test_with_screenshot.py b/napari/_tests/test_with_screenshot.py
--- a/napari/_tests/test_with_screenshot.py
+++ b/napari/_tests/test_with_screenshot.py
@@ -127,6 +127,7 @@ def test_z_order_images_after_ndisplay(make_napari_viewer):
     np.testing.assert_almost_equal(screenshot[center], [0, 0, 255, 255])
 
 
+@pytest.mark.skip('Image is 1 pixel thick in 3D, so point is swallowed')
 @skip_on_win_ci
 @skip_local_popups
 def test_z_order_image_points_after_ndisplay(make_napari_viewer):
Repository: napari/napari

Issue:
Evented containers documentation does not contain events names.
## 📚 Documentation
<!-- A clear and concise description of the documentation that needs to be created/updated -->
When checking documentation I found that list of Events of `EventedList` contains a signature but does not contain the name of events:

![Zrzut ekranu z 2022-04-26 15-38-53](https://user-images.githubusercontent.com/3826210/165312872-46dbd09e-f4a6-411b-9ba4-e3aec6da1d77.png)

https://napari.org/api/napari.utils.events.EventedList.html#napari.utils.events.EventedList


And EventedDict:
![Zrzut ekranu z 2022-04-26 15-43-59](https://user-images.githubusercontent.com/3826210/165313870-f0b693e8-4ac3-4626-8da8-071d985e71c2.png)

https://napari.org/api/napari.utils.events.EventedDict.html



Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -133,6 +133,8 @@
     'naps/template.md',
 ]
 
+napoleon_custom_sections = [('Events', 'params_style')]
+
 
 def reset_napari_theme(gallery_conf, fname):
     from napari.settings import get_settings
diff --git a/napari/utils/events/containers/_selection.py b/napari/utils/events/containers/_selection.py
--- a/napari/utils/events/containers/_selection.py
+++ b/napari/utils/events/containers/_selection.py
@@ -12,9 +12,9 @@
 
 
 class Selection(EventedSet[_T]):
-    """An model of selected items, with a `active` and `current` item.
+    """A model of selected items, with ``active`` and ``current`` item.
 
-    There can only be one `active` and one `current` item, but there can be
+    There can only be one ``active`` and one ``current` item, but there can be
     multiple selected items.  An "active" item is defined as a single selected
     item (if multiple items are selected, there is no active item).  The
     "current" item is mostly useful for (e.g.) keyboard actions: even with


Test patch:
Repository: napari/napari

Issue:
Wrong event rendering for LayerList documentation
## 📚 Documentation
<!-- A clear and concise description of the documentation that needs to be created/updated -->

Documentation of LayerList contains documentation of events, but without the information that the documented entirs are events. 

Events information in LayerList:
![Zrzut ekranu z 2022-04-28 11-36-52](https://user-images.githubusercontent.com/3826210/165724421-851ef99b-5d2d-4b9a-a679-8207f00b3e30.png)

Expected events information (here Evented list)
![Zrzut ekranu z 2022-04-28 11-36-59](https://user-images.githubusercontent.com/3826210/165724444-dea13d4e-8587-451a-a4ae-6c55595a5506.png)

Events of different objects should be rendered in the same way to increase documentation readability. 



Discussion:

Resolving patch:
diff --git a/napari/components/layerlist.py b/napari/components/layerlist.py
--- a/napari/components/layerlist.py
+++ b/napari/components/layerlist.py
@@ -28,8 +28,8 @@ class LayerList(SelectableEventedList[Layer]):
     data : iterable
         Iterable of napari.layer.Layer
 
-    Attributes
-    ----------
+    Events
+    ------
     inserting : (index: int)
         emitted before an item is inserted at ``index``
     inserted : (index: int, value: T)
@@ -49,7 +49,7 @@ class LayerList(SelectableEventedList[Layer]):
     reordered : (value: self)
         emitted when the list is reordered (eg. moved/reversed).
     selection.changed : (added: Set[_T], removed: Set[_T])
-        Emitted when the set changes, includes item(s) that have been added
+        emitted when the set changes, includes item(s) that have been added
         and/or removed from the set.
     selection.active : (value: _T)
         emitted when the current item has changed.


Test patch:
Repository: napari/napari

Issue:
npe2 plugins need to be added to `napari --info` 
## 🐛 Bug
currently, `napari --info` doesn't include npe2 plugins


Discussion:

Resolving patch:
diff --git a/napari/utils/info.py b/napari/utils/info.py
--- a/napari/utils/info.py
+++ b/napari/utils/info.py
@@ -76,6 +76,8 @@ def sys_info(as_html=False):
     as_html : bool
         if True, info will be returned as HTML, suitable for a QTextEdit widget
     """
+    from npe2 import PluginManager as Npe2PluginManager
+
     from napari.plugins import plugin_manager
 
     sys_version = sys.version.replace('\n', ' ')
@@ -152,17 +154,27 @@ def sys_info(as_html=False):
         text += f"  - failed to load screen information {e}"
 
     plugin_manager.discover()
-    plugin_strings = []
+    plugin_strings = {}
     for meta in plugin_manager.list_plugin_metadata():
         plugin_name = meta.get('plugin_name')
         if plugin_name == 'builtins':
             continue
         version = meta.get('version')
         version_string = f": {version}" if version else ""
-        plugin_strings.append(f"  - {plugin_name}{version_string}")
+        plugin_strings[plugin_name] = f"  - {plugin_name}{version_string}"
+
+    npe2_plugin_manager = Npe2PluginManager.instance()
+    for manifest in npe2_plugin_manager.iter_manifests():
+        plugin_name = manifest.name
+        if plugin_name in ("napari", "builtins"):
+            continue
+        version = manifest.package_version
+        version_string = f": {version}" if version else ""
+        plugin_strings[plugin_name] = f"  - {plugin_name}{version_string}"
+
     text += '<br><b>Plugins</b>:'
     text += (
-        ("<br>" + "<br>".join(sorted(plugin_strings)))
+        ("<br>" + "<br>".join(sorted(plugin_strings.values())))
         if plugin_strings
         else '  None'
     )


Test patch:
Repository: napari/napari

Issue:
Find how to lock .condarc file for bundle app
## 🧰 Task

With the bundle updates using conda/mamba, we need to ensure that condarc configuration from user space (`/Users/someuser/.condarc`) does not interfere with the conda/mamba that exists inside the bundled app installation.



Discussion:
xref https://github.com/conda/conda/issues/11377

Resolving patch:
diff --git a/bundle_conda.py b/bundle_conda.py
--- a/bundle_conda.py
+++ b/bundle_conda.py
@@ -49,6 +49,7 @@
 from distutils.spawn import find_executable
 from pathlib import Path
 from tempfile import NamedTemporaryFile
+from textwrap import dedent
 
 from ruamel import yaml
 
@@ -131,6 +132,30 @@ def _generate_background_images(installer_type, outpath="resources"):
         clean_these_files.append(output)
 
 
+def _get_condarc():
+    # we need defaults for tensorflow and others on windows only
+    defaults = "- defaults" if WINDOWS else ""
+    prompt = "[napari]({default_env}) "
+    contents = dedent(
+        f"""
+        channels:  #!final
+          - napari
+          - conda-forge
+          {defaults}
+        repodata_fns:  #!final
+          - repodata.json
+        auto_update_conda: false  #!final
+        channel_priority: strict  #!final
+        env_prompt: '{prompt}'  #! final
+        """
+    )
+    # the undocumented #!final comment is explained here
+    # https://www.anaconda.com/blog/conda-configuration-engine-power-users
+    with NamedTemporaryFile(delete=False, mode="w+") as f:
+        f.write(contents)
+    return f.name
+
+
 def _constructor(version=_version(), extra_specs=None):
     """
     Create a temporary `construct.yaml` input file and
@@ -183,6 +208,7 @@ def _constructor(version=_version(), extra_specs=None):
         + ["napari/label/bundle_tools", "conda-forge"]
     )
     empty_file = NamedTemporaryFile(delete=False)
+    condarc = _get_condarc()
     definitions = {
         "name": APP,
         "company": "Napari",
@@ -201,6 +227,7 @@ def _constructor(version=_version(), extra_specs=None):
         "extra_files": {
             "resources/bundle_readme.md": "README.txt",
             empty_file.name: ".napari_is_bundled_constructor",
+            condarc: ".condarc",
         },
     }
     if _use_local():
@@ -281,6 +308,7 @@ def _constructor(version=_version(), extra_specs=None):
 
     clean_these_files.append("construct.yaml")
     clean_these_files.append(empty_file.name)
+    clean_these_files.append(condarc)
 
     # TODO: temporarily patching password - remove block when the secret has been fixed
     # (I think it contains an ending newline or something like that, copypaste artifact?)


Test patch:
Repository: napari/napari

Issue:
layerlist and controls now showing before viewer
## 🐛 Bug

the lines added here in #4195:

https://github.com/napari/napari/blob/413488578b4ca22e09c300e194978c1ce6bf6f06/napari/_qt/qt_main_window.py#L882-L884

are now causing the layerlist and controls to appear briefly before being moved into the viewer:

https://user-images.githubusercontent.com/1609449/165848892-4e81231d-f952-4daf-a8ed-cd05c7a47a98.mov

cc @brisvag 




Discussion:
this also means that all tests using make_napari_viewer now flash these two panels

https://user-images.githubusercontent.com/1609449/165849462-8f493631-e72b-4419-8ad1-a82cae115e01.mov


oops! Thanks for flagging this - maybe @brisvag can take a look. @goanpeca might be able to help too. We should fix before 0.4.16 cc @jni 
> We should fix before 0.4.16

Absolutely. I've added the milestone so we don't drop that ball.
Oef... I guess it's too fast on my machine for me to notice?

I think this is worse than the alternative (#3624), so at worst we can simply revert the change.

@goanpeca , do you remember what else you tried to solve that problem?
Not sure if this helps---I just did a quick look and I may be missing something, but I tried commenting out `dock_widget.setFloating(True)` and just have `dock_widget.setFloating(False)` being called.  I *think* its still working as expected and doesn't have the dock widget flash separately.


```
# dock_widget.setFloating(True) (remove this line)
dock_widget.setFloating(False)
        ```

Resolving patch:
diff --git a/napari/_qt/qt_main_window.py b/napari/_qt/qt_main_window.py
--- a/napari/_qt/qt_main_window.py
+++ b/napari/_qt/qt_main_window.py
@@ -880,7 +880,6 @@ def _add_viewer_dock_widget(
         # self.window_menu.addAction(action)
 
         # see #3663, to fix #3624 more generally
-        dock_widget.setFloating(True)
         dock_widget.setFloating(False)
 
     def _remove_dock_widget(self, event=None):


Test patch:
Repository: napari/napari

Issue:
Catch when user provides non-RGB data but claims they do
This is more of an improvement than a bug.

## 🐛 Bug

When the user provides `rgb=True` to the viewer, there are some simple checks that can be done to confirm that the data conforms.  Instead, Napari gives cryptic error messages:

```
ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 2 is different from 3)
```

## To Reproduce

```python
import napari
import numpy as np

image = np.random.random((1024, 1024))
viewer = napari.view_image(image, rgb=True)
```

## Expected behavior

Error message: "`rgb` was set to True, but data does not have suitable dimensions"




Discussion:
Completely agree we should add some basic checks for RGB data and provide a more reasonable error message. In the interest of helping with our bug triage process, I've removed the `bug` label and added the `feature` and `good first issue` labels so other contributors know it's up for grabs!

@stefanv please ping me if you think that's unreasonable or there's another reason you'd like to keep the `bug` label! 🐞 

Resolving patch:
diff --git a/napari/layers/image/image.py b/napari/layers/image/image.py
--- a/napari/layers/image/image.py
+++ b/napari/layers/image/image.py
@@ -256,8 +256,15 @@ def __init__(
             data = MultiScaleData(data)
 
         # Determine if rgb
-        if rgb is None:
-            rgb = guess_rgb(data.shape)
+        rgb_guess = guess_rgb(data.shape)
+        if rgb and not rgb_guess:
+            raise ValueError(
+                trans._(
+                    "'rgb' was set to True but data does not have suitable dimensions."
+                )
+            )
+        elif rgb is None:
+            rgb = rgb_guess
 
         # Determine dimensionality of the data
         ndim = len(data.shape)


Test patch:
diff --git a/napari/layers/image/_tests/test_image.py b/napari/layers/image/_tests/test_image.py
--- a/napari/layers/image/_tests/test_image.py
+++ b/napari/layers/image/_tests/test_image.py
@@ -199,14 +199,13 @@ def test_non_rgb_image():
     assert layer._data_view.shape == shape[-2:]
 
 
-def test_error_non_rgb_image():
+@pytest.mark.parametrize("shape", [(10, 15, 6), (10, 10)])
+def test_error_non_rgb_image(shape):
     """Test error on trying non rgb as rgb."""
     # If rgb is set to be True in constructor but the last dim has a
-    # size > 4 then data cannot actually be rgb
-    shape = (10, 15, 6)
-    np.random.seed(0)
-    data = np.random.random(shape)
-    with pytest.raises(ValueError):
+    # size > 4 or ndim not >= 3 then data cannot actually be rgb
+    data = np.empty(shape)
+    with pytest.raises(ValueError, match="'rgb' was set to True but"):
         Image(data, rgb=True)
Repository: napari/napari

Issue:
Versioned API documentation: proposal
## 📚 Documentation

In order to enable version-specific API documentation for napari, we need a place to host and archive it. Previously, this was done on napari/napari.github.io, and the proposal here is to enable that again - but this may change the way the docs are deployed.

As of now, this is the process:
- A PR is merged to the napari/napari `main` branch;
- The [Build and Deploy docs](https://github.com/napari/napari/blob/main/.github/workflows/deploy_docs.yml) action is triggered, and pushes the built html artifacts to the gh-pages branch of napari/napari.github.io, **overwriting** whatever content is already there.

One way we could orchestrate this process is the following:
- A PR is merged to the napari/napari `main` branch;
- The [Build and Deploy docs](https://github.com/napari/napari/blob/main/.github/workflows/deploy_docs.yml) action is triggered, and pushes the built html artifacts to the `dev` subfolder of the gh-pages branch of napari/napari.github.io, keeping the existing deployments for other versions.

This of course implies changing the subfolder structure of the current documentation (released versions would show up under `napari.org/<version>`, the latest release under `napari.org/stable`, and the current version under development would show under `napari.org/dev` or something similar.) This could mean a few broken links especially if people are linking from other pages to the napari docs.

Another change this would imply is an extra action item on releases, to set up the symlink from stable to the newest release.

cc @jni @neuromusic @codemonkey800 


Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -71,13 +71,26 @@
 # a list of builtin themes.
 #
 html_theme = 'napari'
+
+# Define the json_url for our version switcher.
+json_url = "https://napari.org/version_switcher.json"
+
+if version == "dev":
+    version_match = "latest"
+else:
+    version_match = release
+
 html_theme_options = {
     "external_links": [
         {"name": "napari hub", "url": "https://napari-hub.org"}
     ],
     "github_url": "https://github.com/napari/napari",
     "navbar_start": ["navbar-project"],
-    "navbar_end": ["navbar-icon-links"],
+    "navbar_end": ["version-switcher", "navbar-icon-links"],
+    "switcher": {
+        "json_url": "https://napari.org/version_switcher.json",
+        "version_match": version_match,
+    },
 }
 
 # Add any paths that contain custom static files (such as style sheets) here,
@@ -92,6 +105,10 @@
     'custom.css',
 ]
 
+html_js_files = [
+    'redirects.js',
+]
+
 intersphinx_mapping = {
     'python': ['https://docs.python.org/3', None],
     'numpy': ['https://numpy.org/doc/stable/', None],


Test patch:
Repository: napari/napari

Issue:
Plugin installer enable/disable checkboxes not working for multi-entrypoint npe1 plugins
## 🐛 Bug
as noticed in discussion with @Czaki, the "enable/disable" checkboxes in the plugin installer menu appear to have no effect for partseg (as in, they do not modify the settings.yaml file)... but they do work for most other plugins.  Partseg is a multi-entrypoint npe1 plugin, so I assume that has something to do with it.


Discussion:

Resolving patch:
diff --git a/napari/_qt/dialogs/qt_plugin_dialog.py b/napari/_qt/dialogs/qt_plugin_dialog.py
--- a/napari/_qt/dialogs/qt_plugin_dialog.py
+++ b/napari/_qt/dialogs/qt_plugin_dialog.py
@@ -526,7 +526,7 @@ def _on_enabled_checkbox(self, state: int):
             return
 
         for npe1_name, _, distname in plugin_manager.iter_available():
-            if distname and (distname == plugin_name):
+            if distname and (normalized_name(distname) == plugin_name):
                 plugin_manager.set_blocked(npe1_name, not enabled)
 
     def show_warning(self, message: str = ""):
@@ -825,7 +825,7 @@ def _add_to_installed(distname, enabled, npe_version=1):
             # not showing these in the plugin dialog
             if plugin_name in ('napari_plugin_engine',):
                 continue
-            if distname in self.already_installed:
+            if normalized_name(distname or '') in self.already_installed:
                 continue
             _add_to_installed(
                 distname, not plugin_manager.is_blocked(plugin_name)


Test patch:
Repository: napari/napari

Issue:
Public api for viewer.window._qt_window.setGeometry()
## 🚀 Feature
Public api for viewer.window._qt_window.setGeometry()

## Motivation & Pitch
This feature is needed to place several napari viewers on the screen for example. Unless I have missed it in the docs, I haven't found another way to set the geometry of the window with a public method.

## Alternatives

Not deprecate the current implementation. Currently I get this warning:
`FutureWarning: Private attribute access ('Window._qt_window') in this context (e.g. inside a plugin widget or dock widget) is deprecated and will be unavailable in version 0.5.0!
`

## Additional context

This is needed in plugins for example.



Discussion:

Resolving patch:
diff --git a/napari/_qt/qt_main_window.py b/napari/_qt/qt_main_window.py
--- a/napari/_qt/qt_main_window.py
+++ b/napari/_qt/qt_main_window.py
@@ -1019,6 +1019,39 @@ def resize(self, width, height):
         """
         self._qt_window.resize(width, height)
 
+    def set_geometry(self, left, top, width, height):
+        """Set the geometry of the widget
+
+        Parameters
+        ----------
+        left : int
+            X coordinate of the upper left border.
+        top : int
+            Y coordinate of the upper left border.
+        width : int
+            Width of the rectangle shape of the window.
+        height : int
+            Height of the rectangle shape of the window.
+        """
+        self._qt_window.setGeometry(left, top, width, height)
+
+    def geometry(self) -> Tuple[int, int, int, int]:
+        """Get the geometry of the widget
+
+        Returns
+        -------
+        left : int
+            X coordinate of the upper left border.
+        top : int
+            Y coordinate of the upper left border.
+        width : int
+            Width of the rectangle shape of the window.
+        height : int
+            Height of the rectangle shape of the window.
+        """
+        rect = self._qt_window.geometry()
+        return rect.left(), rect.top(), rect.width(), rect.height()
+
     def show(self, *, block=False):
         """Resize, show, and bring forward the window.
 


Test patch:
diff --git a/napari/_qt/_tests/test_qt_window.py b/napari/_qt/_tests/test_qt_window.py
--- a/napari/_qt/_tests/test_qt_window.py
+++ b/napari/_qt/_tests/test_qt_window.py
@@ -48,6 +48,13 @@ def test_current_viewer(make_napari_viewer):
     assert _QtMainWindow.current() is None
 
 
+def test_set_geometry(make_napari_viewer):
+    viewer = make_napari_viewer()
+    values = (70, 70, 1000, 700)
+    viewer.window.set_geometry(*values)
+    assert viewer.window.geometry() == values
+
+
 @patch.object(Window, "_theme_icon_changed")
 @patch.object(Window, "_remove_theme")
 @patch.object(Window, "_add_theme")