Skip to content

Commit

Permalink
Test and fix with geopandas 0.6, update Travis (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
caspervdw committed Oct 17, 2019
2 parents f11bab3 + 2ef2365 commit bb3e869
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 34 deletions.
37 changes: 10 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,23 @@ language: minimal
matrix:
include:
- os: linux
env: PYTHON_VERSION="3.5" DEPS="numpy=1.12 gdal=2.0 dask-core=0.18 toolz=0.9 pandas=0.19 shapely=1.5 geopandas=0.4.0 pytz scipy=0.19"
env: PYTHON_VERSION="3.5" MAINDEPS="numpy=1.12 gdal=2.2.4 scipy=0.19 pytz" DEPS="dask-core=0.18 toolz=0.9 pandas=0.19 geopandas=0.4.1"
- os: linux
env: PYTHON_VERSION="3.6" DEPS="numpy=1.14 gdal=2.2 dask-core=0.20 toolz=0.10 pandas=0.23 shapely=1.6 geopandas=0.4 pytz scipy=1.1"
env: PYTHON_VERSION="3.6" MAINDEPS="numpy=1.14 gdal=2.2.4 scipy=1.1 pytz" DEPS="dask-core=0.20 toolz=0.10 pandas=0.23 geopandas=0.5"
- os: linux
env: PYTHON_VERSION="3.7" DEPS="numpy gdal dask-core toolz geopandas pytz scipy"
env: PYTHON_VERSION="3.7" MAINDEPS="numpy gdal scipy pytz" DEPS="dask-core toolz geopandas"
- os: osx
env: PYTHON_VERSION="3.7" DEPS="numpy gdal dask-core toolz geopandas pytz scipy"

before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh;
fi;
env: PYTHON_VERSION="3.7" MAINDEPS="numpy gdal scipy pytz" DEPS="dask-core toolz geopandas"

install:
# install miniconda
# -b means "batch mode": automatically agree with license
# -p means "prefix": determine installation prefix
- bash miniconda.sh -b -p $HOME/miniconda
# setup the paths and reset hash
- export PATH="$HOME/miniconda:$HOME/miniconda/bin:$PATH"
- source $HOME/miniconda/etc/profile.d/conda.sh
- wget https://repo.anaconda.com/pkgs/misc/conda-execs/conda-latest-$TRAVIS_OS_NAME-64.exe -O conda.exe
- chmod +x conda.exe
- export CONDA_ALWAYS_YES=1
- ./conda.exe create --prefix $HOME/miniconda python=$PYTHON_VERSION conda pytest $MAINDEPS
- ./conda.exe install --prefix $HOME/miniconda --channel conda-forge $DEPS
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
# update and configure miniconda
- conda update --yes conda
- conda config --set changeps1 no --set restore_free_channel true
- conda config --append channels conda-forge
# create and activate the test environment
- conda create -n testenv --yes python=$PYTHON_VERSION $DEPS pytest
- conda activate testenv
- pip install . --no-deps
# print stuff for debugging
- conda --version ; python --version ; pip --version;

script:
- pytest
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ Changelog of dask-geomodeling
2.0.4 (unreleased)
------------------

- Nothing changed yet.
- Preserve functionality of the geometry.Difference block with geopandas 0.6.
When taking the difference of a geometry with a missing geometry (A - None),
geopandas < 0.6 returned A as result, while >= 0.6 returns None as result.


2.0.3 (2019-10-08)
Expand Down
20 changes: 14 additions & 6 deletions dask_geomodeling/geometry/set_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,21 @@ def process(source_data, other_data=None):
}
else:
return source_data
if len(source_data["features"]) == 0 or len(other_data["features"]) == 0:
return source_data # do nothing

features = source_data["features"].set_geometry(
source_data["features"].difference(other_data["features"])
)
return {"features": features, "projection": source_data["projection"]}
a = source_data["features"]
b = other_data["features"]
if len(a) == 0 or len(b) == 0:
return source_data # do nothing

a_series = a["geometry"]
b_series = b["geometry"].reindex(a_series.index)
result_series = a_series.difference(b_series)

# re-insert geometries that were missing in b (we want A - None = A)
missing_in_b = b_series.isna()
result_series[missing_in_b] = a_series[missing_in_b]
result = a.set_geometry(result_series)
return {"features": result, "projection": source_data["projection"]}


class Intersection(BaseSingle):
Expand Down

0 comments on commit bb3e869

Please sign in to comment.