Skip to content

Commit

Permalink
Drop python 3.5 support (#13)
Browse files Browse the repository at this point in the history
* update geocube to support python 3.6+
  • Loading branch information
snowman2 committed Dec 12, 2019
1 parent c7897aa commit efcae58
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 31 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ clean-test: ## remove test and coverage artifacts

lint: ## check style with flake8
flake8 geocube test --max-line-length 88
black --check .
black --target-version py36 --check .

check:
###### FLAKE8 #####
# No unused imports, no undefined vars,
flake8 --ignore=E731,W503,W504 --exclude --max-complexity 10 --max-line-length 88 geocube/
flake8 --max-line-length 88 tests/unit/ tests/functional/ tests/integration
black --check .
black --target-version py36 --check .

pylint:
###### PYLINT ######
Expand Down
2 changes: 1 addition & 1 deletion geocube/cli/geocube.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def check_version(ctx, _, value):
if not value or ctx.resilient_parsing:
return

click.echo("geocube v{}".format(__version__))
click.echo(f"geocube v{__version__}")

ctx.exit()

Expand Down
5 changes: 2 additions & 3 deletions geocube/geo_utils/geobox.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ def load_vector_data(vector_data):
raise VectorDataError("Empty GeoDataFrame.")
if "geometry" not in vector_data.columns:
raise VectorDataError(
"'geometry' column missing. Columns in file: {}".format(
vector_data.columns.values.tolist()
)
"'geometry' column missing. Columns in file: "
f"{vector_data.columns.values.tolist()}"
)

# make sure projection is set
Expand Down
10 changes: 5 additions & 5 deletions geocube/rasterize.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def rasterize_image(
fill,
merge_alg=MergeAlg.replace,
filter_nan=False,
**ignored_kwargs
**ignored_kwargs,
):
"""
Rasterize a list of shapes+values for a given GeoBox.
Expand Down Expand Up @@ -82,7 +82,7 @@ def rasterize_image(
return image
except TypeError as ter:
if "cannot perform reduce with flexible type" in str(ter):
logger.warning("{warning}".format(warning=ter))
logger.warning(f"{ter}")
return None
raise

Expand All @@ -95,7 +95,7 @@ def rasterize_points_griddata(
method="nearest",
rescale=False,
filter_nan=False,
**ignored_kwargs
**ignored_kwargs,
):
"""
This method uses scipy.interpolate.griddata to interpolate point data
Expand Down Expand Up @@ -154,7 +154,7 @@ def rasterize_points_radial(
grid_coords,
method="linear",
filter_nan=False,
**ignored_kwargs
**ignored_kwargs,
):
"""
This method uses scipy.interpolate.Rbf to interpolate point data
Expand Down Expand Up @@ -195,6 +195,6 @@ def rasterize_points_radial(
return interp(*numpy.meshgrid(grid_coords["x"], grid_coords["y"]))
except ValueError as ter:
if "object arrays are not supported" in str(ter):
logger.warning("{warning}".format(warning=ter))
logger.warning(f"{ter}")
return None
raise
14 changes: 5 additions & 9 deletions geocube/vector_to_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def _format_series_data(data_series):
if "datetime" in str(data_series.dtype):
data_series = pandas.to_numeric(data_series).astype(numpy.float64)
get_logger().warning(
"The series '{}' was converted from a date to a number to "
f"The series '{data_series.name}' was converted from a date to a number to "
"rasterize the data. To load the data back in as a date, "
"use 'pandas.to_datetime()'.".format(data_series.name)
"use 'pandas.to_datetime()'."
)
elif str(data_series.dtype) == "category":
data_series = data_series.cat.codes
Expand Down Expand Up @@ -246,7 +246,7 @@ def _get_dataset(self, vector_data, measurements, group_by, interpolate_na_metho
out_xds = xarray.Dataset(data_vars=data_vars, coords=self.grid_coords)

for categorical_measurement, categoral_enums in self._categorical_enums.items():
enum_var_name = "{}_categories".format(categorical_measurement)
enum_var_name = f"{categorical_measurement}_categories"
cat_attrs = dict(out_xds[categorical_measurement].attrs)
cat_attrs["categorical_mapping"] = enum_var_name
out_xds[categorical_measurement].attrs = cat_attrs
Expand Down Expand Up @@ -299,9 +299,7 @@ def _get_grouped_grid(self, grouped_dataframe, measurement_name, group_by):
)
if image is None:
logger.warning(
"Skipping attribute {col} due to missing data...".format(
col=measurement_name
)
f"Skipping attribute {measurement_name} due to missing data..."
)
return None

Expand Down Expand Up @@ -346,9 +344,7 @@ def _get_grid(self, dataframe, measurement_name):
)
if image_data is None:
logger.warning(
"Skipping attribute {col} due to missing data...".format(
col=measurement_name
)
f"Skipping attribute {measurement_name} due to missing data..."
)
return None

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
description="Tool to convert geopandas vector data into rasterized xarray data.",
entry_points={"console_scripts": ["geocube=geocube.cli.geocube:geocube"]},
Expand All @@ -64,5 +64,5 @@
url="https://github.com/corteva/geocube",
version=__version__,
zip_safe=False,
python_requires=">=3",
python_requires=">=3.6",
)
14 changes: 7 additions & 7 deletions sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
master_doc = "index"

# General information about the project.
project = u"geocube"
copyright = u"2019, Geocube Contributors"
author = u"Geocube Contributors"
project = "geocube"
copyright = "2019, Geocube Contributors"
author = "Geocube Contributors"

# The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout
Expand Down Expand Up @@ -136,8 +136,8 @@
(
master_doc,
"geocube.tex",
u"geocube Documentation",
u"Geocube Contributors",
"geocube Documentation",
"Geocube Contributors",
"manual",
)
]
Expand All @@ -147,7 +147,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "geocube", u"geocube Documentation", [author], 1)]
man_pages = [(master_doc, "geocube", "geocube Documentation", [author], 1)]


# -- Options for Texinfo output ----------------------------------------
Expand All @@ -159,7 +159,7 @@
(
master_doc,
"geocube",
u"geocube Documentation",
"geocube Documentation",
author,
"geocube",
"One line description of project.",
Expand Down
4 changes: 4 additions & 0 deletions sphinx/history.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
History
=======

0.0.11
------
- Drop Python 3.5 Support (issue #12)

0.0.10
------
- Added filter_nan kwarg to filter out missing data when rasterizing (issue #9)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/api/test_core_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def test_make_geocube__like_error_invalid_args(load_extra_kwargs):
measurements=soil_attribute_list,
like=xdc,
fill=-9999.0,
**load_extra_kwargs
**load_extra_kwargs,
)


Expand Down Expand Up @@ -618,7 +618,7 @@ def test_make_geocube__group_by_like_error_invalid_args(load_extra_kwargs):
like=xdc,
group_by="hzdept_r",
fill=-9999.0,
**load_extra_kwargs
**load_extra_kwargs,
)


Expand Down

0 comments on commit efcae58

Please sign in to comment.