Repository: PMEAL/OpenPNM

Issue:
Interleave data breaks when dealing with a combination of (Nt,1) and (Nt,2) conductance models
**Describe the bug**
Suppose you have two geometries, one involves a conductance model that returns (Nt,1), and the other (Nt,2). Calling `throat.conductance` on the phase object fails.

**To Reproduce**
Steps to reproduce the behavior, ideally a code snippet that only reproduces the bug:
```python
import numpy as np
import openpnm as op


np.random.seed(10)
ws = op.Workspace()

net = op.network.Cubic(shape=[5, 1, 1])

geom2 = op.geometry.SpheresAndCylinders(network=net, pores=net.Ps, throats=net.Ts[:-1])
geom1 = op.geometry.SpheresAndCylinders(network=net, throats=net.Ts[-1])

air = op.phases.Air(network=net)

phys2 = op.physics.Standard(network=net, phase=air, geometry=geom1)
phys1 = op.physics.Standard(network=net, phase=air, geometry=geom2)

mod = op.models.physics.ad_dif_conductance.ad_dif
phys2.add_model("throat.foo", model=mod)
phys1["throat.foo"] = 1.234

g = air["throat.foo"]
print(g)
```
```python
Traceback (most recent call last):

  File "/home/amin/Code/scripts/temp.py", line 22, in <module>
    g = air["throat.foo"]

  File "/home/amin/Code/OpenPNM/openpnm/phases/GenericPhase.py", line 92, in __getitem__
    vals = super().__getitem__(key)

  File "/home/amin/Code/OpenPNM/openpnm/core/Base.py", line 27, in __getitem__
    vals = super().__getitem__(key)

  File "/home/amin/Code/OpenPNM/openpnm/core/Base.py", line 254, in __getitem__
    vals = self.interleave_data(key)

  File "/home/amin/Code/OpenPNM/openpnm/core/Base.py", line 810, in interleave_data
    temp_arr[inds] = vals

ValueError: shape mismatch: value array of shape (3,)  could not be broadcast to indexing result of shape (3,2)
```

Discussion:

Patch:
diff --git a/openpnm/core/_base.py b/openpnm/core/_base.py
index a10d5a9d8..8e72baeb7 100644
--- a/openpnm/core/_base.py
+++ b/openpnm/core/_base.py
@@ -715,11 +715,14 @@ class Base(dict):
 
         # Let's start by handling the easy cases first
         if not any([a is None for a in arrs]):
+            # If any arrays are more than 1 column, then make they all are
+            if np.any(np.array([a.ndim for a in arrs]) > 1):
+                arrs = [np.atleast_2d(a).T if a.ndim == 1 else a for a in arrs]
             # All objs are present and array found on all objs
             try:
                 W = max([a.shape[1] for a in arrs])  # Width of array
                 shape = [N, W]
-            except:
+            except IndexError:
                 shape = [N, ]
             types = [a.dtype for a in arrs]
             if len(set(types)) == 1:


Test patch:
diff --git a/tests/unit/core/InterleaveDataTest.py b/tests/unit/core/InterleaveDataTest.py
index 83f521919..f4c0ca9cb 100644
--- a/tests/unit/core/InterleaveDataTest.py
+++ b/tests/unit/core/InterleaveDataTest.py
@@ -323,6 +323,15 @@ class InterleaveDataTest:
         geo1['throat.conduit_data'] = np.ones((geo1.Nt, 1))
         geo2['throat.conduit_data'] = np.ones((geo2.Nt, 2))*2
         assert np.all(pn['throat.conduit_data'] == a)
+        # Now do it with 1D arrays
+        geo1['throat.conduit_data'] = np.ones((geo1.Nt, ))
+        geo2['throat.conduit_data'] = np.ones((geo2.Nt, 2))*2
+        assert np.all(pn['throat.conduit_data'] == a)
+        # Now do it the other way
+        geo1['throat.conduit_data'] = np.ones((geo1.Nt, 2))
+        geo2['throat.conduit_data'] = np.ones((geo2.Nt, ))*2
+        assert np.all(pn['throat.conduit_data'] == a)
+
 
 
 if __name__ == '__main__':