Skip to content

Commit

Permalink
Merge pull request #91 from nens/fix-deprecation
Browse files Browse the repository at this point in the history
Solve distutils deprecation warning
  • Loading branch information
arjanverkerk committed Feb 1, 2022
2 parents 9d929c7 + cbfe20c commit 7ca47ec
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 59 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
python: 3.5
numpy: "==1.12.*"
pins: "pygdal==2.2.3.* scipy==0.19.* dask[delayed]==0.18.* pandas==0.19.* geopandas==0.4.1"
- os: ubuntu-18.04
python: 3.6
numpy: "==1.14.*"
pins: "pygdal==2.2.3.* scipy==1.1.* dask[delayed]==0.20.* pandas==0.23.* geopandas==0.5.*"
pins: "pygdal==2.2.3.* scipy==1.1.* dask[delayed]==0.20.* pandas==0.23.* geopandas==0.7.*"
- os: ubuntu-18.04
python: 3.7
numpy: "==1.16.*"
pins: "pygdal==2.2.3.* scipy==1.3.* dask[delayed]==1.* pandas==0.25.* geopandas==0.6.*"
pins: "pygdal==2.2.3.* scipy==1.3.* dask[delayed]==1.* pandas==0.25.* geopandas==0.7.*"
- os: ubuntu-20.04
python: 3.8
numpy: "==1.18.*"
Expand All @@ -35,6 +31,10 @@ jobs:
python: 3.9
numpy: "==1.20.*"
pins: "pygdal==3.0.4.* scipy==1.6.* dask[delayed]==2020.* pandas==1.1.* geopandas==0.9.*"
- os: ubuntu-20.04
python: 3.9
numpy: "==1.21.*"
pins: "pygdal==3.0.4.* scipy==1.7.* dask[delayed]==2021.* pandas==1.3.* geopandas==0.10.*"
- os: ubuntu-20.04
python: 3.9
display_name: "latest"
Expand Down
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Changelog of dask-geomodeling
2.3.5 (unreleased)
------------------

- Nothing changed yet.
- Drop python 3.5 support and move on other version requirements.

- Fix deprecation warning with distutils.


2.3.4 (2021-02-08)
Expand Down
15 changes: 4 additions & 11 deletions dask_geomodeling/tests/test_geometry_sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@
from pandas.util.testing import assert_frame_equal


def compare_crs(actual, expected):
if utils.GEOPANDAS_GTE_0_7_0:
assert actual == expected
else:
assert actual["init"] == expected["init"]


