PyPSA / powerplantmatching

Set of tools to combine multiple power plant databases
https://powerplantmatching.readthedocs.io/en/latest/
GNU General Public License v3.0
152 stars 52 forks source link

Invalid cartopy method call in "draw_basemap" #184

Closed irm-codebase closed 1 month ago

irm-codebase commented 1 month ago

The issue

Calling ppm.plotpowerplant_map(some_ppm_df) will result in failure due to this line:

ax.outline_patch.set_visible(False)

This is most likely because the dependencies of this library are not pinned to "below" X version of geopandas and cartopy, resulting in unstable software.

The error shown is:

Traceback (most recent call last):
 Line 42, in <module>
    ppm.plot.powerplant_map(plants)
  Line 123, in powerplant_map
    draw_basemap(ax=ax, resolution=resolution, fillcontinents=fillcontinents)
  Line 390, in draw_basemap
    ax.outline_patch.set_visible(False)
    ^^^^^^^^^^^^^^^^
AttributeError: 'GeoAxes' object has no attribute 'outline_patch'

Solutions

v0.5.15 (the newest version at the moment) has several of these issues (e.g., using append instead of concat in other plotting functions).

Although modifying the line would fix this issue, using a lockfile is more robust long-term. There are some nice tools to do this (I like pixi).

irm-codebase commented 1 month ago

Additionally, pinning cartopy to 0.17 (the version before outline_patch was depreciated) on the user side causes other headaches, since it's a fairly old version...

lkstrp commented 1 month ago

Thank you @irm-codebase !

The linked pr should fix that. Other pandas compatibility issues should also have been fixed in the master. If you encounter any other issues feel free to raise them. I'll make a release soon.

We are trying to improve the tests so that these things are caught earlier and no pins are needed.

irm-codebase commented 1 month ago

Great, thank you for the help Lukas!