# Buggy code
def _set_view_slice(self):
    """Set the view given the indices to slice with."""
    if self.multichannel:
        # if multichannel need to keep the final axis fixed during the
        # transpose. The index of the final axis depends on how many
        # axes are displayed.
        order = self.dims.displayed_order + (self.dims.ndisplay,)
    else:
        order = self.dims.displayed_order

    self._data_view = np.asarray(self.data[self.dims.indices]).transpose(order)

    self._data_thumbnail = self._data_view
    self._update_thumbnail()
    self._update_coordinates()
    self.events.set_data()


# Traceback (ValueError)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-42-5ae500208e78> in <module>
----> 1 napari.view(array)

/Applications/anaconda3/envs/chloe/lib/python3.7/site-packages/napari/view_function.py in view(title, metadata, multichannel, contrast_limits, *images, **named_images)
51             metadata=metadata,
52             multichannel=multichannel,
---> 53             contrast_limits=contrast_limits,
54         )
55     for name, image in named_images.items():

/Applications/anaconda3/envs/chloe/lib/python3.7/site-packages/napari/components/viewer_model.py in add_image(self, data, multichannel, colormap, contrast_limits, interpolation, rendering, name, metadata, scale, translate, opacity, blending, visible)
411             opacity=opacity,
412             blending=blending,
--> 413             visible=visible,
414         )
415         self.add_layer(layer)

/Applications/anaconda3/envs/chloe/lib/python3.7/site-packages/napari/layers/image/image.py in __init__(self, data, multichannel, colormap, contrast_limits, interpolation, rendering, name, metadata, scale, translate, opacity, blending, visible)
174
175         # Trigger generation of view slice and thumbnail
--> 176         self._update_dims()
177
178     @property

/Applications/anaconda3/envs/chloe/lib/python3.7/site-packages/napari/layers/base/base.py in _update_dims(self)
313             self.dims.set_range(i, r)
314
--> 315         self._set_view_slice()
316         self._update_coordinates()
317

/Applications/anaconda3/envs/chloe/lib/python3.7/site-packages/napari/layers/image/image.py in _set_view_slice(self)
333
334         self._data_thumbnail = self._data_view
--> 335         self._update_thumbnail()
336         self._update_coordinates()
337         self.events.set_data()

/Applications/anaconda3/envs/chloe/lib/python3.7/site-packages/napari/layers/image/image.py in _update_thumbnail(self)
392             colormapped = colormapped.reshape(downsampled.shape + (4,))
393             colormapped[..., 3] *= self.opacity
--> 394         self.thumbnail = colormapped
395
396     def get_value(self):

/Applications/anaconda3/envs/chloe/lib/python3.7/site-packages/napari/layers/base/base.py in thumbnail(self, thumbnail)
353             with warnings.catch_warnings():
354                 warnings.simplefilter("ignore")
--> 355                 thumbnail = img_as_ubyte(thumbnail)
356         self._thumbnail = thumbnail
357         self.events.thumbnail()

/Applications/anaconda3/envs/chloe/lib/python3.7/site-packages/skimage/util/dtype.py in img_as_ubyte(image, force_copy)
484
485     """
--> 486     return convert(image, np.uint8, force_copy)
487
488

/Applications/anaconda3/envs/chloe/lib/python3.7/site-packages/skimage/util/dtype.py in convert(image, dtype, force_copy, uniform)
253
254         if np.min(image) < -1.0 or np.max(image) > 1.0:
--> 255             raise ValueError("Images of type float must be between -1 and 1.")
256         # floating point -> integer
257         prec_loss()

ValueError: Images of type float must be between -1 and 1.

# Fixed code
def _set_view_slice(self):
    """Set the view given the indices to slice with."""
    if self.multichannel:
        # if multichannel need to keep the final axis fixed during the
        # transpose. The index of the final axis depends on how many
        # axes are displayed.
        order = self.dims.displayed_order + (self.dims.ndisplay,)
    else:
        order = self.dims.displayed_order

    image = np.asarray(self.data[self.dims.indices]).transpose(order)

    if self.multichannel and image.dtype.kind == "f":
        self._data_view = np.clip(image, 0, 1)
    else:
        self._data_view = image

    self._data_thumbnail = self._data_view
    self._update_thumbnail()
    self._update_coordinates()
    self.events.set_data()