From 21e8414f97dde65ad981af50bc59c38b66eea046 Mon Sep 17 00:00:00 2001 From: elbeejay Date: Mon, 6 Jul 2026 20:47:59 -0400 Subject: [PATCH 1/2] Refactor: single source of truth for version and bump to 2.7.1 --- dorado/__init__.py | 8 +++++++- pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dorado/__init__.py b/dorado/__init__.py index 489383a..fe8797e 100644 --- a/dorado/__init__.py +++ b/dorado/__init__.py @@ -1,4 +1,10 @@ -__version__ = "2.7.0" +from importlib.metadata import version, PackageNotFoundError + +try: + __version__ = version("pydorado") +except PackageNotFoundError: + __version__ = "unknown" + from . import lagrangian_walker from . import parallel_routing diff --git a/pyproject.toml b/pyproject.toml index 9d20645..1655664 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pydorado" -version = "2.7.0" +version = "2.7.1" description = "dorado - Lagrangian particle routing routine via weighted random walks" readme = { file = "README.md", content-type = "text/markdown" } license = { file = "LICENSE" } From 2f3a431f9bcb56e84b8ff2a318a7cb71aeef5cdb Mon Sep 17 00:00:00 2001 From: elbeejay Date: Mon, 6 Jul 2026 20:59:48 -0400 Subject: [PATCH 2/2] Fix deprecated matplotlib get_cmap --- dorado/routines.py | 12 ++++++++++-- .../spatial_exposure_time_example_Delft3DFM.ipynb | 7 ++++--- tests/test_spatial.py | 5 +++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/dorado/routines.py b/dorado/routines.py index 2d43068..1de0eaa 100644 --- a/dorado/routines.py +++ b/dorado/routines.py @@ -1304,7 +1304,11 @@ def show_nourishment_area(visit_freq, grid=None, walk_data=None, alphas = Normalize(0, amax, clip=True)(visit_freq) # Normalize alphas alphas = np.clip(alphas, min_alpha, 1) colors = Normalize(np.nanmin(visit_freq), 1)(visit_freq) # Normalize color - cmap = plt.cm.get_cmap(cmap) + if isinstance(cmap, str): + try: + cmap = matplotlib.colormaps[cmap] + except AttributeError: + cmap = plt.cm.get_cmap(cmap) colors = cmap(colors) colors[..., -1] = alphas @@ -1390,7 +1394,11 @@ def show_nourishment_time(mean_times, grid=None, walk_data=None, alphas = np.clip(alphas, min_alpha, 1) colors = Normalize(np.nanmin(mean_times), np.nanmax(mean_times))(mean_times) # Normalize colors - cmap = plt.cm.get_cmap(cmap) + if isinstance(cmap, str): + try: + cmap = matplotlib.colormaps[cmap] + except AttributeError: + cmap = plt.cm.get_cmap(cmap) colors = cmap(colors) colors[..., -1] = alphas diff --git a/examples/spatial_exposure_time_example_Delft3DFM.ipynb b/examples/spatial_exposure_time_example_Delft3DFM.ipynb index 7e012da..b9edd51 100644 --- a/examples/spatial_exposure_time_example_Delft3DFM.ipynb +++ b/examples/spatial_exposure_time_example_Delft3DFM.ipynb @@ -41,6 +41,7 @@ "import json\n", "from pathlib import Path\n", "import dorado\n", + "import matplotlib\n", "from matplotlib import pyplot as plt\n", "import dorado.spatial as spat\n", "import dorado.particle_track as pt" @@ -423,7 +424,7 @@ "outputs": [], "source": [ "title = 'System-wide exposure time (days)'\n", - "cmap = plt.get_cmap('plasma_r')\n", + "cmap = matplotlib.colormaps['plasma_r'] if hasattr(matplotlib, 'colormaps') else plt.get_cmap('plasma_r')\n", "max_exposure = 30 # max time in model\n", "cbar_levels = 7" ] @@ -563,7 +564,7 @@ "outputs": [], "source": [ "title_local = 'Localized exposure time (days)'\n", - "cmap_local = plt.get_cmap('viridis_r')\n", + "cmap_local = matplotlib.colormaps['viridis_r'] if hasattr(matplotlib, 'colormaps') else plt.get_cmap('viridis_r')\n", "max_exposure_local = 7\n", "cbar_levels_local = 6" ] @@ -655,4 +656,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} +} \ No newline at end of file diff --git a/tests/test_spatial.py b/tests/test_spatial.py index 4a460a0..683be9d 100644 --- a/tests/test_spatial.py +++ b/tests/test_spatial.py @@ -4,6 +4,7 @@ @author: cturn """ +import matplotlib from matplotlib import pyplot as plt import numpy as np import pytest @@ -100,7 +101,7 @@ def test_plot_spatial(test_grid, walk_data): elevation=elevation, max_exposure=7, cbar_levels=7, - cmap=plt.get_cmap("plasma_r"), + cmap=matplotlib.colormaps["plasma_r"] if hasattr(matplotlib, "colormaps") else plt.get_cmap("plasma_r"), title="Test System-Wide (s)") plt.close("all") @@ -112,6 +113,6 @@ def test_plot_spatial(test_grid, walk_data): elevation=elevation, max_exposure=7, cbar_levels=7, - cmap=plt.get_cmap("viridis_r"), + cmap=matplotlib.colormaps["viridis_r"] if hasattr(matplotlib, "colormaps") else plt.get_cmap("viridis_r"), title="Test Localized (s)") plt.close("all")