Repository: napari/napari

Issue:
is_pyramid check has an integer overflow with large arrays
## 🐛 Bug

The pyramid size check uses np.prod which defaults to np.int32 data type and there is integer overflow when calculating size on images with dimension products greater than 2^32. 

The function below has the current function in, but commented out.
```python
def is_pyramid(data):
    """If shape of arrays along first axis is strictly decreasing.
    """
    #size = np.array([np.prod(d.shape) for d in data]) 
    size = np.array([np.prod(d.shape,dtype=np.uint64) for d in data])  #should be 64-bit integer

    if len(size) > 1:
        return np.all(size[:-1] > size[1:])
    else:
        return False
```


## To Reproduce
```python
import napari
import numpy as np

#pyramid of zeros
pyramid = [np.zeros((50000,50000,3),dtype=np.uint8),
 np.zeros((25000,25000,3),dtype=np.uint8),
np.zeros((12500,12500,3),dtype=np.uint8)]

size_default = np.array([np.prod(d.shape) for d in pyramid])
```
```
Out[43]: array([-1089934592,  1875000000,   468750000])
```
```python
size_uint64 = np.array([np.prod(d.shape,dtype=np.uint64) for d in pyramid])
```
```
Out[45]: array([7500000000, 1875000000,  468750000], dtype=uint64)
```
```python
with napari.gui_qt():
    # add image pyramid
    napari.view_image(pyramid, is_pyramid=True)

```
Traceback:
```
Traceback (most recent call last):

  File "<ipython-input-48-ce4a0e063e17>", line 3, in <module>
    napari.view_image(pyramid, is_pyramid=True)

  File "C:\anaconda3\envs\nap\lib\site-packages\napari\view_layers.py", line 120, in view_image
    path=path,

  File "C:\anaconda3\envs\nap\lib\site-packages\napari\components\viewer_model.py", line 509, in add_image
    visible=visible,

  File "C:\anaconda3\envs\nap\lib\site-packages\napari\layers\image\image.py", line 147, in __init__
    data, pyramid=is_pyramid, rgb=rgb

  File "C:\anaconda3\envs\nap\lib\site-packages\napari\util\misc.py", line 143, in get_pyramid_and_rgb
    init_shape = data.shape

AttributeError: 'list' object has no attribute 'shape'
```

Pyramidal checks are based on decreasing numbers of points per resolution. From the previous size estimate with 32 bit integers:
```python
np.all(size_default[:-1] > size_default[1:])
```
```
Out[49]: False
```

```python
np.all(size_uint64[:-1] > size_uint64[1:])
```
```
Out[51]: True
```

## Expected behavior

Should load a pyramidal image.

## Environment

napari, 0.2.5
Qt, 5.12.5
NumPy, 1.17.4
SciPy, 1.3.2
VisPy, 0.6.2
scikit-image, 0.16.2

Platform: Windows-10-10.0.10240-SP0
Python:   3.7.3 | packaged by conda-forge | (default, Jul  1 2019, 22:01:29) [MSC v.1900 64 bit (AMD64)]
Backend:  PyQt5
GL version:  '4.4.0 - Build 20.19.15.4531'
MAX_TEXTURE_SIZE: 16384



## Additional context

<!-- Add any other context about the problem here. -->

Allow Path object in `magic_read`
## 🚀 Feature
<!-- A clear and concise description of the feature proposal -->

## Motivation
I tend to use `pahtlib.Path` objects a lot for path manipulation, and passing such an object to `io.magic_read` fails due to:
```py
    if len(filenames) == 0:
        return None
```

`Path` object should be accepted as input to `magic_read`



Discussion:
Oops, good catch @NHPatterson!

We'd happily accept that fix as a PR if you don't mind making it, otherwise I can take care of it. 
Ok, I'll submit a pull request.
Thanks!


Resolving patch:
diff --git a/napari/util/misc.py b/napari/util/misc.py
--- a/napari/util/misc.py
+++ b/napari/util/misc.py
@@ -65,7 +65,7 @@ def is_rgb(shape):
 def is_pyramid(data):
     """If shape of arrays along first axis is strictly decreasing.
     """
-    size = np.array([np.prod(d.shape) for d in data])
+    size = np.array([np.prod(d.shape, dtype=np.uint64) for d in data])
     if len(size) > 1:
         return np.all(size[:-1] > size[1:])
     else:


Test patch:
diff --git a/napari/util/tests/test_misc.py b/napari/util/tests/test_misc.py
--- a/napari/util/tests/test_misc.py
+++ b/napari/util/tests/test_misc.py
@@ -1,4 +1,5 @@
 import numpy as np
+import dask.array as da
 from skimage.transform import pyramid_gaussian
 from napari.util.misc import (
     is_rgb,
@@ -98,6 +99,10 @@ def test_is_pyramid():
     )
     assert is_pyramid(data)
 
+    s = 8192
+    data = [da.ones((s,) * 3), da.ones((s // 2,) * 3), da.ones((s // 4,) * 3)]
+    assert is_pyramid(data)
+
 
 def test_trim_pyramid():