Commit 6d295c2f authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Merge branch 'master' into enhancement/improve_test_cov

# Conflicts:
#	HISTORY.rst
#	tests/test_geoarray.py
parents 19bcaf8e bf03bd02
Pipeline #19576 passed with stage
in 1 minute and 44 seconds
......@@ -14,8 +14,9 @@ test_geoarray:
- source /root/miniconda3/bin/activate ci_env
# update py_tools_ds
- pip install -U py_tools_ds # FIXME Remove as soon as docker container is rebuilt
- conda install -c conda-forge cartopy # FIXME Remove as soon as docker container is rebuilt
- pip install -U py_tools_ds -q
- pip install parameterized -q # TODO remove as soon as CI runner is rebuilt
# run tests
- make nosetests
......
# Config file for automatic testing at travis-ci.org
# This file will be regenerated if you run travis_pypi_setup.py
language: python
python: 3.5
env:
- TOXENV=py35
- TOXENV=py34
- TOXENV=py33
- TOXENV=py27
- TOXENV=py26
- TOXENV=pypy
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install: pip install -U tox
# command to run tests, e.g. python setup.py test
script: tox -e ${TOXENV}
......@@ -2,17 +2,41 @@
History
=======
0.10.7 (coming soon)
--------------------
0.10.10 (coming soon)
---------------------
* Added test for GeoArray.show().
* Fixed holoviews DeprecationWarning within GeoArray.show().
0.10.6 (2020-12-09)
0.10.9 (2021-02-19)
-------------------
* Revised tests.
* Added parameterized as test requirement.
* Replaced deprecated numpy data types with builtin types.
* Fixed dead link in the docs.
0.10.8 (2021-01-28)
-------------------
* Fixed an issue in GeoArray.show() that caused an invisible plot for some input images.
0.10.7 (2021-01-27)
-------------------
* Fixed a numpy overflow error within GeoArray.show() due to float16 data type.
0.10.6 (2021-01-25)
-------------------
* Added URL checker CI job and fixed all dead URLs.
* Fixed wrong package name in environment_geoarray.yml.
* Moved folium and geojson to optional dependencies. Revised 'extras_require' parameter in setup.py.
* Removed .travis.yml.
0.10.5 (2020-12-08)
......
......@@ -113,6 +113,6 @@ This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypack
.. _coverage: https://danschef.git-pages.gfz-potsdam.de/geoarray/coverage/
.. _nosetests: https://danschef.git-pages.gfz-potsdam.de/geoarray/nosetests_reports/nosetests.html
.. _conda: https://conda.io/docs/
.. _here: examples/notebooks/features_and_usage.ipynb
.. _here: https://git.gfz-potsdam.de/danschef/geoarray/-/blob/master/examples/notebooks/features_and_usage.ipynb
.. _pip: https://pip.pypa.io
.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/
......@@ -674,7 +674,7 @@ class GeoArray(object):
arr = self[:, :, fromBand] if self.ndim == 3 and fromBand is not None else self[:]
if self.nodata is None:
mask = np.ones((self.rows, self.cols), np.bool)
mask = np.ones((self.rows, self.cols), bool)
elif np.isnan(self.nodata):
nanmask = np.isnan(arr)
......@@ -971,7 +971,7 @@ class GeoArray(object):
# write _arr_cache
self._arr_cache = dict(pos=arr_pos, arr_cached=out_arr)
return out_arr # TODO implement check of returned datatype (e.g. NoDataMask should always return np.bool
return out_arr # TODO implement check of returned datatype (e.g. NoDataMask should always return bool
# TODO -> would be np.int8 if an int8 file is read from disk
def save(self, out_path, fmt='ENVI', creationOptions=None):
......@@ -1147,16 +1147,25 @@ class GeoArray(object):
@staticmethod
def _get_cmap_vmin_vmax(cmap, vmin, vmax, pmin, pmax, image2plot, nodataVal):
from matplotlib import pyplot as plt
# set color palette
palette = plt.get_cmap(cmap) if cmap and isinstance(cmap, str) else cmap if cmap else plt.get_cmap('gray')
palette = \
plt.get_cmap(cmap) if cmap and isinstance(cmap, str) else \
cmap if cmap else \
plt.get_cmap('gray')
palette = copy(palette) # allows to modify the colormap as in-place modifications are not allowed anymore
if nodataVal is not None and np.std(image2plot) != 0: # do not show nodata
if nodataVal is not None and \
np.std(image2plot.astype(float)) != 0: # do not show nodata; float is needed to avoid overflow error
image2plot = np.ma.masked_equal(image2plot, nodataVal)
vmin_auto, vmax_auto = \
np.nanpercentile(image2plot.compressed(), pmin), np.nanpercentile(image2plot.compressed(), pmax)
vmin_auto = np.nanpercentile(image2plot.compressed(), pmin)
vmax_auto = np.nanpercentile(image2plot.compressed(), pmax)
palette.set_bad('aqua', 0)
else:
vmin_auto, vmax_auto = np.nanpercentile(image2plot, pmin), np.nanpercentile(image2plot, pmax)
vmin_auto = np.nanpercentile(image2plot, pmin)
vmax_auto = np.nanpercentile(image2plot, pmax)
vmin = vmin if vmin is not None else vmin_auto
vmax = vmax if vmax is not None else vmax_auto
......@@ -1209,7 +1218,7 @@ class GeoArray(object):
ignore_rotation=ignore_rotation)
palette, vmin, vmax = self._get_cmap_vmin_vmax(cmap, vmin, vmax, pmin, pmax, image2plot, nodataVal)
if nodataVal is not None and np.std(image2plot) != 0:
if nodataVal is not None and np.std(image2plot.astype(float)) != 0:
image2plot = np.ma.masked_equal(image2plot, nodataVal)
# check availability of holoviews
......@@ -1255,8 +1264,12 @@ class GeoArray(object):
ax = plt.gca()
rows, cols = image2plot.shape[:2]
im = ax.imshow(image2plot, palette, interpolation=interpolation, extent=(0, cols, rows, 0),
vmin=vmin, vmax=vmax, ) # compressed excludes nodata values
im = ax.imshow(image2plot.astype(np.int),
palette,
interpolation=interpolation,
extent=(0, cols, rows, 0),
vmin=vmin,
vmax=vmax, ) # compressed excludes nodata values
plt.show()
return im
......
......@@ -38,7 +38,7 @@ class BadDataMask(GeoArray):
if self.is_inmem:
# validate input data - before converting to bool
self._validate_array_values(self.arr)
self.arr = self.arr.astype(np.bool)
self.arr = self.arr.astype(bool)
# del self._mask_baddata, self.mask_baddata # TODO delete property (requires deleter)
......@@ -50,7 +50,7 @@ class BadDataMask(GeoArray):
def arr(self, ndarray):
assert isinstance(ndarray, np.ndarray), "'arr' can only be set to a numpy array!"
self._validate_array_values(ndarray)
self._arr = ndarray.astype(np.bool)
self._arr = ndarray.astype(bool)
def _validate_array_values(self, maskarray):
pixelVals_in_mask = sorted(list(np.unique(maskarray)))
......@@ -71,7 +71,7 @@ class NoDataMask(GeoArray):
if self.is_inmem:
# validate input data - before converting to bool
self._validate_array_values(self.arr)
self.arr = self.arr.astype(np.bool)
self.arr = self.arr.astype(bool)
# del self._mask_nodata, self.mask_nodata # TODO delete property (requires deleter)
# TODO disk-mode: init must check the numbers of bands, and ideally also the pixel values in mask
......@@ -84,7 +84,7 @@ class NoDataMask(GeoArray):
def arr(self, ndarray):
assert isinstance(ndarray, np.ndarray), "'arr' can only be set to a numpy array!"
self._validate_array_values(ndarray)
self._arr = ndarray.astype(np.bool)
self._arr = ndarray.astype(bool)
def _validate_array_values(self, maskarray):
pixelVals_in_mask = sorted(list(np.unique(maskarray)))
......
......@@ -20,5 +20,5 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
__version__ = '0.10.5'
__versionalias__ = '20201208.01'
__version__ = '0.10.9'
__versionalias__ = '20210219.01'
cartopy
dill
folium
# folium # optional
gdal>=2.1.0
geojson
# geojson # optional
# holoviews # optional
matplotlib
numpy
......
six
dill
geojson
folium
# geojson # optional
# folium # optional
......@@ -35,12 +35,10 @@ version = {}
with open("geoarray/version.py") as version_file:
exec(version_file.read(), version)
requirements = [
req = [
'cartopy',
'dill',
'folium',
'gdal>=2.1.0',
'geojson',
'matplotlib',
'numpy',
'pandas',
......@@ -50,8 +48,22 @@ requirements = [
'shapely',
'six',
]
setup_requirements = ['setuptools-git']
test_requirements = requirements + ["coverage", "nose", "nose2", "nose-htmloutput", "rednose", "urlchecker"]
req_interactive_plotting = [
'folium',
'geojson',
'holoviews'
]
req_setup = ['setuptools-git']
req_test = req + ["coverage", "nose", "nose2", "nose-htmloutput", "rednose", "urlchecker", "parameterized"]
req_doc = ['sphinx-argparse', 'sphinx_rtd_theme']
req_lint = ['flake8', 'pycodestyle', 'pydocstyle', 'pylint']
req_dev = req_setup + req_test + req_doc + req_lint
setup(
name='geoarray',
......@@ -64,7 +76,7 @@ setup(
packages=find_packages(exclude=['tests*']), # searches for packages with an __init__.py and returns a list
package_dir={'geoarray': 'geoarray'},
include_package_data=True,
install_requires=requirements,
install_requires=req,
license="GPL-3.0-or-later",
zip_safe=False,
keywords=['geoarray', 'geoprocessing', 'gdal', 'numpy'],
......@@ -82,7 +94,13 @@ setup(
'Programming Language :: Python :: 3.9',
],
test_suite='tests',
tests_require=test_requirements,
setup_requires=setup_requirements,
extras_require={'interactive_plotting': ["holoviews"]}
tests_require=req_test,
setup_requires=req_setup,
extras_require={
"interactive_plotting": req_interactive_plotting,
"doc": req_doc,
"test": req_test,
"lint": req_lint,
"dev": req_dev
}
)
......@@ -11,7 +11,7 @@ dependencies:
- holoviews
- matplotlib
- numpy
- py_tools_ds>=0.14.35
- py-tools-ds>=0.14.35
- scikit-image
- shapely
......@@ -26,6 +26,7 @@ dependencies:
# test/docs requirements
- coverage
- flake8
- parameterized
- pycodestyle
- pydocstyle
- pylint
......
This diff is collapsed.
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