Repository: napari/napari

Issue:
Broadcast error when viewing ome-zarr data
7d288e5c37a2c46c3ca3f4c31d8a3f51a4603797 / #1673 broke viewing ome-zarr multiscale data. I'm not sure yet what exactly is broken. Reproducible example (requires `pip install ome-zarr`):

```python
import napari

with napari.gui_qt():
    v = napari.Viewer()
    v.open('https://s3.embassy.ebi.ac.uk/idr/zarr/v0.1/6001240.zarr')
```

Results in:

```pytb
Traceback (most recent call last):
  File "/home/jni/miniconda3/envs/all/lib/python3.8/site-packages/vispy/app/backends/_qt.py", line 825, in paintGL
    self._vispy_canvas.events.draw(region=None)
  File "/home/jni/miniconda3/envs/all/lib/python3.8/site-packages/vispy/util/event.py", line 455, in __call__
    self._invoke_callback(cb, event)
  File "/home/jni/miniconda3/envs/all/lib/python3.8/site-packages/vispy/util/event.py", line 473, in _invoke_callback
    _handle_exception(self.ignore_callback_errors,
  File "/home/jni/miniconda3/envs/all/lib/python3.8/site-packages/vispy/util/event.py", line 471, in _invoke_callback
    cb(event)
  File "/home/jni/projects/napari/napari/_qt/qt_viewer.py", line 673, in on_draw
    layer._update_draw(
  File "/home/jni/projects/napari/napari/layers/base/base.py", line 771, in _update_draw
    level, corners = compute_multiscale_level_and_corners(
  File "/home/jni/projects/napari/napari/layers/utils/layer_utils.py", line 268, in compute_multiscale_level_and_corners
    level = compute_multiscale_level(
  File "/home/jni/projects/napari/napari/layers/utils/layer_utils.py", line 231, in compute_multiscale_level
    locations = np.argwhere(np.all(scaled_shape > shape_threshold, axis=1))
ValueError: operands could not be broadcast together with shapes (2,4) (2,) 
```


Discussion:
Ok good to know, thanks!! I can look into tomorrow
@sofroniewn here's a reproducible example with just numpy:

```python
import numpy as np
import napari


r0 = np.random.random((1, 2, 236, 275, 271))
r1 = np.random.random((1, 2, 236, 137, 135))

with napari.gui_qt():
    v = napari.view_image([r0, r1])
```

Resolving patch:
diff --git a/napari/layers/base/base.py b/napari/layers/base/base.py
--- a/napari/layers/base/base.py
+++ b/napari/layers/base/base.py
@@ -768,9 +768,14 @@ def _update_draw(self, scale_factors, corner_pixels, shape_threshold):
         )
 
         if self.dims.ndisplay == 2 and self.multiscale:
-            level, corners = compute_multiscale_level_and_corners(
-                data_corners, shape_threshold, self.downsample_factors,
+            level, displayed_corners = compute_multiscale_level_and_corners(
+                data_corners[:, self.dims.displayed],
+                shape_threshold,
+                self.downsample_factors[:, self.dims.displayed],
             )
+            corners = np.zeros((2, self.ndim))
+            corners[:, self.dims.displayed] = displayed_corners
+            corners = corners.astype(int)
             if self.data_level != level or not np.all(
                 self.corner_pixels == corners
             ):


Test patch:
diff --git a/napari/_vispy/_tests/test_vispy_multiscale.py b/napari/_vispy/_tests/test_vispy_multiscale.py
--- a/napari/_vispy/_tests/test_vispy_multiscale.py
+++ b/napari/_vispy/_tests/test_vispy_multiscale.py
@@ -158,3 +158,20 @@ def test_image_screenshot_zoomed(make_test_viewer):
     np.testing.assert_allclose(
         screenshot[-screen_offset, -screen_offset], target_center
     )
+
+
+@pytest.mark.skipif(
+    sys.platform.startswith('win') or not os.getenv("CI"),
+    reason='Screenshot tests are not supported on napari windows CI.',
+)
+def test_5D_multiscale(make_test_viewer):
+    """Test 5D multiscale data."""
+    # Show must be true to trigger multiscale draw and corner estimation
+    viewer = make_test_viewer(show=True)
+    shapes = [(1, 2, 5, 20, 20), (1, 2, 5, 10, 10), (1, 2, 5, 5, 5)]
+    np.random.seed(0)
+    data = [np.random.random(s) for s in shapes]
+    layer = viewer.add_image(data, multiscale=True)
+    assert layer.data == data
+    assert layer.multiscale is True
+    assert layer.ndim == len(shapes[0])
diff --git a/napari/layers/image/_tests/test_multiscale.py b/napari/layers/image/_tests/test_multiscale.py
--- a/napari/layers/image/_tests/test_multiscale.py
+++ b/napari/layers/image/_tests/test_multiscale.py
@@ -393,3 +393,14 @@ def test_world_data_extent():
     layer = Image(data)
     extent = np.array(((0,) * 3, np.subtract(shapes[0], 1)))
     check_layer_world_data_extent(layer, extent, (3, 1, 1), (10, 20, 5))
+
+
+def test_5D_multiscale():
+    """Test 5D multiscale data."""
+    shapes = [(1, 2, 5, 20, 20), (1, 2, 5, 10, 10), (1, 2, 5, 5, 5)]
+    np.random.seed(0)
+    data = [np.random.random(s) for s in shapes]
+    layer = Image(data, multiscale=True)
+    assert layer.data == data
+    assert layer.multiscale is True
+    assert layer.ndim == len(shapes[0])