Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with mpl v3.9.2 (latest) #459

Open
wants to merge 95 commits into
base: master
Choose a base branch
from

Conversation

cvanelteren
Copy link

Continuation of #458 and #450. This PR makes it up-to-date with the latest mpl version.
It passes the generate unittests from #458, I will do some finalize testing since the colormaps are the major change in the last couple of mpl versions.

@cvanelteren
Copy link
Author

cvanelteren commented Jul 25, 2024

  • TODO fix docs
  • Note this makes use of the backwards compatibility for the colormaps. Over time these will be deprecated by mpl. I am still trying to figure out how @lukelbd uses the colormaps here, and how to adapt the code to mpl. For now everything seems to be running fine

@riley-brady
Copy link

Setting up environment for testing, with a bunch of bleeding edge modern package versions with python 3.11:

mamba create -c conda-forge -n pplot_test python=3.11 matplotlib cartopy numpy pandas xarray

Trying to install from most recent official proplot release:

conda activate pplot_test
mamba install -c conda-forge proplot
The following package could not be installed
└─ proplot is installable and it requires
   ├─ matplotlib <3.5.0a0  with the potential options
   │  ├─ matplotlib [3.3.2|3.3.3|...|3.4.3] would require
   │  │  └─ python >=3.8,<3.9.0a0 , which can be installed;
   │  ├─ matplotlib [3.3.2|3.3.3|...|3.4.3] would require
   │  │  └─ python >=3.9,<3.10.0a0 , which can be installed;
   │  └─ matplotlib 3.4.3 would require
   │     └─ python >=3.10,<3.11.0a0 , which can be installed;
   └─ matplotlib-base <3.5.0a0  with the potential options
      ├─ matplotlib-base [3.3.2|3.3.3|...|3.4.3] would require
      │  └─ python >=3.8,<3.9.0a0 , which can be installed;
      ├─ matplotlib-base [3.3.2|3.3.3|...|3.4.3] would require
      │  └─ python >=3.9,<3.10.0a0 , which can be installed;
      └─ matplotlib-base 3.4.3 would require
         └─ python >=3.10,<3.11.0a0 , which can be installed.

Now with your branch:

pip install git+https://github.com/proplot-dev/proplot.git@refs/pull/459/head

Install successful!! 🎉

Quick test:

import xarray as xr
import numpy as np
import proplot as plot

xr.DataArray(np.random.random((50, 50)), dims=['x', 'y']).plot()
Screenshot 2024-08-18 at 4 36 04 PM

@riley-brady
Copy link

Awesome job @cvanelteren!! Excited for @lukelbd to merge this in when he has time. In the meantime will broadcast on old issues and PRs to install this way.

@Holmgren825
Copy link

Hey, this is wonderful! Very happy to be able to update soon. I tried this out quickly and there seems to be a problem with the integration with cartopy. For instance:

fig, ax = pplt.subplots(proj="pcarree")

works as expected, but trying a few different projections such as "robin", "merc" or "npstere" does not and throws an error.

Click to expand trace

