diff --git a/examples/duplicate_points.png b/examples/duplicate_points.png index 5f41ea5..aa33d88 100644 Binary files a/examples/duplicate_points.png and b/examples/duplicate_points.png differ diff --git a/examples/duplicate_points.py b/examples/duplicate_points.py index 682398f..5300a72 100644 --- a/examples/duplicate_points.py +++ b/examples/duplicate_points.py @@ -99,7 +99,7 @@ distinct_pt_coords = coords[np.asarray(list(count_per_pt.keys()))] # highlight voronoi regions with point duplicates -vor_colors = {i_poly: 'red' if len(pt_indices) > 1 else 'blue' +vor_colors = {i_poly: (1,0,0) if len(pt_indices) > 1 else (0,0,1) for i_poly, pt_indices in poly_to_pt_assignments.items()} fig, ax = subplot_for_map() @@ -108,7 +108,7 @@ plot_voronoi_opts={'alpha': 0.2}, plot_points_opts={'alpha': 0.4}, voronoi_color=vor_colors, - voronoi_edgecolor='black', + voronoi_edgecolor=(0,0,0,1), point_labels=pt_labels, points_markersize=np.square(np.array(list(count_per_pt.values())))*10) diff --git a/examples/random_points_across_italy.png b/examples/random_points_across_italy.png index 152cca6..23bff23 100644 Binary files a/examples/random_points_across_italy.png and b/examples/random_points_across_italy.png differ diff --git a/examples/random_points_across_italy.py b/examples/random_points_across_italy.py index 682078c..5a9ac0d 100644 --- a/examples/random_points_across_italy.py +++ b/examples/random_points_across_italy.py @@ -17,6 +17,17 @@ from geovoronoi import coords_to_points, voronoi_regions_from_coords from geovoronoi.plotting import subplot_for_map, plot_voronoi_polys_with_points_in_area +import traceback +import warnings +import sys + +def warn_with_traceback(message, category, filename, lineno, file=None, line=None): + + log = file if hasattr(file,'write') else sys.stderr + traceback.print_stack(file=log) + log.write(warnings.formatwarning(message, category, filename, lineno, line)) + +warnings.showwarning = warn_with_traceback logging.basicConfig(level=logging.INFO) geovoronoi_log = logging.getLogger('geovoronoi') diff --git a/examples/random_points_and_area.png b/examples/random_points_and_area.png index b9d0997..aebff9d 100644 Binary files a/examples/random_points_and_area.png and b/examples/random_points_and_area.png differ diff --git a/examples/using_geopandas.png b/examples/using_geopandas.png index ccba835..706a36f 100644 Binary files a/examples/using_geopandas.png and b/examples/using_geopandas.png differ diff --git a/geovoronoi/__init__.py b/geovoronoi/__init__.py index aac7203..8f3adf4 100644 --- a/geovoronoi/__init__.py +++ b/geovoronoi/__init__.py @@ -14,6 +14,6 @@ __title__ = 'geovoronoi' -__version__ = '0.2.0' +__version__ = '0.3.0dev' __author__ = 'Markus Konrad' __license__ = 'Apache License 2.0' diff --git a/geovoronoi/plotting.py b/geovoronoi/plotting.py index 7cc26dd..6997164 100644 --- a/geovoronoi/plotting.py +++ b/geovoronoi/plotting.py @@ -59,7 +59,7 @@ def colors_for_voronoi_polys_and_points(poly_shapes, poly_to_pt_assignments, poi pt_to_poly = sorted(pt_to_poly.items(), key=lambda x: x[0]) - pt_colors = ['black' if i_vor is None else vor_colors[i_vor] for _, i_vor in pt_to_poly] + pt_colors = [(0,0,0,1) if i_vor is None else vor_colors[i_vor] for _, i_vor in pt_to_poly] assert len(vor_colors) <= len(pt_colors) @@ -154,7 +154,7 @@ def plot_polygon(ax, polygon, facecolor=None, edgecolor=None, linewidth=1, lines def plot_voronoi_polys_with_points_in_area(ax, area_shape, poly_shapes, points, poly_to_pt_assignments=None, - area_color='white', area_edgecolor='black', + area_color=(1,1,1,1), area_edgecolor=(0,0,0,1), voronoi_and_points_cmap='tab20', voronoi_color=None, voronoi_edgecolor=None, points_color=None, points_markersize=5, points_marker='o', @@ -185,7 +185,7 @@ def plot_voronoi_polys_with_points_in_area(ax, area_shape, poly_shapes, points, cmap_name=voronoi_and_points_cmap) if voronoi_color is None and voronoi_edgecolor is None: - voronoi_edgecolor = 'black' # better visible default value + voronoi_edgecolor = (0,0,0,1) # better visible default value plot_voronoi_polys(ax, poly_shapes, color=voronoi_color, edgecolor=voronoi_edgecolor, labels=voronoi_labels, label_fontsize=voronoi_label_fontsize, label_color=voronoi_label_color, @@ -206,7 +206,7 @@ def _color_for_labels(label_color, default_color, seq_index): else: c = label_color - return c or 'black' + return c or (0,0,0,1) def _plot_polygon_collection_with_color(ax, geoms, color=None, **kwargs): diff --git a/requirements.txt b/requirements.txt index 9b24f88..1fb7e26 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,52 +1,6 @@ -appdirs==1.4.3 -attrs==19.3.0 -backcall==0.1.0 -Click==7.0 -click-plugins==1.1.1 -cligj==0.5.0 -cycler==0.10.0 -decorator==4.4.2 -descartes==1.1.0 -distlib==0.3.0 -filelock==3.0.12 -Fiona==1.8.13.post1 -geopandas==0.7.0 -hypothesis==5.6.0 -importlib-metadata==1.5.0 -importlib-resources==1.2.0 -ipython==7.13.0 -ipython-genutils==0.2.0 -jedi==0.16.0 -kiwisolver==1.1.0 -matplotlib==3.2.0 -more-itertools==8.2.0 -munch==2.5.0 -nose==1.3.7 -numpy==1.18.1 -packaging==20.3 -pandas==1.0.1 -parso==0.6.2 -pexpect==4.8.0 -pickleshare==0.7.5 -Pillow==7.0.0 -pluggy==0.13.1 -prompt-toolkit==3.0.3 -ptyprocess==0.6.0 -py==1.8.1 -Pygments==2.5.2 -pyparsing==2.4.6 -pyproj==2.5.0 -pytest==5.3.5 -pytest-mpl==0.11 -python-dateutil==2.8.1 -pytz==2019.3 -scipy==1.4.1 -Shapely==1.7.0 -six==1.14.0 -sortedcontainers==2.1.0 -toml==0.10.0 -tox==3.14.5 -traitlets==4.3.3 -virtualenv==20.0.8 -wcwidth==0.1.8 -zipp==3.1.0 +# requirements.txt +# +# installs dependencies from ./setup.py, and the package itself, +# in editable mode for development + +-e .[all] diff --git a/setup.py b/setup.py index 6df8b8d..9d30add 100644 --- a/setup.py +++ b/setup.py @@ -8,12 +8,25 @@ GITHUB_URL = 'https://github.com/WZBSocialScienceCenter/geovoronoi' __title__ = 'geovoronoi' -__version__ = '0.2.0' +__version__ = '0.3.0dev' __author__ = 'Markus Konrad' __license__ = 'Apache License 2.0' here = os.path.abspath(os.path.dirname(__file__)) +DEPS_BASE = ['numpy>=1.19.0,<2', 'scipy>=1.6.0,<1.7', 'shapely>=1.7.0,<1.8'] + +DEPS_EXTRA = { + 'plotting': ['matplotlib>=3.3.0,<3.4', 'geopandas>=0.8.0,<0.9', 'descartes>=1.1.0,<1.2'], + 'test': ['pytest>=6.2.0,<6.3', 'pytest-mpl>=0.12,<0.13', 'hypothesis>=6.0.0,<6.1', 'tox>=3.21.0,<3.22'], + 'develop': ['ipython>=7.19.0', 'twine>=3.3.0'], +} + +DEPS_EXTRA['all'] = [] +for k, deps in DEPS_EXTRA.items(): + if k != 'all': + DEPS_EXTRA['all'].extend(deps) + # Get the long description from the README file with open(os.path.join(here, 'README.md'), encoding='utf-8') as f: long_description = f.read() @@ -43,10 +56,10 @@ 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', 'Topic :: Scientific/Engineering :: Information Analysis', 'Topic :: Software Development :: Libraries :: Python Modules', @@ -58,10 +71,6 @@ packages=['geovoronoi'], # include_package_data=True, python_requires='>=3.6', - install_requires=['numpy>=1.18.0', 'scipy>=1.4.0', 'shapely>=1.7.0'], - extras_require={ - 'plotting': ['matplotlib>=3.2.0', 'geopandas>=0.7.0', 'descartes>=1.1.0'], - 'test': ['pytest>=5.3.0', 'pytest-mpl>=0.11', 'hypothesis>=5.6.0', 'tox>=3.14.0'], - 'develop': ['ipython>=7.0.0', 'twine>=3.1.0'], - } + install_requires=DEPS_BASE, + extras_require=DEPS_EXTRA )