Commit f6b0fa2c authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fix for not updating the data type and array shape after the complete array was replaced.

Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <>
parent 275a018e
......@@ -2,6 +2,12 @@
0.13.2 (2021-07-09)
* Fix for not updating the data type and array shape after the complete array was replaced.
0.13.1 (2021-07-09)
......@@ -168,6 +168,8 @@ class GeoArray(object):
self.flush_cache() # the cached array is not useful anymore
self._arr = ndarray
self._dtype = ndarray.dtype
self._shape = ndarray.shape
def bandnames(self):
......@@ -253,13 +255,14 @@ class GeoArray(object):
def dtype(self):
"""Get the numpy data type of the associated image array."""
if self._dtype:
return self._dtype
elif self.is_inmem:
if self.is_inmem:
return self.arr.dtype
return self._dtype
if self._dtype:
return self._dtype
return self._dtype
def geotransform(self):
......@@ -101,11 +101,28 @@ class Test_GeoArray(TestCase):
msg='The number of {i} is different from the expected result!'.format(
def test_shape_is_updated(self, _, gA):
shape_orig = gA.shape
gA.arr = np.random.randint(1, 10, (gA.shape[0], ))
self.assertEqual((gA.shape[0],), gA.shape, 'Shape attribute was not correctly updated.')
self.assertEqual((gA.shape[0],), gA._shape, 'Private shape attribute was not correctly updated.')
def test_dtype(self, _, gA):
"""Test GeoArray.dtype."""
self.assertEqual(gA.dtype, np.dtype('float32'))
def test_dtype_is_updated(self, _, gA):
"""Test if the data type gets properly updated if the full array is replaced with one with another data type."""
self.assertEqual(gA.dtype, np.float32)
gA.arr = np.random.randint(1, 10, (10, 10, 2), int)
self.assertEqual(gA.dtype, int, 'Data type attribute was not correctly updated.')
self.assertEqual(gA._dtype, int, 'Private data type attribute was not correctly updated.')
def test_geotransform_gsd_grid(self, _, gA):
"""Test GeoArray.geotransform, .xgsd, .ygsd, and .xygrid_specs."""
......@@ -549,7 +566,7 @@ class Test_GeoArray(TestCase):
vals_z = self.gA.read_pointData(mapXY_points=np.array([[366015, 5916585]]),
self.assertIsInstance(vals_z, self.gA.dtype)
self.assertEqual(vals_z.dtype, self.gA.dtype)
self.assertEqual(vals_z, 5766)
def test_read_pointData__singleCoord_allbands(self):
Supports Markdown
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