TypeError Traceback (most recent call last)
File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/matplotlib/figure.py:1787, in FigureBase.get_tightbbox(self, renderer, bbox_extra_artists)
1786 try:
-> 1787 bbox = ax.get_tightbbox(
1788 renderer, bbox_extra_artists=bbox_extra_artists)
1789 except TypeError:

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/proplot/axes/geo.py:1326, in _CartopyAxes.get_tightbbox(self, renderer, *args, **kwargs)
1324 self._gridliners = []
-> 1326 return super().get_tightbbox(renderer, *args, **kwargs)

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/proplot/axes/base.py:2780, in Axes.get_tightbbox(self, renderer, *args, **kwargs)
2779 self.indicate_inset_zoom()
-> 2780 self._tight_bbox = super().get_tightbbox(renderer, *args, **kwargs)
2781 return self._tight_bbox

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/cartopy/mpl/geoaxes.py:499, in GeoAxes.get_tightbbox(self, renderer, *args, **kwargs)
497 self._draw_preprocess(renderer)
--> 499 return super().get_tightbbox(renderer, *args, **kwargs)

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/matplotlib/_api/deprecation.py:457, in make_keyword_only..wrapper(*args, **kwargs)
452 warn_deprecated(
453 since, message="Passing the %(name)s %(obj_type)s "
454 "positionally is deprecated since Matplotlib %(since)s; the "
455 "parameter will become keyword-only %(removal)s.",
456 name=name, obj_type=f"parameter of {func.name}()")
--> 457 return func(*args, **kwargs)

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/matplotlib/axes/_base.py:4499, in _AxesBase.get_tightbbox(self, renderer, call_axes_locator, bbox_extra_artists, for_layout_only)
4498 for a in bbox_artists:
-> 4499 bbox = a.get_tightbbox(renderer)
4500 if (bbox is not None
4501 and 0 < bbox.width < np.inf
4502 and 0 < bbox.height < np.inf):

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/cartopy/mpl/gridliner.py:1243, in Gridliner.get_tightbbox(self, renderer)
1242 self._draw_gridliner(renderer=renderer)
-> 1243 bboxes = [c.get_tightbbox(renderer=renderer)
1244 for c in self.get_visible_children()]
1245 if bboxes:

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/cartopy/mpl/gridliner.py:1243, in (.0)
1242 self._draw_gridliner(renderer=renderer)
-> 1243 bboxes = [c.get_tightbbox(renderer=renderer)
1244 for c in self.get_visible_children()]
1245 if bboxes:

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/matplotlib/artist.py:365, in Artist.get_tightbbox(self, renderer)
350 """
351 Like .Artist.get_window_extent, but includes any clipping.
352
(...)
363 Returns None if clipping results in no intersection.
364 """
--> 365 bbox = self.get_window_extent(renderer)
366 if self.get_clip_on():

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/matplotlib/collections.py:311, in Collection.get_window_extent(self, renderer)
308 def get_window_extent(self, renderer=None):
309 # TODO: check to ensure that this does not fail for
310 # cases other than scatter plot legend
--> 311 return self.get_datalim(transforms.IdentityTransform())

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/matplotlib/collections.py:270, in Collection.get_datalim(self, transData)
269 if not transform.is_affine:
--> 270 paths = [transform.transform_path_non_affine(p) for p in paths]
271 # Don't convert transform to transform.get_affine() here because
272 # we may have transform.contains_branch(transData) but not
273 # transforms.get_affine().contains_branch(transData). But later,
274 # be careful to only apply the affine part that remains.

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/matplotlib/collections.py:270, in (.0)
269 if not transform.is_affine:
--> 270 paths = [transform.transform_path_non_affine(p) for p in paths]
271 # Don't convert transform to transform.get_affine() here because
272 # we may have transform.contains_branch(transData) but not
273 # transforms.get_affine().contains_branch(transData). But later,
274 # be careful to only apply the affine part that remains.

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/matplotlib/transforms.py:2445, in CompositeGenericTransform.transform_path_non_affine(self, path)
2444 elif not self._a.is_affine and self._b.is_affine:
-> 2445 return self._a.transform_path_non_affine(path)
2446 else:

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/cartopy/mpl/geoaxes.py:175, in InterProjectionTransform.transform_path_non_affine(self, src_path)
174 transformed_geoms = []
--> 175 geoms = cpatch.path_to_geos(src_path)
177 for geom in geoms:

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/cartopy/mpl/patch.py:210, in path_to_geos(path, force_ccw)
208 if geom_collection and all(isinstance(geom, sgeom.LineString) for
209 geom in geom_collection):
--> 210 geom_collection = [sgeom.MultiLineString(geom_collection)]
212 # Remove any zero area Polygons

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/shapely/geometry/multilinestring.py:60, in MultiLineString.new(self, lines)
58 return shapely.from_wkt("MULTILINESTRING EMPTY")
---> 60 return shapely.multilinestrings(subs)

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/shapely/decorators.py:77, in multithreading_enabled..wrapped(*args, **kwargs)
76 arr.flags.writeable = False
---> 77 return func(*args, **kwargs)
78 finally:

File ~/miniforge3/envs/ppl_dev/lib/python3.11/site-packages/shapely/creation.py:393, in multilinestrings(geometries, indices, out, **kwargs)
392 if indices is None:
--> 393 return lib.create_collection(geometries, typ, out=out, **kwargs)
394 else:

TypeError: ufunc 'create_collection' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

@cvanelteren
Copy link
Author

cvanelteren commented Aug 20, 2024

@Holmgren825 I cannot reproduce this error here locally. It also points to a shapely issue rather than proplot. I have cartopy 0.23.0 installed, what version are you running?

For shapely the version is 2.0.5.

@cvanelteren
Copy link
Author

