Repository: napari/napari

Issue:
numpy.pad() issues on version 1.16
## 🐛 Bug

I had numpy version 1.16 and the `test_viewer.py` tests were failing because `np.pad()` was missing the `mode` positional argument (see below). I noticed that in [v1.17, `mode` is optional](https://docs.scipy.org/doc/numpy/reference/generated/numpy.pad.html) and when I upgraded numpy (1.17.3), the tests passed.

## To Reproduce

Steps to reproduce the behavior:

1. Install numpy version 1.16
2. run the tests in `/napari/tests/test_viewer.py`
3. Receive the following error

```python
self = <napari._vispy.vispy_shapes_layer.VispyShapesLayer object at 0x149450f28>

    def _on_data_change(self):
        faces = self.layer._data_view._mesh.displayed_triangles
        colors = self.layer._data_view._mesh.displayed_triangles_colors
        vertices = self.layer._data_view._mesh.vertices

        # Note that the indicies of the vertices need to be resversed to
        # go from numpy style to xyz
        if vertices is not None:
            vertices = vertices[:, ::-1] + 0.5

        if len(vertices) == 0 or len(faces) == 0:
            vertices = np.zeros((3, self.layer.dims.ndisplay))
            faces = np.array([[0, 1, 2]])
            colors = np.array([[0, 0, 0, 0]])

        if self.layer.dims.ndisplay == 3 and self.layer.dims.ndim == 2:
>           vertices = np.pad(vertices, ((0, 0), (0, 1)))
E           TypeError: pad() missing 1 required positional argument: 'mode'

../_vispy/vispy_shapes_layer.py:47: TypeError
```

## Expected behavior

Currently, the requirements specifty numpy >= 1.10.0, so I think we should bump to 1.17 (or the oldest version that passes).




Discussion:
Bumping the required version makes sense to me? Thoughts @jni?
Yep, let's do it! Pretty happy to be bleeding-edge with napari, since we are still in alpha.
Just something to consider: with the strict dependency checking in conda and the pervasiveness of numpy, this _may_ give some people conflicts when they try to install napari into a conda environment with some other dependencies (once the conda builds are working).  It’s not exactly your problem, but it may be a reason to try to be a bit more liberal with the numpy requirement
@tlambert03 , I think that is a good point - I agree that we should be careful not to over-constrain the dependencies.

As far as I could tell, this `np.pad` issue is the only reason we currently needs to bump the requirements to `numpy >= 1.17`. I can make a small PR to add the `mode` argument (it is `mode=constant` by default in 1.17) in the relevant places and we won't have to touch the `numpy` version requirement. That of course assumes there aren't other reasons to bump the requirement. At this point, I don't have a strong preference, but it seems like a pretty small change to be able to maintain compatibility with a broader range of `numpy` versions. Thoughts @jni and @sofroniewn ?
If it is a relatively simple fix like that then I lean towards making it and not bumping the requirement yet for reasons discussed above. But I will defer to the experience of @jni if he wants to weigh in again
Talley is right, conda constraints can be super annoying. Sorry, I misread and misremembered this issue and thought we would have to do more surgery. Let's just add `mode='constant'` to that line and move on with our lives! =D
Sounds good, would be great if you can take this one then @kevinyamauchi! 

Resolving patch:
diff --git a/napari/_vispy/vispy_shapes_layer.py b/napari/_vispy/vispy_shapes_layer.py
--- a/napari/_vispy/vispy_shapes_layer.py
+++ b/napari/_vispy/vispy_shapes_layer.py
@@ -44,7 +44,7 @@ def _on_data_change(self):
             colors = np.array([[0, 0, 0, 0]])
 
         if self.layer.dims.ndisplay == 3 and self.layer.dims.ndim == 2:
-            vertices = np.pad(vertices, ((0, 0), (0, 1)))
+            vertices = np.pad(vertices, ((0, 0), (0, 1)), mode='constant')
 
         self.node._subvisuals[0].set_data(
             vertices=vertices, faces=faces, face_colors=colors
diff --git a/napari/_vispy/vispy_vectors_layer.py b/napari/_vispy/vispy_vectors_layer.py
--- a/napari/_vispy/vispy_vectors_layer.py
+++ b/napari/_vispy/vispy_vectors_layer.py
@@ -25,7 +25,7 @@ def _on_data_change(self):
             faces = self.layer._view_faces
 
         if self.layer.dims.ndisplay == 3 and self.layer.dims.ndim == 2:
-            vertices = np.pad(vertices, ((0, 0), (0, 1)))
+            vertices = np.pad(vertices, ((0, 0), (0, 1)), mode='constant')
 
         self.node.set_data(
             vertices=vertices, faces=faces, color=self.layer.edge_color


Test patch: