diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 02100ee4..0af1c868 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -29,12 +29,12 @@ jobs: python -m pip install -r docs/requirements.txt - name: Build docs run: ./.github/jobs/build_documentation.sh - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v7 if: always() with: name: documentation path: artifact/documentation - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v7 if: failure() with: name: documentation_warnings.log diff --git a/.github/workflows/linkcheck.yml b/.github/workflows/linkcheck.yml new file mode 100644 index 00000000..305c6dce --- /dev/null +++ b/.github/workflows/linkcheck.yml @@ -0,0 +1,19 @@ +name: Linkcheck +on: + schedule: + - cron: '0 6 * * 1' + pull_request: + paths: + - 'docs/**' + workflow_dispatch: {} + +jobs: + linkcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: dtcenter/metplus-action-linkcheck@v1 + with: + fail-on-broken-links: 'true' + upload-artifact: 'true' + install-package: 'true' \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 3da31ba3..fde51216 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -97,7 +97,29 @@ numfig_format = { 'figure': 'Figure %s', } - + +# -- linkcheck builder configuration ---------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-the-linkcheck-builder + +linkcheck_timeout = 10 +linkcheck_retries = 2 +linkcheck_workers = 8 + +linkcheck_ignore = [ + # add regex patterns for URLs that should be skipped, e.g.: + # r'https://dtcenter\.org/.*', # if this site blocks automated requests + # r'https://matplotlib\.org/.*', # occasionally rate-limits automated clients + # r'https://scitools\.org\.uk/cartopy/.*', # occasionally slow + # r'https://doi\.org/.*', # DOI redirectors often 403 non-browser requests +] + +linkcheck_allowed_redirects = { + # map of regex -> regex for redirects that are fine to follow +} + +linkcheck_anchors = True +linkcheck_anchors_ignore = ['^!'] + # -- Export variables -------------------------------------------------------- rst_epilog = """ @@ -110,3 +132,4 @@ release_datestr = release_date, release_yearstr = release_year) + diff --git a/metplotpy/plots/base_plot.py b/metplotpy/plots/base_plot.py index 3551ba08..f7ad4541 100644 --- a/metplotpy/plots/base_plot.py +++ b/metplotpy/plots/base_plot.py @@ -369,6 +369,7 @@ def _add_legend(self, ax: plt.Axes, handles_and_labels=None, loc='upper center') if not handles: print("Warning: No labels found. Use ax.plot(..., label='name')") + return # handle plots that only have a single boolean for show legend show_legend = self.config_obj.show_legend @@ -379,6 +380,10 @@ def _add_legend(self, ax: plt.Axes, handles_and_labels=None, loc='upper center') filtered_handles = [h for h, show in zip(handles, show_legend) if show == 1] filtered_labels = [l for l, show in zip(labels, show_legend) if show == 1] + # Check if there are any handles left to plot + if not filtered_handles: + return + legend = ax.legend( handles=filtered_handles, labels=filtered_labels, diff --git a/metplotpy/plots/taylor_diagram/taylor_diagram.py b/metplotpy/plots/taylor_diagram/taylor_diagram.py index 146c6e9e..66be05c7 100644 --- a/metplotpy/plots/taylor_diagram/taylor_diagram.py +++ b/metplotpy/plots/taylor_diagram/taylor_diagram.py @@ -174,7 +174,7 @@ def _create_figure(self) -> None: # in Matplotlib 3.10, the default for apply_theta_transforms=True has been deprecated, explicitly set this # to True - tr = PolarAxes.PolarTransform(apply_theta_transforms=False) + tr = PolarAxes.PolarTransform() # Correlation labels rlocs = np.array([0, 0.2, 0.4, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 1]) diff --git a/metplotpy/plots/tcmpr_plots/tcmpr.py b/metplotpy/plots/tcmpr_plots/tcmpr.py index 26bf45e5..21e3a836 100755 --- a/metplotpy/plots/tcmpr_plots/tcmpr.py +++ b/metplotpy/plots/tcmpr_plots/tcmpr.py @@ -240,7 +240,7 @@ def _add_legend(self, ax=None, handles_and_labels=None) -> None: """ if ax is None: ax = self.ax - super()._add_legend(ax) + super()._add_legend(ax, handles_and_labels=handles_and_labels) def _get_nstats(self) -> list: """