Permalink
Browse files

Fixed gis test failures when numpy isn't installed.

Thanks to Bas Peschier for pointing this out. Refs #23804.
  • Loading branch information...
1 parent 4a5d967 commit 0d9b018e07c384314e142372153eb670c2e129f3 @yellowcap yellowcap committed with timgraham Mar 20, 2015
Showing with 4 additions and 4 deletions.
  1. +1 −1 django/contrib/gis/gdal/raster/band.py
  2. +3 −3 tests/gis_tests/gdal_tests/test_raster.py
@@ -121,7 +121,7 @@ def data(self, data=None, offset=None, size=None, as_memoryview=False):
access_flag = 1
# Instantiate ctypes array holding the input data
- if isinstance(data, (bytes, six.memoryview, numpy.ndarray)):
+ if isinstance(data, (bytes, six.memoryview)) or (numpy and isinstance(data, numpy.ndarray)):
data_array = ctypes_array.from_buffer_copy(data)
else:
data_array = ctypes_array(*data)
@@ -204,10 +204,10 @@ def test_band_data_setters(self):
if numpy:
numpy.testing.assert_equal(bandmem.data(), numpy.arange(100).reshape(10, 10))
else:
- self.assertEqual(bandmem.data(), range(100))
+ self.assertEqual(bandmem.data(), list(range(100)))
# Prepare data for setting values in subsequent tests
- block = range(100, 104)
+ block = list(range(100, 104))
packed_block = struct.pack('<' + 'B B B B', *block)
# Set data from list
@@ -267,4 +267,4 @@ def test_band_data_setters(self):
numpy.array(range(25)).reshape(5, 5)
)
else:
- self.assertEqual(bandmemjson.data(), range(25))
+ self.assertEqual(bandmemjson.data(), list(range(25)))

0 comments on commit 0d9b018

Please sign in to comment.