The projections in the docs also point to it working fine (see https://proplot--459.org.readthedocs.build/en/459/projections.html). The environment is currently rather unconstrained and would love to add the information in there to prevent a build issue like yours from happening.

@Holmgren825
Copy link

Holmgren825 commented Aug 20, 2024

Wierd. I had the same versions (0.23.0 and 2.0.5). But if I upgrade to shapely 2.0.6 things work.

Edit: ufunc in the error should be a hint. 2.0.6 (released last night) is a compatibility release for numpy 2.1 (which I had installed).

@cvanelteren
Copy link
Author

Ah thanks for reminding me. Numpy should be held back due to some dependency issues with xarray. Fixed in latest commit

@cvanelteren cvanelteren mentioned this pull request Aug 20, 2024
@huddao
Copy link

huddao commented Aug 27, 2024

cannot install:

$ pip install git+https://github.com/proplot-dev/proplot.git@refs/pull/459/head
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting git+https://github.com/proplot-dev/proplot.git@refs/pull/459/head
  Cloning https://github.com/proplot-dev/proplot.git (to revision refs/pull/459/head) to /tmp/pip-req-build-0rm6thj_
  Running command git clone --quiet https://github.com/proplot-dev/proplot.git /tmp/pip-req-build-0rm6thj_
  WARNING: Did not find branch or tag 'refs/pull/459/head', assuming revision or ref.
  Running command git fetch -q https://github.com/proplot-dev/proplot.git refs/pull/459/head
  Running command git checkout -q f7524a24eef76f59b5d0fad56faac14e9fcf0846
  Resolved https://github.com/proplot-dev/proplot.git to commit f7524a24eef76f59b5d0fad56faac14e9fcf0846
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: importlib-metadata in /public/home/hzc/soft/anaconda3-2023/envs/geos-chem-3.11/lib/python3.11/site-packages (from proplot==0.9.5.post425) (8.4.0)
Requirement already satisfied: zipp>=0.5 in /public/home/hzc/soft/anaconda3-2023/envs/geos-chem-3.11/lib/python3.11/site-packages (from importlib-metadata->proplot==0.9.5.post425) (3.20.0)

@cvanelteren
Copy link
Author

cvanelteren commented Aug 27, 2024

@huddao huddao I don't see any errors?

@huddao
Copy link

huddao commented Aug 27, 2024

@cvanelteren The version is 'proplot==0.9.5.post425', I'm not sure this is the correct version.

@cvanelteren
Copy link
Author

The correct version should be tagged as v0.9.91. Try installing it from here:

pip install git+https://github.com/cvanelteren/[email protected]

@huddao
Copy link

huddao commented Aug 27, 2024

@cvanelteren Thanks!

@austin-hoover
Copy link

Working for me! Thank you cvanelteren.

@austin-hoover
Copy link

Any update on this? I'm posting analysis code for a paper and it would be great to reference the main proplot branch in the requirements.

@riley-brady
Copy link

Nothing that I've seen @austin-hoover. Still waiting on @lukelbd to come in and merge, as he is the only one with permissions. For now you will have to point to @cvanelteren's branch. You can always update your code repo linked to the paper at a later point and point back to a main release here.

@cvanelteren
Copy link
Author

Any movement on this @lukelbd?

@austin-hoover
Copy link

Also PyPI doesn't allow direct links to GitHub repos, so projects on PyPI can't list working proplot version as a dependency right now.

@cvanelteren
Copy link
Author

cvanelteren commented Nov 7, 2024

I wanted to address the current status of proplot's development. With the recent lack of movement on this project, there's a genuine concern about potentially losing our valuable contributors. To prevent this, I'm proposing we restructure the project under a more collaborative, organization-based framework that would:

  1. Facilitate continued development
  2. Decentralize the pull request process
  3. Enable broader community participation

Beginning in the new year, I'm prepared to take on a more active leadership role in this initiative. My plan includes forking the repository to maintain development momentum, but I'm committed to keeping communication channels open with @lukelbd and other stakeholders.

I'd like to extend an invitation to all interested contributors to join this effort. If you're passionate about proplot's future and want to be part of its continued development, please reach out to discuss how we can collaborate effectively.

Together, we can ensure proplot remains a vibrant and well-maintained project that serves its community's needs.

@riley-brady
Copy link

I wanted to address the current status of proplot's development. With the recent lack of movement on this project, there's a genuine concern about potentially losing our valuable contributors. To prevent this, I'm proposing we restructure the project under a more collaborative, organization-based framework that would:

  1. Facilitate continued development
  2. Decentralize the pull request process
  3. Enable broader community participation

Beginning in the new year, I'm prepared to take on a more active leadership role in this initiative. My plan includes forking the repository to maintain development momentum, but I'm committed to keeping communication channels open with @lukelbd and other stakeholders.

I'd like to extend an invitation to all interested contributors to join this effort. If you're passionate about proplot's future and want to be part of its continued development, please reach out to discuss how we can collaborate effectively.

Together, we can ensure proplot remains a vibrant and well-maintained project that serves its community's needs.

Please keep us posted when you fork out and launch the project. My job has severely limited the time I have to directly contribute, but I can continue with scoping as I did here. Might have some opportunities to contribute directly as well. Thanks @cvanelteren and enjoy your well-earned vacation!

@beckermr
Copy link

beckermr commented Nov 8, 2024

@cvanelteren count me in on helping with dev as I can and I'd like to be a part of the effort. Also, I am cross-referencing the issue currently open on more sustainable development (#452).

From the point of view of shipping a fork on conda-forge, it will be by far the easiest if the forked project gets a new name.

@cvanelteren
Copy link
Author

Yes I agree @beckermr -- I already have a logo for it ;-). I will be in touch in the new year!

@pratiman-91
Copy link
Contributor

@cvanelteren I am willing to help wherever I can. I like proplot, and it would be nice to see a continuous development along with the latest matplotlib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants