Fixed gis test failures when numpy isn't installed.
Thanks to Bas Peschier for pointing this out. Refs #23804.
This commit is contained in:
parent
4a5d967dfe
commit
0d9b018e07
|
@ -121,7 +121,7 @@ class GDALBand(GDALBase):
|
|||
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 @@ class GDALBandTests(unittest.TestCase):
|
|||
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 @@ class GDALBandTests(unittest.TestCase):
|
|||
numpy.array(range(25)).reshape(5, 5)
|
||||
)
|
||||
else:
|
||||
self.assertEqual(bandmemjson.data(), range(25))
|
||||
self.assertEqual(bandmemjson.data(), list(range(25)))
|
||||
|
|
Loading…
Reference in New Issue