From ac77f8fd45e520f7d7ca6f824354890bd63f2841 Mon Sep 17 00:00:00 2001 From: Chris Barker Date: Fri, 11 Jan 2019 22:13:42 -0800 Subject: [PATCH 1/3] moved tests to be inside package. This is so they can be run from an install, and won't be installed as a separate pacakge called "tests" Also added a standard .gitignore file for Python. --- .gitignore | 117 ++++++++++++++++++ {tests => hrds/tests}/__init__.py | 0 {tests => hrds/tests}/base.tif | Bin {tests => hrds/tests}/layer1.tif | Bin {tests => hrds/tests}/layer2.tif | Bin .../tests}/real_data/boundaries.dbf | Bin .../tests}/real_data/boundaries.prj | 0 .../tests}/real_data/boundaries.qpj | 0 .../tests}/real_data/boundaries.shp | Bin .../tests}/real_data/boundaries.shx | Bin .../tests}/real_data/create_bathy.py | 0 {tests => hrds/tests}/real_data/distance.fld | 0 {tests => hrds/tests}/real_data/emod_utm.tif | Bin {tests => hrds/tests}/real_data/gebco_uk.tif | Bin .../tests}/real_data/high_res_area.dbf | Bin .../tests}/real_data/high_res_area.prj | 0 .../tests}/real_data/high_res_area.qpj | 0 .../tests}/real_data/high_res_area.shp | Bin .../tests}/real_data/high_res_area.shx | Bin .../tests}/real_data/inspire_data.tif | Bin {tests => hrds/tests}/real_data/real_data.qgs | 0 .../tests}/real_data/sample_points.cpg | 0 .../tests}/real_data/sample_points.dbf | Bin .../tests}/real_data/sample_points.prj | 0 .../tests}/real_data/sample_points.qpj | 0 .../tests}/real_data/sample_points.shp | Bin .../tests}/real_data/sample_points.shx | Bin {tests => hrds/tests}/real_data/style.qml | 0 {tests => hrds/tests}/real_data/test_mesh.csv | 0 {tests => hrds/tests}/real_data/test_mesh.geo | 0 {tests => hrds/tests}/real_data/test_mesh.msh | 0 .../tests}/real_data/xyz_example.py | 0 {tests => hrds/tests}/test_buffer.py | 0 {tests => hrds/tests}/test_hrds.py | 0 {tests => hrds/tests}/test_interpolation.py | 0 {tests => hrds/tests}/test_raster.asc | 0 {tests => hrds/tests}/test_raster_large.tif | Bin .../tests}/test_raster_nodata_centre.tif | Bin 38 files changed, 117 insertions(+) create mode 100644 .gitignore rename {tests => hrds/tests}/__init__.py (100%) rename {tests => hrds/tests}/base.tif (100%) rename {tests => hrds/tests}/layer1.tif (100%) rename {tests => hrds/tests}/layer2.tif (100%) rename {tests => hrds/tests}/real_data/boundaries.dbf (100%) rename {tests => hrds/tests}/real_data/boundaries.prj (100%) rename {tests => hrds/tests}/real_data/boundaries.qpj (100%) rename {tests => hrds/tests}/real_data/boundaries.shp (100%) rename {tests => hrds/tests}/real_data/boundaries.shx (100%) rename {tests => hrds/tests}/real_data/create_bathy.py (100%) rename {tests => hrds/tests}/real_data/distance.fld (100%) rename {tests => hrds/tests}/real_data/emod_utm.tif (100%) rename {tests => hrds/tests}/real_data/gebco_uk.tif (100%) rename {tests => hrds/tests}/real_data/high_res_area.dbf (100%) rename {tests => hrds/tests}/real_data/high_res_area.prj (100%) rename {tests => hrds/tests}/real_data/high_res_area.qpj (100%) rename {tests => hrds/tests}/real_data/high_res_area.shp (100%) rename {tests => hrds/tests}/real_data/high_res_area.shx (100%) rename {tests => hrds/tests}/real_data/inspire_data.tif (100%) rename {tests => hrds/tests}/real_data/real_data.qgs (100%) rename {tests => hrds/tests}/real_data/sample_points.cpg (100%) rename {tests => hrds/tests}/real_data/sample_points.dbf (100%) rename {tests => hrds/tests}/real_data/sample_points.prj (100%) rename {tests => hrds/tests}/real_data/sample_points.qpj (100%) rename {tests => hrds/tests}/real_data/sample_points.shp (100%) rename {tests => hrds/tests}/real_data/sample_points.shx (100%) rename {tests => hrds/tests}/real_data/style.qml (100%) rename {tests => hrds/tests}/real_data/test_mesh.csv (100%) rename {tests => hrds/tests}/real_data/test_mesh.geo (100%) rename {tests => hrds/tests}/real_data/test_mesh.msh (100%) rename {tests => hrds/tests}/real_data/xyz_example.py (100%) rename {tests => hrds/tests}/test_buffer.py (100%) rename {tests => hrds/tests}/test_hrds.py (100%) rename {tests => hrds/tests}/test_interpolation.py (100%) rename {tests => hrds/tests}/test_raster.asc (100%) rename {tests => hrds/tests}/test_raster_large.tif (100%) rename {tests => hrds/tests}/test_raster_nodata_centre.tif (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cc2abf4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,117 @@ +#.gitignore for Python, from gitHub + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ diff --git a/tests/__init__.py b/hrds/tests/__init__.py similarity index 100% rename from tests/__init__.py rename to hrds/tests/__init__.py diff --git a/tests/base.tif b/hrds/tests/base.tif similarity index 100% rename from tests/base.tif rename to hrds/tests/base.tif diff --git a/tests/layer1.tif b/hrds/tests/layer1.tif similarity index 100% rename from tests/layer1.tif rename to hrds/tests/layer1.tif diff --git a/tests/layer2.tif b/hrds/tests/layer2.tif similarity index 100% rename from tests/layer2.tif rename to hrds/tests/layer2.tif diff --git a/tests/real_data/boundaries.dbf b/hrds/tests/real_data/boundaries.dbf similarity index 100% rename from tests/real_data/boundaries.dbf rename to hrds/tests/real_data/boundaries.dbf diff --git a/tests/real_data/boundaries.prj b/hrds/tests/real_data/boundaries.prj similarity index 100% rename from tests/real_data/boundaries.prj rename to hrds/tests/real_data/boundaries.prj diff --git a/tests/real_data/boundaries.qpj b/hrds/tests/real_data/boundaries.qpj similarity index 100% rename from tests/real_data/boundaries.qpj rename to hrds/tests/real_data/boundaries.qpj diff --git a/tests/real_data/boundaries.shp b/hrds/tests/real_data/boundaries.shp similarity index 100% rename from tests/real_data/boundaries.shp rename to hrds/tests/real_data/boundaries.shp diff --git a/tests/real_data/boundaries.shx b/hrds/tests/real_data/boundaries.shx similarity index 100% rename from tests/real_data/boundaries.shx rename to hrds/tests/real_data/boundaries.shx diff --git a/tests/real_data/create_bathy.py b/hrds/tests/real_data/create_bathy.py similarity index 100% rename from tests/real_data/create_bathy.py rename to hrds/tests/real_data/create_bathy.py diff --git a/tests/real_data/distance.fld b/hrds/tests/real_data/distance.fld similarity index 100% rename from tests/real_data/distance.fld rename to hrds/tests/real_data/distance.fld diff --git a/tests/real_data/emod_utm.tif b/hrds/tests/real_data/emod_utm.tif similarity index 100% rename from tests/real_data/emod_utm.tif rename to hrds/tests/real_data/emod_utm.tif diff --git a/tests/real_data/gebco_uk.tif b/hrds/tests/real_data/gebco_uk.tif similarity index 100% rename from tests/real_data/gebco_uk.tif rename to hrds/tests/real_data/gebco_uk.tif diff --git a/tests/real_data/high_res_area.dbf b/hrds/tests/real_data/high_res_area.dbf similarity index 100% rename from tests/real_data/high_res_area.dbf rename to hrds/tests/real_data/high_res_area.dbf diff --git a/tests/real_data/high_res_area.prj b/hrds/tests/real_data/high_res_area.prj similarity index 100% rename from tests/real_data/high_res_area.prj rename to hrds/tests/real_data/high_res_area.prj diff --git a/tests/real_data/high_res_area.qpj b/hrds/tests/real_data/high_res_area.qpj similarity index 100% rename from tests/real_data/high_res_area.qpj rename to hrds/tests/real_data/high_res_area.qpj diff --git a/tests/real_data/high_res_area.shp b/hrds/tests/real_data/high_res_area.shp similarity index 100% rename from tests/real_data/high_res_area.shp rename to hrds/tests/real_data/high_res_area.shp diff --git a/tests/real_data/high_res_area.shx b/hrds/tests/real_data/high_res_area.shx similarity index 100% rename from tests/real_data/high_res_area.shx rename to hrds/tests/real_data/high_res_area.shx diff --git a/tests/real_data/inspire_data.tif b/hrds/tests/real_data/inspire_data.tif similarity index 100% rename from tests/real_data/inspire_data.tif rename to hrds/tests/real_data/inspire_data.tif diff --git a/tests/real_data/real_data.qgs b/hrds/tests/real_data/real_data.qgs similarity index 100% rename from tests/real_data/real_data.qgs rename to hrds/tests/real_data/real_data.qgs diff --git a/tests/real_data/sample_points.cpg b/hrds/tests/real_data/sample_points.cpg similarity index 100% rename from tests/real_data/sample_points.cpg rename to hrds/tests/real_data/sample_points.cpg diff --git a/tests/real_data/sample_points.dbf b/hrds/tests/real_data/sample_points.dbf similarity index 100% rename from tests/real_data/sample_points.dbf rename to hrds/tests/real_data/sample_points.dbf diff --git a/tests/real_data/sample_points.prj b/hrds/tests/real_data/sample_points.prj similarity index 100% rename from tests/real_data/sample_points.prj rename to hrds/tests/real_data/sample_points.prj diff --git a/tests/real_data/sample_points.qpj b/hrds/tests/real_data/sample_points.qpj similarity index 100% rename from tests/real_data/sample_points.qpj rename to hrds/tests/real_data/sample_points.qpj diff --git a/tests/real_data/sample_points.shp b/hrds/tests/real_data/sample_points.shp similarity index 100% rename from tests/real_data/sample_points.shp rename to hrds/tests/real_data/sample_points.shp diff --git a/tests/real_data/sample_points.shx b/hrds/tests/real_data/sample_points.shx similarity index 100% rename from tests/real_data/sample_points.shx rename to hrds/tests/real_data/sample_points.shx diff --git a/tests/real_data/style.qml b/hrds/tests/real_data/style.qml similarity index 100% rename from tests/real_data/style.qml rename to hrds/tests/real_data/style.qml diff --git a/tests/real_data/test_mesh.csv b/hrds/tests/real_data/test_mesh.csv similarity index 100% rename from tests/real_data/test_mesh.csv rename to hrds/tests/real_data/test_mesh.csv diff --git a/tests/real_data/test_mesh.geo b/hrds/tests/real_data/test_mesh.geo similarity index 100% rename from tests/real_data/test_mesh.geo rename to hrds/tests/real_data/test_mesh.geo diff --git a/tests/real_data/test_mesh.msh b/hrds/tests/real_data/test_mesh.msh similarity index 100% rename from tests/real_data/test_mesh.msh rename to hrds/tests/real_data/test_mesh.msh diff --git a/tests/real_data/xyz_example.py b/hrds/tests/real_data/xyz_example.py similarity index 100% rename from tests/real_data/xyz_example.py rename to hrds/tests/real_data/xyz_example.py diff --git a/tests/test_buffer.py b/hrds/tests/test_buffer.py similarity index 100% rename from tests/test_buffer.py rename to hrds/tests/test_buffer.py diff --git a/tests/test_hrds.py b/hrds/tests/test_hrds.py similarity index 100% rename from tests/test_hrds.py rename to hrds/tests/test_hrds.py diff --git a/tests/test_interpolation.py b/hrds/tests/test_interpolation.py similarity index 100% rename from tests/test_interpolation.py rename to hrds/tests/test_interpolation.py diff --git a/tests/test_raster.asc b/hrds/tests/test_raster.asc similarity index 100% rename from tests/test_raster.asc rename to hrds/tests/test_raster.asc diff --git a/tests/test_raster_large.tif b/hrds/tests/test_raster_large.tif similarity index 100% rename from tests/test_raster_large.tif rename to hrds/tests/test_raster_large.tif diff --git a/tests/test_raster_nodata_centre.tif b/hrds/tests/test_raster_nodata_centre.tif similarity index 100% rename from tests/test_raster_nodata_centre.tif rename to hrds/tests/test_raster_nodata_centre.tif From 25865fcd94990f33b79549f86a5d57b6a5c77dce Mon Sep 17 00:00:00 2001 From: Chris Barker Date: Fri, 11 Jan 2019 22:41:19 -0800 Subject: [PATCH 2/3] cleaned up some formatting in the setup.py, including putting the version in the package __init__.py . --- hrds/__init__.py | 2 ++ setup.py | 54 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/hrds/__init__.py b/hrds/__init__.py index 7be55c8..bde9b4f 100644 --- a/hrds/__init__.py +++ b/hrds/__init__.py @@ -24,6 +24,8 @@ """ +__version__ = "0.1.0" + from .raster import RasterInterpolator # NOQA from .raster_buffer import CreateBuffer # NOQA from .hrds import HRDS # NOQA diff --git a/setup.py b/setup.py index 8b36841..c8904bd 100644 --- a/setup.py +++ b/setup.py @@ -1,20 +1,40 @@ import setuptools +DESCRIPTION = """ +hrds is a python package for obtaining points from a set of raster at +different resolutions. You can request a point (or list of points) and +hrds will return a value based on the highest resolution dataset (as +defined by the user) available at that point, blending datasets in a +buffer region to ensure consistancy. +""" + + +def get_version(): + """ + kludgy, but lets you set version in one place, and have it in the + package + """ + with open("hrds/__init__.py") as initfile: + for line in initfile: + parts = line.strip().split("=") + if parts[0].strip() == "__version__": + version = parts[1].strip().strip("'").strip('"') + return version + raise ValueError("no __version__ defined in package __init__") + + setuptools.setup(name='hrds', - version='0.1', - author='Jon Hill', - author_email='jon.hill@york.ac.uk', - description="hrds is a python package for obtaining points from a set of raster at different resolutions."+ - "You can request a point (or list of points) and hrds will return a value based on"+ - "the highest resolution dataset (as defined by the user) available at that point, blending"+ - "datasets in a buffer region to ensure consistancy.", - url='https://github.com/stephankramer/uptide', - packages = setuptools.find_packages(), - keywords = ['raster', 'gis', 'modelling'], - classifiers = [ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)', - 'Programming Language :: Python :: 2.7', - 'Topic :: Scientific/Engineering'], - ) + version=get_version(), + author='Jon Hill', + author_email='jon.hill@york.ac.uk', + description=DESCRIPTION, + url='https://github.com/stephankramer/uptide', + packages=setuptools.find_packages(), + keywords=['raster', 'gis', 'modelling'], + classifiers=[ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)', + 'Programming Language :: Python :: 2.7', + 'Topic :: Scientific/Engineering'], + ) From e156ef1f750566601855fa2e36534e4aca39586b Mon Sep 17 00:00:00 2001 From: "Christopher H.Barker, PhD" Date: Fri, 11 Jan 2019 23:08:27 -0800 Subject: [PATCH 3/3] use pytest to run tests inside installed package --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2f58de1..6931624 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,6 @@ install: - "pip install -r requirements.txt" - python setup.py install script: - - make test + - pytest --pyargs hrds #after_success: # - coveralls #--config_file .coveragerc