From 9a12cc766bc6d8c02cde744204c13282d4323ac4 Mon Sep 17 00:00:00 2001 From: Matthew Perry Date: Thu, 22 Feb 2018 11:10:16 +0530 Subject: [PATCH 1/5] workaround for numpy on win 64bit, resolves #129 --- src/rasterstats/main.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/rasterstats/main.py b/src/rasterstats/main.py index 540ed20..57dd1d4 100644 --- a/src/rasterstats/main.py +++ b/src/rasterstats/main.py @@ -1,10 +1,13 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division -import numpy as np -import warnings + from affine import Affine from shapely.geometry import shape +import numpy as np +import numpy.distutils.system_info as sysinfo +import warnings + from .io import read_features, Raster from .utils import (rasterize_geom, get_percentile, check_stats, remap_categories, key_assoc_val, boxify_points) @@ -169,6 +172,14 @@ def gen_zonal_stats( fsrc.array, mask=(isnodata | ~rv_array)) + # If we're on 64 bit platform and the array is an integer type + # make sure we cast to 64 bit to avoid overflow. + # workaround for https://github.com/numpy/numpy/issues/8433 + if sysinfo.platform_bits == 64 and \ + masked.dtype != np.int64 and \ + issubclass(masked.dtype.type, np.integer): + masked = masked.astype(np.int64) + # execute zone_func on masked zone ndarray if zone_func is not None: if not callable(zone_func): From aa1a3912d3d62f3b3f09d648b545449f0bc4b0ea Mon Sep 17 00:00:00 2001 From: Matthew Perry Date: Thu, 22 Feb 2018 11:10:51 +0530 Subject: [PATCH 2/5] pep8 --- src/rasterstats/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rasterstats/main.py b/src/rasterstats/main.py index 57dd1d4..710d8f6 100644 --- a/src/rasterstats/main.py +++ b/src/rasterstats/main.py @@ -161,7 +161,8 @@ def gen_zonal_stats( isnodata = (fsrc.array == fsrc.nodata) # add nan mask (if necessary) - has_nan = (np.issubdtype(fsrc.array.dtype, float) + has_nan = ( + np.issubdtype(fsrc.array.dtype, float) and np.isnan(fsrc.array.min())) if has_nan: isnodata = (isnodata | np.isnan(fsrc.array)) @@ -199,7 +200,6 @@ def gen_zonal_stats( pixel_count = dict(zip([np.asscalar(k) for k in keys], [np.asscalar(c) for c in counts])) - if categorical: feature_stats = dict(pixel_count) if category_map: From 0bdb4da99d329aec6e221caf972807ec2339378a Mon Sep 17 00:00:00 2001 From: Matthew Perry Date: Thu, 22 Feb 2018 11:14:00 +0530 Subject: [PATCH 3/5] use rasterio 1 for CI testing b/c wheels --- .travis.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6f2d1fd..ed59b5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,12 +7,6 @@ env: global: - PIP_WHEEL_DIR=$HOME/.cache/pip/wheels - PIP_FIND_LINKS=file://$HOME/.cache/pip/wheels -addons: - apt: - packages: - - libgdal1h - - gdal-bin - - libgdal-dev python: - 2.7 - 3.4 @@ -22,7 +16,7 @@ before_install: - pip install -U pip setuptools --upgrade - pip install wheel install: - - pip install numpy>=1.9 Cython + - pip install numpy "rasterio>=1.12a" - pip install -r requirements_dev.txt - pip install coveralls - pip install -e . From f7fd296ed711d94063a66d151299515a85e4016f Mon Sep 17 00:00:00 2001 From: Matthew Perry Date: Thu, 22 Feb 2018 11:17:31 +0530 Subject: [PATCH 4/5] versions --- .travis.yml | 2 +- src/rasterstats/_version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ed59b5d..a6f7f72 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ before_install: - pip install -U pip setuptools --upgrade - pip install wheel install: - - pip install numpy "rasterio>=1.12a" + - pip install numpy "rasterio>=1.0a12" - pip install -r requirements_dev.txt - pip install coveralls - pip install -e . diff --git a/src/rasterstats/_version.py b/src/rasterstats/_version.py index ea370a8..def467e 100644 --- a/src/rasterstats/_version.py +++ b/src/rasterstats/_version.py @@ -1 +1 @@ -__version__ = "0.12.0" +__version__ = "0.12.1" From cb3e6d5ff6ad6418b6d95bcb4d285d9fe689d48f Mon Sep 17 00:00:00 2001 From: Matthew Perry Date: Thu, 22 Feb 2018 11:19:30 +0530 Subject: [PATCH 5/5] we support python 3.6 officially, resolves #149 --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index a87a1b1..223e61e 100644 --- a/setup.py +++ b/setup.py @@ -58,6 +58,7 @@ def run_tests(self): 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', "Topic :: Utilities", 'Topic :: Scientific/Engineering :: GIS', ],