Repository: PMEAL/porespy

Issue:
boundary_width in snow2 breaks when trying to specify padding on both ends of all axes
This works:
`b = ps.networks.snow2(im, boundary_width=[[5, 15], 10])`

This breaks:
`b = ps.networks.snow2(im, boundary_width=[[5, 15], [10, 10]])`

The complaint is coming from `np.pad`: `TypeError: `pad_width` must be of integral type.`

Comments:

Patch:
diff --git a/porespy/networks/_snow2.py b/porespy/networks/_snow2.py
index 5aa197559..404ef5d99 100644
--- a/porespy/networks/_snow2.py
+++ b/porespy/networks/_snow2.py
@@ -244,4 +244,4 @@ def _parse_pad_width(pad_width, shape):
         else:
             raise Exception("pad_width components can't have 2+ elements")
 
-    return np.array(tmp)
+    return np.array(tmp, dtype=int)


Test patch:
diff --git a/test/unit/test_snow2.py b/test/unit/test_snow2.py
index be6057dbb..c22273b01 100644
--- a/test/unit/test_snow2.py
+++ b/test/unit/test_snow2.py
@@ -108,10 +108,11 @@ class Snow2Test:
         ]
         for case, out_desired in test_cases_2d:
             try:
-                out = ps.networks._parse_pad_width(case, shape_2d).tolist()
+                out = ps.networks._parse_pad_width(case, shape_2d)
+                assert out.dtype == int
             except Exception as e:
                 out = e.args[0]
-            assert out == out_desired
+            assert np.all(out == out_desired)
 
     def test_parse_pad_width_3d(self):
         shape_3d = [10, 10, 10]
@@ -133,10 +134,11 @@ class Snow2Test:
         ]
         for case, out_desired in test_cases_3d:
             try:
-                out = ps.networks._parse_pad_width(case, shape_3d).tolist()
+                out = ps.networks._parse_pad_width(case, shape_3d)
+                assert out.dtype == int
             except Exception as e:
                 out = e.args[0]
-            assert out == out_desired
+            assert np.all(out == out_desired)
 
     def test_label_phases(self):
         im = self.spheres2D
@@ -155,7 +157,7 @@ class Snow2Test:
     def test_ensure_correct_sizes_are_returned_single_phase_2d(self):
         im = self.spheres2D
         snow = ps.networks.snow2(phases=im, parallelization=None)
-        mode = spst.mode(snow.network['pore.extended_diameter'])
+        mode = spst.mode(snow.network['pore.extended_diameter'], keepdims=False)
         assert mode[0] == 60
         D = np.unique(snow.network['pore.extended_diameter'].astype(int))
         assert np.all(D == np.array([30, 34, 60]))
@@ -164,7 +166,7 @@ class Snow2Test:
         im = self.spheres2D
         phases = im.astype(int) + 1
         snow = ps.networks.snow2(phases=phases, parallelization=None)
-        mode = spst.mode(snow.network['pore.extended_diameter'])
+        mode = spst.mode(snow.network['pore.extended_diameter'], keepdims=False)
         assert mode[0] == 60
         D = np.unique(snow.network['pore.extended_diameter'].astype(int))
         assert np.all(D == np.array([15, 16, 17, 18, 19, 21,
@@ -173,7 +175,7 @@ class Snow2Test:
     def test_ensure_correct_sizes_are_returned_single_phase_3d(self):
         im = self.spheres3D
         snow = ps.networks.snow2(phases=im, parallelization=None)
-        mode = spst.mode(snow.network['pore.extended_diameter'])
+        mode = spst.mode(snow.network['pore.extended_diameter'], keepdims=False)
         assert mode[0] == 30
         D = np.unique(snow.network['pore.extended_diameter'].astype(int))
         assert np.all(D == np.array([25, 30, 38]))
@@ -182,7 +184,7 @@ class Snow2Test:
         im = self.spheres3D
         phases = im.astype(int) + 1
         snow = ps.networks.snow2(phases=phases, parallelization=None)
-        mode = spst.mode(snow.network['pore.extended_diameter'])
+        mode = spst.mode(snow.network['pore.extended_diameter'], keepdims=False)
         assert mode[0] == 30
         D = np.unique(snow.network['pore.extended_diameter'].astype(int))
         assert np.all(D == np.array([7, 12, 17, 19, 20, 22, 24, 25, 26,