def assert_frame_equal_ignore_index(actual, expected, sort_col):
assert_frame_equal(
actual.set_index(sort_col).sort_index(),
Expand Down Expand Up @@ -121,7 +114,7 @@ def test_geojson(self):
# compare dataframes without checking the order of records / columns
assert_frame_equal_ignore_index(actual, expected, "int")
# compare projections
compare_crs(actual.crs, expected.crs)
assert actual.crs == expected.crs

@pytest.mark.skipif(
"gpkg" not in sinks.GeometryFileSink.supported_extensions,
Expand All @@ -137,7 +130,7 @@ def test_geopackage(self):
# compare dataframes without checking the order of records / columns
assert_frame_equal_ignore_index(actual, self.expected, "int")
# compare projections
compare_crs(actual.crs, self.expected.crs)
assert actual.crs == self.expected.crs

def test_shapefile(self):
block = self.klass(self.source, self.path, "shp")
Expand All @@ -149,7 +142,7 @@ def test_shapefile(self):
# compare dataframes without checking the order of records / columns
assert_frame_equal_ignore_index(actual, self.expected, "int")
# compare projections
compare_crs(actual.crs, self.expected.crs)
assert actual.crs == self.expected.crs

@pytest.mark.skipif(
"gml" not in sinks.GeometryFileSink.supported_extensions,
Expand Down Expand Up @@ -199,7 +192,7 @@ def test_merge_files(self):
# compare dataframes without checking the order of records / columns
assert_frame_equal_ignore_index(actual, expected, "int")
# compare projections
compare_crs(actual.crs, expected.crs)
assert actual.crs == expected.crs

def test_merge_files_cleanup(self):
block = self.klass(self.source, self.path, "geojson")
Expand Down
12 changes: 3 additions & 9 deletions dask_geomodeling/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import numpy as np
import pandas as pd
import geopandas as gpd
from pyproj import CRS

from dask_geomodeling import utils

Expand Down Expand Up @@ -171,17 +172,10 @@ def test_safe_file_url(self):
f("..\\", "C:\\tmp")

def test_get_crs(self):
if utils.GEOPANDAS_GTE_0_7_0:
from pyproj import CRS

expected_type = CRS
else:
expected_type = dict

# from EPSG
epsg = "EPSG:28992"
crs = utils.get_crs(epsg)
self.assertIsInstance(crs, expected_type)
self.assertIsInstance(crs, CRS)

# from proj4
proj4 = """
Expand All @@ -191,7 +185,7 @@ def test_get_crs(self):
+units=m +no_defs
"""
crs = utils.get_crs(proj4)
self.assertIsInstance(crs, expected_type)
self.assertIsInstance(crs, CRS)

def test_shapely_transform(self):
src_srs = "EPSG:28992"
Expand Down
29 changes: 3 additions & 26 deletions dask_geomodeling/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pytz
import os
import warnings
from distutils.version import LooseVersion
from functools import lru_cache
from itertools import repeat

Expand All @@ -17,11 +16,10 @@
from osgeo import gdal, ogr, osr, gdal_array
from shapely.geometry import box, Point
from shapely import wkb as shapely_wkb
from pyproj import CRS

import fiona
import fiona.crs
import geopandas


POLYGON = "POLYGON (({0} {1},{2} {1},{2} {3},{0} {3},{0} {1}))"

Expand All @@ -30,14 +28,6 @@
except ImportError:
from fiona import drivers as fiona_env # NOQA

try:
GEOPANDAS_GTE_0_7_0 = LooseVersion(geopandas.__version__) >= LooseVersion("0.7.0")
except AttributeError: # for doctests geopandas is mocked
GEOPANDAS_GTE_0_7_0 = True

if GEOPANDAS_GTE_0_7_0:
from pyproj import CRS


GDAL3 = gdal.VersionInfo().startswith("3")

Expand Down Expand Up @@ -374,22 +364,9 @@ def get_crs(user_input):
user_input (str): a WKT, PROJ4, or EPSG:xxxx crs representation
Returns:
for geopandas >= 0.7: pyproj.CRS
for geopandas < 0.7: dict
pyproj.CRS
"""
if GEOPANDAS_GTE_0_7_0:
return CRS(user_input)
wkt = osr.GetUserInputAsWKT(str(user_input))
sr = osr.SpatialReference(wkt)
key = str("GEOGCS") if sr.IsGeographic() else str("PROJCS")
name = sr.GetAuthorityName(key)
if name == "EPSG":
# we can specify CRS in EPSG code which is more compatible with output
# file types
return fiona.crs.from_epsg(int(sr.GetAuthorityCode(key)))
else:
# we have to go through Proj4
return fiona.crs.from_string(sr.ExportToProj4())
return CRS(user_input)


def crs_to_srs(crs):
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ filterwarnings =
error:::scipy[.*]
error:::pandas[.*]
error:::dask[.*]
ignore:distutils Version classes are deprecated. Use packaging.version instead.::

[flake8]
ignore = E203, E266, E501, W503
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

install_requires = (
[
"dask[delayed]>=0.18",
"pandas>=0.19",
"geopandas>=0.4",
"dask[delayed]>=0.20",
"pandas>=0.23",
"geopandas>=0.7",
"pytz",
"numpy>=1.12",
"scipy>=0.19",
"numpy>=1.14",
"scipy>=1.1",
],
)

Expand Down Expand Up @@ -52,7 +52,7 @@
zip_safe=False,
install_requires=install_requires,
tests_require=tests_require,
python_requires='>=3.5',
python_requires='>=3.6',
extras_require={"test": tests_require, "cityhash": ["cityhash"]},
entry_points={"console_scripts": []},
)

0 comments on commit 7ca47ec

Please sign in to comment.