Commit a33ec5ac authored by Daniel Scheffler's avatar Daniel Scheffler

Merge branch 'bugfix/fix_ensure_np_shape_consistency_3D_2D' into 'master'

Bugfix.

See merge request !8
parents c249500e 335a3c52
Pipeline #4002 passed with stages
in 11 minutes and 9 seconds
......@@ -866,7 +866,7 @@ class GeoArray(object):
arr = arr[:, :, np.newaxis]
# 3D -> 2D
if 1 in arr.shape:
if 1 in arr.shape and len(getitem_params) != 1:
outshape = []
for i, sh in enumerate(arr.shape):
if sh == 1 and isinstance(getitem_params[i], (int, np.integer, float, np.floating)):
......
__version__ = '0.8.18'
__versionalias__ = '20190514.01'
__version__ = '0.8.19'
__versionalias__ = '20190522.01'
......@@ -346,6 +346,21 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
self.assertEqual(inmem_res.ndim, notinmem_res.ndim)
self.assertEqual(inmem_res.shape, notinmem_res.shape)
def test___getitem__consistency_3d_array_1_column(self):
testarr = np.array([[1, 2], [3, 4]]).reshape(2, 1, 2)
gA_inmem = GeoArray(testarr)
inmem_res = gA_inmem[:]
with tempfile.TemporaryDirectory() as tf:
gA_inmem.save(os.path.join(tf, 'test.bsq'))
gA_notinmem = GeoArray(os.path.join(tf, 'test.bsq'))
notinmem_res = gA_notinmem[:]
self.assertEqual(inmem_res.ndim, notinmem_res.ndim)
self.assertEqual(inmem_res.shape, notinmem_res.shape)
def test___getitem__consistency_2d_array(self):
testarr = np.zeros((2, 2))
testarr[:, :] = [[11, 12], [13, 14]]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment