shakasom / voronoi

Voronoi diagrams with Python
8 stars 2 forks source link

Fails on lastest Jupyter Lab with latest python modules #1

Open christian-weiss opened 3 years ago

christian-weiss commented 3 years ago

Looks like this Jupyther Notebook i not compatible with the lastet python modules.

With lastet version of all modules i get in step:

# Calculate Voronoi Regions
poly_shapes, pts, poly_to_pt_assignments = voronoi_regions_from_coords(coords, boundary_shape)

the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-11-7f40d335d004> in <module>
      1 # Calculate Voronoi Regions
----> 2 poly_shapes, pts, poly_to_pt_assignments = voronoi_regions_from_coords(coords, boundary_shape)

ValueError: not enough values to unpack (expected 3, got 2)

After a downgrade of geovoronoi to 0.1.2 did help a bit but i run into the next issue:

fig, ax = subplot_for_map()

plot_voronoi_polys_with_points_in_area(ax, boundary_shape, poly_shapes, pts, poly_to_pt_assignments)

ax.set_title('Voronoi regions of Schools in Uppsala')

plt.tight_layout()
plt.show()

i get the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-15-a22de067d74b> in <module>
      1 fig, ax = subplot_for_map()
      2 
----> 3 plot_voronoi_polys_with_points_in_area(ax, boundary_shape, poly_shapes, pts, poly_to_pt_assignments)
      4 
      5 ax.set_title('Voronoi regions of Schools in Uppsala')

/opt/conda/lib/python3.9/site-packages/geovoronoi/plotting.py in plot_voronoi_polys_with_points_in_area(ax, area_shape, poly_shapes, points, poly_to_pt_assignments, area_color, area_edgecolor, voronoi_and_points_cmap, voronoi_color, voronoi_edgecolor, points_color, points_markersize, points_marker, voronoi_labels, voronoi_label_fontsize, voronoi_label_color, point_labels, point_label_fontsize, point_label_color, plot_area_opts, plot_voronoi_opts, plot_points_opts)
    146         voronoi_edgecolor = 'black'   # better visible default value
    147 
--> 148     plot_voronoi_polys(ax, poly_shapes, color=voronoi_color, edgecolor=voronoi_edgecolor,
    149                        labels=voronoi_labels, label_fontsize=voronoi_label_fontsize, label_color=voronoi_label_color,
    150                        **plot_voronoi_opts)

/opt/conda/lib/python3.9/site-packages/geovoronoi/plotting.py in plot_voronoi_polys(ax, poly_shapes, color, edgecolor, labels, label_fontsize, label_color, **kwargs)
     66     """
     67 
---> 68     _plot_polygon_collection_with_color(ax, poly_shapes, color=color, edgecolor=edgecolor, **kwargs)
     69 
     70     if labels:

/opt/conda/lib/python3.9/site-packages/geovoronoi/plotting.py in _plot_polygon_collection_with_color(ax, geoms, color, **kwargs)
    212         del kwargs['markersize']
    213 
--> 214     collection = PatchCollection([PolygonPatch(poly) for poly in geoms],
    215                                  color=color, **kwargs)
    216 

/opt/conda/lib/python3.9/site-packages/matplotlib/collections.py in __init__(self, patches, match_original, **kwargs)
   1890             kwargs['antialiaseds'] = [p.get_antialiased() for p in patches]
   1891 
-> 1892         super().__init__(**kwargs)
   1893 
   1894         self.set_paths(patches)

/opt/conda/lib/python3.9/site-packages/matplotlib/_api/deprecation.py in wrapper(*inner_args, **inner_kwargs)
    429                          else deprecation_addendum,
    430                 **kwargs)
--> 431         return func(*inner_args, **inner_kwargs)
    432 
    433     return wrapper

/opt/conda/lib/python3.9/site-packages/matplotlib/collections.py in __init__(self, edgecolors, facecolors, linewidths, linestyles, capstyle, joinstyle, antialiaseds, offsets, transOffset, norm, cmap, pickradius, hatch, urls, offset_position, zorder, **kwargs)
    215 
    216         self._path_effects = None
--> 217         self.update(kwargs)
    218         self._paths = None
    219 

/opt/conda/lib/python3.9/site-packages/matplotlib/artist.py in update(self, props)
   1062                         raise AttributeError(f"{type(self).__name__!r} object "
   1063                                              f"has no property {k!r}")
-> 1064                     ret.append(func(v))
   1065         if ret:
   1066             self.pchanged()

/opt/conda/lib/python3.9/site-packages/matplotlib/collections.py in set_color(self, c)
    758             For setting the edge or face color individually.
    759         """
--> 760         self.set_facecolor(c)
    761         self.set_edgecolor(c)
    762 

/opt/conda/lib/python3.9/site-packages/matplotlib/collections.py in set_facecolor(self, c)
    787             c = c.lower()
    788         self._original_facecolor = c
--> 789         self._set_facecolor(c)
    790 
    791     def get_facecolor(self):

/opt/conda/lib/python3.9/site-packages/matplotlib/collections.py in _set_facecolor(self, c)
    769             c = self._get_default_facecolor()
    770 
--> 771         self._facecolors = mcolors.to_rgba_array(c, self._alpha)
    772         self.stale = True
    773 

/opt/conda/lib/python3.9/site-packages/matplotlib/colors.py in to_rgba_array(c, alpha)
    383             rgba = np.array([to_rgba(cc) for cc in c])
    384     else:
--> 385         rgba = np.array([to_rgba(cc) for cc in c])
    386 
    387     if alpha is not None:

/opt/conda/lib/python3.9/site-packages/matplotlib/colors.py in <listcomp>(.0)
    383             rgba = np.array([to_rgba(cc) for cc in c])
    384     else:
--> 385         rgba = np.array([to_rgba(cc) for cc in c])
    386 
    387     if alpha is not None:

/opt/conda/lib/python3.9/site-packages/matplotlib/colors.py in to_rgba(c, alpha)
    204         rgba = None
    205     if rgba is None:  # Suppress exception chaining of cache lookup failure.
--> 206         rgba = _to_rgba_no_colorcycle(c, alpha)
    207         try:
    208             _colors_full_map.cache[c, alpha] = rgba

/opt/conda/lib/python3.9/site-packages/matplotlib/colors.py in _to_rgba_no_colorcycle(c, alpha)
    282     # tuple color.
    283     if not np.iterable(c):
--> 284         raise ValueError(f"Invalid RGBA argument: {orig_c!r}")
    285     if len(c) not in [3, 4]:
    286         raise ValueError("RGBA sequence should have length 3 or 4")

ValueError: Invalid RGBA argument: 0

Downgrade all the way from matplotlib==3.4.2 to matplotlib==3.1.0 did not help to fix the above error.

I tried for fix that with:

import sys
!{sys.executable} -m pip install geovoronoi==0.1.2
!{sys.executable} -m pip install geopandas==0.9.0
!{sys.executable} -m pip install contextily==1.1.0
!{sys.executable} -m pip install shapely==1.7.1
!{sys.executable} -m pip install descartes==1.1.0
!{sys.executable} -m pip install matplotlib==3.1.0

I could not find a matplotlib module version that works.

What version are you using, @shakasom ?

charlietls commented 2 years ago

having same issue. @christian-weiss you found fix yet? below is my env: (base) root@8d05ab968179:~/tmp/voronoi# pip list WARNING: The directory '/home/jovyan/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag. Package Version


affine 2.3.0 aiohttp 3.8.1 aiosignal 1.2.0 alembic 1.7.4 altair 4.1.0 anyio 3.3.4 appdirs 1.4.4 argon2-cffi 21.1.0 async-generator 1.10 async-timeout 4.0.1 attrs 21.2.0 Babel 2.9.1 backcall 0.2.0 backports.functools-lru-cache 1.6.4 beautifulsoup4 4.10.0 bleach 4.1.0 blinker 1.4 bokeh 2.4.1 Bottleneck 1.3.2 branca 0.4.2 brotlipy 0.7.0 cached-property 1.5.2 cachetools 4.2.4 certifi 2021.10.8 certipy 0.1.3 cffi 1.14.6 chardet 4.0.0 charset-normalizer 2.0.0 click 8.0.3 click-plugins 1.1.1 cligj 0.7.2 cloudpickle 2.0.0 colorama 0.4.4 conda 4.10.3 conda-package-handling 1.7.3 contextily 1.2.0 cryptography 35.0.0 cycler 0.11.0 Cython 0.29.24 cytoolz 0.11.0 dask 2021.10.0 debugpy 1.4.1 decorator 5.1.0 defusedxml 0.7.1 descartes 1.1.0 dill 0.3.4 distributed 2021.10.0 entrypoints 0.3 Fiona 1.8.20 folium 0.12.1.post1 frozenlist 1.2.0 fsspec 2021.10.1 GDAL 3.4.0 geographiclib 1.52 geojson 2.5.0 geopandas 0.10.2 geopy 2.2.0 geovoronoi 0.3.0 gmaps 0.9.0 gmpy2 2.1.0b5 google-api-core 1.31.2 google-auth 1.35.0 google-auth-oauthlib 0.4.6 google-cloud-bigquery 1.10.0 google-cloud-core 0.29.1 google-resumable-media 0.5.0 googleapis-common-protos 1.53.0 greenlet 1.1.2 h5py 3.4.0 HeapDict 1.0.1 idna 3.1 imagecodecs 2021.8.26 imageio 2.9.0 importlib-metadata 4.8.1 importlib-resources 5.3.0 ipykernel 6.4.2 ipympl 0.8.2 ipython 7.28.0 ipython-genutils 0.2.0 ipywidgets 7.6.5 jedi 0.18.0 Jinja2 3.0.2 joblib 1.1.0 json5 0.9.5 jsonschema 4.1.2 jupyter-client 7.0.6 jupyter-core 4.9.1 jupyter-server 1.11.1 jupyter-telemetry 0.1.0 jupyterhub 1.4.2 jupyterlab 3.2.1 jupyterlab-pygments 0.1.2 jupyterlab-server 2.8.2 jupyterlab-widgets 1.0.2 kiwisolver 1.3.2 llvmlite 0.37.0 locket 0.2.0 Mako 1.1.5 mamba 0.17.0 mapclassify 2.4.3 MarkupSafe 2.0.1 matplotlib 3.4.3 matplotlib-inline 0.1.3 mercantile 1.2.1 mistune 0.8.4 mock 4.0.3 mpmath 1.2.1 msgpack 1.0.2 multidict 5.2.0 munch 2.5.0 nbclassic 0.3.3 nbclient 0.5.4 nbconvert 6.2.0 nbformat 5.1.3 nest-asyncio 1.5.1 networkx 2.6.3 notebook 6.4.5 numba 0.54.1 numexpr 2.7.3 numpy 1.20.3 oauthlib 3.1.1 olefile 0.46 packaging 21.0 pamela 1.0.0 pandas 1.3.4 pandocfilters 1.5.0 parso 0.8.2 partd 1.2.0 patsy 0.5.2 pexpect 4.8.0 pickleshare 0.7.5 Pillow 8.3.2 pip 21.3.1 pooch 1.5.2 prometheus-client 0.11.0 prompt-toolkit 3.0.21 protobuf 3.19.1 psutil 5.8.0 ptyprocess 0.7.0 pyasn1 0.4.8 pyasn1-modules 0.2.7 pycosat 0.6.3 pycparser 2.20 pycurl 7.44.1 pydata-google-auth 1.2.0 Pygments 2.10.0 PyJWT 2.3.0 pyOpenSSL 21.0.0 pyparsing 3.0.3 pyproj 3.3.0 pyrsistent 0.17.3 PySocks 1.7.1 python-dateutil 2.8.2 python-figures 1.1 python-json-logger 2.0.1 pytz 2021.3 pytz-deprecation-shim 0.1.0.post0 pyu2f 0.1.5 PyWavelets 1.1.1 PyYAML 6.0 pyzmq 22.3.0 rasterio 1.2.10 requests 2.26.0 requests-oauthlib 1.3.0 requests-unixsocket 0.2.0 rpy2 3.4.5 rsa 4.8 Rtree 0.9.7 ruamel.yaml 0.17.16 ruamel.yaml.clib 0.2.2 ruamel-yaml-conda 0.15.80 scikit-image 0.18.3 scikit-learn 1.0.1 scipy 1.6.3 seaborn 0.11.2 Send2Trash 1.8.0 setuptools 58.2.0 Shapely 1.7.1 simplegeneric 0.8.1 six 1.16.0 smopy 0.0.7 sniffio 1.2.0 snuggs 1.4.7 sortedcontainers 2.4.0 soupsieve 2.0.1 SQLAlchemy 1.4.26 statsmodels 0.13.0 sympy 1.9 tables 3.6.1 tblib 1.7.0 terminado 0.12.1 testpath 0.5.0 threadpoolctl 3.0.0 tifffile 2021.10.12 toolz 0.11.1 tornado 6.1 tqdm 4.62.3 traitlets 5.1.1 turfpy 0.0.7 typing-extensions 3.10.0.2 tzdata 2021.5 tzlocal 4.1 urllib3 1.26.7 wcwidth 0.2.5 webencodings 0.5.1 websocket-client 0.57.0 wheel 0.37.0 widgetsnbextension 3.5.2 xlrd 2.0.1 xyzservices 2021.11.0 yarl 1.7.2 zict 2.0.0 zipp 3.6.0