Commit 1c47501d authored by Daniel Scheffler's avatar Daniel Scheffler Committed by danschef

Validated Python 2.7 support.

parent 99998ce3
Pipeline #1088 failed with stages
in 37 seconds
......@@ -34,8 +34,10 @@ from py_tools_ds.geo.vector.topology \
import get_footprint_polygon, polyVertices_outside_poly, fill_holes_within_poly
from py_tools_ds.geo.vector.geometry import boxObj
from py_tools_ds.io.raster.gdal import get_GDAL_ds_inmem
from py_tools_ds.compatibility.python.exceptions \
import TimeoutError as TimeoutError_comp, FileNotFoundError as FileNotFoundError_comp
if PY3:
from builtins import TimeoutError, FileNotFoundError
else:
from py_tools_ds.compatibility.python.exceptions import TimeoutError, FileNotFoundError
from py_tools_ds.compatibility.gdal import get_gdal_func
# internal imports
......@@ -77,7 +79,7 @@ class GeoArray(object):
assert ' ' not in path_or_array, "The given path contains whitespaces. This is not supported by GDAL."
if not os.path.exists(path_or_array):
raise FileNotFoundError(path_or_array) if PY3 else FileNotFoundError_comp(path_or_array)
raise FileNotFoundError(path_or_array)
if isinstance(path_or_array, GeoArray) or issubclass(getattr(path_or_array,'__class__'), GeoArray):
......@@ -467,7 +469,7 @@ class GeoArray(object):
multipolygon = raster2polygon(self.mask_nodata.astype(np.uint8), self.gt, self.prj, exact=False,
progress=self.progress, q=self.q, maxfeatCount=10, timeout=3)
self._footprint_poly = fill_holes_within_poly(multipolygon)
except (RuntimeError, TimeoutError, TimeoutError_comp):
except (RuntimeError, TimeoutError):
if not self.q:
warnings.warn("\nCalculation of footprint polygon failed for %s '%s'. Using outer bounds. One "
"reason could be that the nodata value appears within the actual image (not only "
......
......@@ -11,7 +11,7 @@ with open('HISTORY.rst') as history_file:
history = history_file.read()
requirements = [
'py_tools_ds>=0.4.6', 'numpy', 'matplotlib', 'six', 'gdal', 'shapely', 'geopandas', 'pandas', 'dill', 'mpld3',
'py_tools_ds>=0.5.0', 'numpy', 'matplotlib', 'six', 'gdal', 'shapely', 'geopandas', 'pandas', 'dill', 'mpld3',
'geojson', 'folium', 'scikit-image'
# 'holoviews', # conda install --yes -c ioam bokeh holoviews=1.8.0 ; \
# git+https://github.com/matplotlib/basemap.git # conda install --yes -c conda-forge basemap
......
......@@ -21,7 +21,7 @@ Functions that depend on each other are tested together.
Program started in Mai 2017.
"""
from __future__ import print_function
from collections import OrderedDict
import dill
import geopandas
......@@ -40,6 +40,7 @@ import geoarray
from geoarray import GeoArray
from geoarray import masks
from py_tools_ds.geo.vector import geometry
from py_tools_ds.compatibility.python.os import makedirs
__author__ = 'Jessica Palka'
......@@ -68,8 +69,8 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
# Expected results concerning the used TIFF-image.
expected_bandnames = OrderedDict([('B1', 0), ('B2', 1)])
expected_shape = (10, 11, 2)
expected_result = (3, *expected_shape) # dimensions, rows, columns, bands
(R_exp, C_exp, B_exp) = expected_shape = (10, 11, 2)
expected_result = (3, R_exp, C_exp, B_exp) # dimensions, rows, columns, bands
expected_dtype = np.dtype('float32')
given_geotransform = (365985.0, 30.0, 0.0, 5916615.0, 0.0, -30.0)
expected_resolution = (30, 30)
......@@ -97,7 +98,7 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
# Serialize the "GeoArray"-class to the "../tests/data/output"-directory
serialized_testtiff_path = os.path.join(tests_path, "tests", "data", "output", "testtiff_path.tmp")
os.makedirs(os.path.dirname(serialized_testtiff_path), exist_ok=True)
makedirs(os.path.dirname(serialized_testtiff_path), exist_ok=True)
with open(serialized_testtiff_path, "wb") as f:
dill.dump(cls.testtiff, f)
......@@ -118,7 +119,7 @@ class Test_GeoarrayAppliedOnPathArray(unittest.TestCase):
# Serialize the "GeoArray"-class to the "../tests/data/output"-directory
serialized_testtiff_array = os.path.join(tests_path, "tests", "data", "output", "testtiff_array.tmp")
os.makedirs(os.path.dirname(serialized_testtiff_array), exist_ok=True)
makedirs(os.path.dirname(serialized_testtiff_array))
with open(serialized_testtiff_array, "wb") as f:
dill.dump(cls.testtiff, f)
......
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