From f4b87407a3f76e2776ad3324cf4687d49c40b1a1 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:20:53 -0400 Subject: [PATCH 01/35] grammar fixes --- xclim/core/locales.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/xclim/core/locales.py b/xclim/core/locales.py index 21fd564ce..36462354f 100644 --- a/xclim/core/locales.py +++ b/xclim/core/locales.py @@ -6,8 +6,8 @@ climate indicators computed by xclim. Go to :ref:`notebooks/customize:Adding translated metadata` to see how to use this feature. -All the methods and objects in this module use localization data given in json files. -These files are expected to be defined as in this example for french: +All the methods and objects in this module use localization data given in JSON files. +These files are expected to be defined as in this example for French: .. code-block:: @@ -34,14 +34,15 @@ Use the `ind.__class__.__name__` accessor to get its registry name. Here, the usual parameter passed to the formatting of "description" is "freq" and is usually translated from "YS" -to "annual". However, in french and in this sentence, the feminine form should be used, so the "f" modifier is added +to "annual". However, in French and in this sentence, the feminine form should be used, so the "f" modifier is added by the translator so that the formatting function knows which translation to use. Acceptable entries for the mappings are limited to what is already defined in `xclim.core.indicators.utils.default_formatter`. For user-provided internationalization dictionaries, only the "attrs_mapping" and its "modifiers" key are mandatory, all other entries (translations of frequent parameters and all indicator entries) are optional. For xclim-provided translations (for now only French), all indicators must have en entry and the "attrs_mapping" -entries must match exactly the default formatter. Those default translations are found in the `xclim/locales` folder. +entries must match exactly the default formatter. +Those default translations are found in the `xclim/locales` folder. """ from __future__ import annotations @@ -186,7 +187,8 @@ def get_local_attrs( local_attrs.update(loc_dict.get(other_ind, {})) if not local_attrs: warnings.warn( - f"Attributes of indicator {', '.join(indicator)} in language {locale} were requested, but none were found." + f"Attributes of indicator {', '.join(indicator)} in language {locale} " + "were requested, but none were found." ) else: for name in TRANSLATABLE_ATTRS: From 52dd741e76d533864fc3b6e54d10c81c5dde3fa6 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:22:05 -0400 Subject: [PATCH 02/35] add docstring for xclim/data --- xclim/data/__init__.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/xclim/data/__init__.py b/xclim/data/__init__.py index c767fc157..380b73fae 100644 --- a/xclim/data/__init__.py +++ b/xclim/data/__init__.py @@ -1 +1,22 @@ -"""JSON and YAML definitions for virtual modules and internationalisation support.""" +""" +==================== +Data files for xclim +==================== + +JSON and YAML definitions for virtual modules and internationalisation support. + +Currently, the following virtual modules are defined: + * ANUCLIM (`anuclim.yml`) + * CF (`cf.yml`) + * ICCLIM (`icclim.yml`) + +And the following languages are supported: + * English (default) + * French (`fr.json`) + +These files are used by xclim to define new indicators and to provide translations for the user interface. + +Additionally, this package contains the following data files: + * `schema.yml`: YAML schema for detailing class definitions used for indicators. + * `variables.yml`: YAML schema defining the variables and their metadata used in the indicator definitions. +""" From b004bc96483c6d78183d16bc14bbcefaf36556cf Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:23:15 -0400 Subject: [PATCH 03/35] generalize warning about development versions of Python --- docs/installation.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/installation.rst b/docs/installation.rst index 5141427b9..80ec03412 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -114,9 +114,9 @@ From sources ------------ .. warning:: - For Python3.11+ users: Many of the required scientific libraries do not currently have wheels that support the latest - python. In order to ensure that installation of xclim doesn't fail, we suggest installing the `Cython` module - before installing xclim in order to compile necessary libraries from source packages. + While `xclim` strives to be compatible with latest releases and development versions of upstream libraries, many of the required base libraries (`numpy`, `scipy`, `numba`, etc.) may lag by several months before supporting the latest minor releases of Python. + + In order to ensure that installation of `xclim` doesn't fail, we suggest installing the `Cython` module before installing `xclim` in order to compile necessary libraries from their source packages, if required. The sources for xclim can be downloaded from the `Github repo`_. From 3fc48c25282a1c0d03792b3d017370407c06fab8 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:30:48 -0400 Subject: [PATCH 04/35] add furo to dependencies, convert docs to furo style, add a dark version logo, move indicators.json to _dynamic folder --- .gitignore | 2 +- docs/_static/style.css | 2 +- docs/api.rst | 5 -- docs/conf.py | 53 ++++++++++++------ docs/logos/xclim-logo-dark.png | Bin 0 -> 8673 bytes .../{xclim-logo.png => xclim-logo-light.png} | Bin environment.yml | 2 +- pyproject.toml | 2 +- 8 files changed, 40 insertions(+), 26 deletions(-) create mode 100644 docs/logos/xclim-logo-dark.png rename docs/logos/{xclim-logo.png => xclim-logo-light.png} (100%) diff --git a/.gitignore b/.gitignore index 7b0401607..cef52ef05 100644 --- a/.gitignore +++ b/.gitignore @@ -109,7 +109,7 @@ ENV/ # autogenerated RestructuredText docs/apidoc/modules.rst docs/apidoc/xclim*.rst -docs/indicators.json +docs/_dynamic/indicators.json docs/variables.json .vscode diff --git a/docs/_static/style.css b/docs/_static/style.css index 5d18dca7c..abe960f45 100644 --- a/docs/_static/style.css +++ b/docs/_static/style.css @@ -1,4 +1,4 @@ -@import url("theme.css"); +@import url("styles/furo.css"); .wy-side-nav-search>a img.logo, .wy-side-nav-search .wy-dropdown>a img.logo { diff --git a/docs/api.rst b/docs/api.rst index 8c4f5d60e..0f710df5e 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -2,11 +2,6 @@ API === -.. contents:: Table of Contents - :depth: 1 - :local: - :backlinks: none - Indicators ========== diff --git a/docs/conf.py b/docs/conf.py index 80b7e05b4..e6686cfec 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -65,7 +65,7 @@ # Dump indicators to json. The json is added to the html output (html_extra_path) # It is read by _static/indsearch.js to populate the table in indicators.rst -with open("indicators.json", "w") as f: +with open("_dynamic/indicators.json", "w") as f: json.dump(indicators, f) @@ -104,7 +104,6 @@ "sphinx_codeautolink", "sphinx_copybutton", "sphinx_mdinclude", - "sphinx_rtd_theme", ] autodoc_typehints = "description" @@ -272,8 +271,9 @@ class XCStyle(AlphaStyle): "**.ipynb_checkpoints", ] -# The name of the Pygments (syntax highlighting) style to use. +# The name of the Pygments (syntax highlighting) style to use for light and dark themes. pygments_style = "sphinx" +pygments_dark_style = "monokai" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True @@ -283,31 +283,50 @@ class XCStyle(AlphaStyle): # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_title = "XClim Official Documentation" -html_short_title = "XClim" - -html_theme = "sphinx_rtd_theme" +html_title = "xclim Official Documentation" +html_short_title = "xclim" +html_theme = "furo" html_extra_path = ["indicators.json", "variables.json"] -# Theme options are theme-specific and customize the look and feel of a -# theme further. For a list of options available for each theme, see the -# documentation. -# -html_theme_options = {"logo_only": True, "style_external_links": True} +# Theme options are theme-specific and customize the look and feel of a theme further. +# For a list of options available for each theme, see the documentation. +html_theme_options = { + "light_logo": "xclim-logo-light.png", + "dark_logo": "xclim-logo-dark.png", + "footer_icons": [ + { + "name": "GitHub", + "url": "https://github.com/Ouranosinc/xclim", + "html": """ + + + + """, + "class": "", + }, + ], +} html_sidebars = { - "**": ["logo-text.html", "globaltoc.html", "localtoc.html", "searchbox.html"] + "**": [ + "sidebar/scroll-start.html", + "sidebar/brand.html", + "sidebar/search.html", + "sidebar/navigation.html", + "sidebar/ethical-ads.html", + "sidebar/scroll-end.html", + ] } # The name of an image file (relative to this directory) to place at the top # of the sidebar. -html_logo = "logos/xclim-logo.png" +# html_logo = "logos/xclim-logo.png" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] +html_static_path = ["_dynamic", "logos", "_static"] # -- Options for HTMLHelp output --------------------------------------- @@ -317,7 +336,7 @@ class XCStyle(AlphaStyle): # -- Options for LaTeX output ------------------------------------------ latex_engine = "pdflatex" -latex_logo = "logos/xclim-logo.png" +latex_logo = "logos/xclim-logo-light.png" latex_elements = { # The paper size ('letterpaper' or 'a4paper'). @@ -379,4 +398,4 @@ class XCStyle(AlphaStyle): def setup(app): - app.add_css_file("_static/style.css") + app.add_css_file("style.css") diff --git a/docs/logos/xclim-logo-dark.png b/docs/logos/xclim-logo-dark.png new file mode 100644 index 0000000000000000000000000000000000000000..f28ea80a3a2d73414d99891bfd4cab578258d338 GIT binary patch literal 8673 zcmeHLc{r49+n=$75!tmUW6EyK80(CkQH{{Vq$!fwXtIs5Qw*iTQ$56#h$-|?*|HT` zDoaR;q%0{?6p0cZ+jq}UPkrC}9pCXB-~0ae%yB#CzOM6}-*uk9>vx~`eT&08>=1)& zgn&RGG2Bk9BM1bR1^&>&Yk-*=R%s#d^&p%;40I%gKp9Lw54txE8W_f)L203M4-hD{ z#|Q5s{s6jm{=JMbU;UfJp(kbMgO6{Hx+1dIrAz88uI~2}<1>pVx0X+SwuGW0 z{Jy7GuS}%FCcM+eG!A|N4<_kZZN2#<{!n^YEn|J~-Z|>CS8l`tK~lmq-|b5hjpueY zeAqs?9jdv_aOAnOR>y}sv9yGJdM+f151)=*?3-~73io=x?X+j_NMWi1~G~M~YLZRVMr>%`f zj7RR^?^iG{ZEO_0WaIHl&mj4ji{~OO&!61Z(6EOAH<~Rb1~L4fcir17Az*HizBygy zV0Qhoa;%)r7KNFi{_3WFW0se*Y#T%wWM9!{r=k9K>W0;KK5{iWV2FJV~Qx#ik+6MF?G{mWB#(wj7f;Ee~$3Q8xM-PWs*Xtvt@fsU7v zD;ALCqdwbXDQhrT`XQV6@JVDxllkDEHq7R?*DaKq_>Me*-ia(SpY6}zn||qQ5)8+A z-{5c7$oj1PSX|;5YMT=? z2WnqH6nND>k~UTM1pcJr-SqQUO{4t3=M;1p*4caqJ2LhRxhcZYMFIpg!O!K7sn!+ZkYGF`1 z)fBc*-yUhtu%;cR?+juDq5Hlg%j6wC|)HDOXcFpk*ms}R7*6m~c;kbyxU z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z(tp%!cFH7Sswk_|_1o9M$@Ec!cgD{AwnU*)Q75mrgW|iVjx^v^l85|0uHWW9XaJ(a z<5CHZGKPK^%=vLOmXkRThtHS|+>k||vl{!7Zm&_0@$q%PjClCx$}K>)E{152Xo7 zvj$A@P#7Mk!0)cqg4XDdoO%(Pc@v}!TgNuP%<2%+!VRcMhOt_X)`*yY{Gw^6i9LIz zBjGsHtm4gJX~(GiUddtclIFWNfTDVg@EY`MX_X~-_L!)0ObaL>Y@S|O`8FE_v zeHGi>o2L{+Iw4_Y3!@F1J_ibW`tPIU*T0(@$es-KoEP(YeMPtH!nEe0jY18dKNmd? zc7HT|;39j&TCJ&Gn{T@>6#9d{)^{G@+%hJY5`UYqWKt+S%n qpKr0uy=C-bP7Nga@A^!aFZ0!@U04^t#U9Q5HwVtf0b5|@9`j$u!KlLk literal 0 HcmV?d00001 diff --git a/docs/logos/xclim-logo.png b/docs/logos/xclim-logo-light.png similarity index 100% rename from docs/logos/xclim-logo.png rename to docs/logos/xclim-logo-light.png diff --git a/environment.yml b/environment.yml index 3e01a4cbc..f8c105f00 100644 --- a/environment.yml +++ b/environment.yml @@ -40,6 +40,7 @@ dependencies: - flake8 - flake8-rst-docstrings - flit + - furo >=2023.9.10 - h5netcdf - ipykernel - ipython @@ -68,7 +69,6 @@ dependencies: - sphinx-codeautolink - sphinx-copybutton - sphinx-mdinclude - - sphinx-rtd-theme >=1.0 - sphinxcontrib-bibtex - tokenize-rt - tox >=4.0 diff --git a/pyproject.toml b/pyproject.toml index bae56026c..73169787e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,6 +89,7 @@ dev = [ "yamllint", # Documentation and examples "distributed >=2.0", + "furo >=2023.9.10", "ipykernel", "matplotlib", "nbsphinx", @@ -99,7 +100,6 @@ dev = [ "sphinx-codeautolink", "sphinx-copybutton", "sphinx-mdinclude", - "sphinx-rtd-theme >=1.0", "sphinxcontrib-bibtex", "sphinxcontrib-svg2pdfconverter[Cairosvg]" ] From a1b0b27101a7a84a3671cd7ae151f8f1e19d47df Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:48:57 -0400 Subject: [PATCH 05/35] make dirs --- docs/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/conf.py b/docs/conf.py index e6686cfec..32d338c14 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -65,6 +65,7 @@ # Dump indicators to json. The json is added to the html output (html_extra_path) # It is read by _static/indsearch.js to populate the table in indicators.rst +os.makedirs("_dynamic", exist_ok=True) with open("_dynamic/indicators.json", "w") as f: json.dump(indicators, f) From a71e67203f09bdda8f277948418e7c36240b481d Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 25 Apr 2024 15:02:48 -0400 Subject: [PATCH 06/35] remove redundant file --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 32d338c14..223dc1241 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -288,7 +288,7 @@ class XCStyle(AlphaStyle): html_short_title = "xclim" html_theme = "furo" -html_extra_path = ["indicators.json", "variables.json"] +html_extra_path = ["variables.json"] # Theme options are theme-specific and customize the look and feel of a theme further. # For a list of options available for each theme, see the documentation. From 1c7cd641279e447c22977f80c1d3edb5f9239092 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 25 Apr 2024 16:05:34 -0400 Subject: [PATCH 07/35] synchronize dependencies --- .pre-commit-config.yaml | 6 +++--- Makefile | 2 +- environment.yml | 5 +++-- pyproject.toml | 10 +++++----- tox.ini | 12 ++++++------ 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1cd37f8a9..6d9f2ce7d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,7 +33,7 @@ repos: - id: yamllint args: [ '--config-file=.yamllint.yaml' ] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.4.0 + rev: 24.4.1 hooks: - id: black - repo: https://github.com/PyCQA/isort @@ -66,7 +66,7 @@ repos: args: [ '--py39-plus' ] additional_dependencies: [ 'pyupgrade==3.15.2' ] - id: nbqa-black - additional_dependencies: [ 'black==24.4.0' ] + additional_dependencies: [ 'black==24.4.1' ] - id: nbqa-isort additional_dependencies: [ 'isort==5.13.2' ] - repo: https://github.com/kynan/nbstripout @@ -79,7 +79,7 @@ repos: rev: v0.3.9 hooks: - id: blackdoc - additional_dependencies: [ 'black==24.4.0' ] + additional_dependencies: [ 'black==24.4.1' ] exclude: '(xclim/indices/__init__.py|docs/installation.rst)' - repo: https://github.com/codespell-project/codespell rev: v2.2.6 diff --git a/Makefile b/Makefile index d7f585984..379c3c1f5 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ clean-test: ## remove test and coverage artifacts lint: ## check style with flake8 and black black --check xclim tests isort --check xclim tests - ruff xclim tests + ruff check xclim tests flake8 --config=.flake8 xclim tests vulture xclim tests nbqa black --check docs diff --git a/environment.yml b/environment.yml index f8c105f00..ecf456048 100644 --- a/environment.yml +++ b/environment.yml @@ -29,7 +29,7 @@ dependencies: - flox - lmoments3 # Required for some Jupyter notebooks # Testing and development dependencies - - black ==24.1.1 + - black ==24.4.1 - blackdoc ==0.3.9 - bump-my-version >=0.17.1 - cairosvg @@ -63,7 +63,7 @@ dependencies: - pytest-cov - pytest-socket - pytest-xdist >=3.2 - - ruff >=0.2.0 + - ruff >=0.3.0 - sphinx - sphinx-autodoc-typehints - sphinx-codeautolink @@ -73,6 +73,7 @@ dependencies: - tokenize-rt - tox >=4.0 # - tox-conda # Will be added when a tox@v4.0+ compatible plugin is released. + - vulture ==2.11 - xdoctest - yamllint - pip diff --git a/pyproject.toml b/pyproject.toml index 73169787e..0bace0adb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ dependencies = [ [project.optional-dependencies] dev = [ # Dev tools and testing - "black ==24.4.1", + "black[jupyter] ==24.4.1", "blackdoc ==0.3.9", "bump-my-version >=0.17.1", "codespell", @@ -79,14 +79,14 @@ dev = [ "pytest-cov", "pytest-socket", "pytest-xdist[psutil] >=3.2", - "ruff >=0.2.0", + "ruff >=0.3.0", "tokenize-rt", - "tox >=4.0", + "tox >=4.5", # "tox-conda", # Will be added when a tox@v4.0+ compatible plugin is released. "tox-gh >=1.3.1", - "vulture", + "vulture ==2.11", "xdoctest", - "yamllint", + "yamllint==1.35.1", # Documentation and examples "distributed >=2.0", "furo >=2023.9.10", diff --git a/tox.ini b/tox.ini index cd55e0533..5bdf4d89e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -min_version = 4.0 +min_version = 4.5 env_list = lint docs @@ -32,18 +32,18 @@ deps = flake8 flake8-alphabetize flake8-rst-docstrings - black[jupyter]==24.1.0 + black[jupyter]==24.4.1 blackdoc==0.3.9 isort==5.13.2 nbqa - ruff>=0.1.0 - vulture - yamllint + ruff==0.3.0 + vulture==2.11 + yamllint==1.35.1 commands_pre = commands = black --check xclim tests isort --check xclim tests - ruff xclim tests + ruff check xclim tests flake8 --config=.flake8 xclim tests vulture xclim tests nbqa black --check docs From d89bda209e872d23e1ffdb7be6c6d9ef6db8f2b5 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 25 Apr 2024 16:37:59 -0400 Subject: [PATCH 08/35] unpin vulture conda package --- environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index ecf456048..11538bf23 100644 --- a/environment.yml +++ b/environment.yml @@ -73,7 +73,7 @@ dependencies: - tokenize-rt - tox >=4.0 # - tox-conda # Will be added when a tox@v4.0+ compatible plugin is released. - - vulture ==2.11 + - vulture # ==2.11 # The conda-forge version is out of date. - xdoctest - yamllint - pip From 99871066d61de17c60ff08e43461a2f0615466b9 Mon Sep 17 00:00:00 2001 From: Pascal Bourgault Date: Fri, 26 Apr 2024 13:51:10 -0400 Subject: [PATCH 09/35] Fix minisearch injection --- docs/_static/indsearch.js | 2 +- docs/_templates/{layout.html => base.html} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename docs/_templates/{layout.html => base.html} (92%) diff --git a/docs/_static/indsearch.js b/docs/_static/indsearch.js index 6ec3dcdd9..ef8d826a7 100644 --- a/docs/_static/indsearch.js +++ b/docs/_static/indsearch.js @@ -26,7 +26,7 @@ let miniSearch = new MiniSearch({ }); // Populate search object with complete list of indicators -fetch('indicators.json') +fetch('_static/indicators.json') .then(data => data.json()) .then(data => { indicators = Object.entries(data).map(([k, v]) => { diff --git a/docs/_templates/layout.html b/docs/_templates/base.html similarity index 92% rename from docs/_templates/layout.html rename to docs/_templates/base.html index 00954b22d..498bbd45b 100644 --- a/docs/_templates/layout.html +++ b/docs/_templates/base.html @@ -1,4 +1,4 @@ -{% extends "!layout.html" %} +{% extends "!base.html" %} {% set css_files = css_files + ["_static/style.css"] %} -{% block scripts %} +{% block site_meta %} {% if "indicators" in sourcename %} From 13d2af4425265913978ac5b0ee8daaa3b74b9d39 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 29 Apr 2024 13:24:32 -0400 Subject: [PATCH 10/35] modify servedocs to use sphinx-autobuild, add sphinx-autobuild to dependencies --- Makefile | 4 ++-- docs/Makefile | 7 +++++-- environment.yml | 1 + pyproject.toml | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 379c3c1f5..f01f59948 100644 --- a/Makefile +++ b/Makefile @@ -101,8 +101,8 @@ ifndef READTHEDOCS python -m http.server 54345 --directory docs/_build/html/ endif -servedocs: docs ## compile the docs watching for changes - watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . +servedocs: autodoc-custom-index ## generate Sphinx HTML documentation, including API docs, but without indexes for for indices and indicators, and watch for changes + $(MAKE) -C docs livehtml release: dist ## package and upload a release flit publish dist/* diff --git a/docs/Makefile b/docs/Makefile index 44a51e3b1..f00c6ead7 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -2,8 +2,8 @@ # # You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = python -msphinx +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build SPHINXPROJ = xclim SOURCEDIR = . BUILDDIR = _build @@ -18,3 +18,6 @@ help: # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +livehtml: + sphinx-autobuild --port 54345 --open-browser --delay 2 --re-ignore "$(BUILDDIR)|apidoc|_dynamic/indicators.json|variables.json|__pycache__" "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/environment.yml b/environment.yml index 11538bf23..1e02c04a4 100644 --- a/environment.yml +++ b/environment.yml @@ -65,6 +65,7 @@ dependencies: - pytest-xdist >=3.2 - ruff >=0.3.0 - sphinx + - sphinx-autobuild >=2024.4.16 - sphinx-autodoc-typehints - sphinx-codeautolink - sphinx-copybutton diff --git a/pyproject.toml b/pyproject.toml index fbb5e86de..b143cfa55 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -96,6 +96,7 @@ dev = [ "nc-time-axis", "pooch", "sphinx", + "sphinx-autobuild >=2024.4.16", "sphinx-autodoc-typehints", "sphinx-codeautolink", "sphinx-copybutton", From 4d505207db103ade0c0e0370d404c38dbdf8b998 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 29 Apr 2024 13:24:49 -0400 Subject: [PATCH 11/35] add noqa for long docstring --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 223dc1241..1ea3d5550 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -303,7 +303,7 @@ class XCStyle(AlphaStyle): - """, + """, # noqa: E501 "class": "", }, ], From 38a1e8aaf641b9f90488c53d0c8380e1aae27872 Mon Sep 17 00:00:00 2001 From: Sarah G <91751417+sg2475962@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:16:46 -0400 Subject: [PATCH 12/35] Fix docs wrong icon, tables --- README.rst | 17 ++++- docs/_static/style.css | 61 +++++++++++++++++- docs/logos/empty.png | Bin 0 -> 563 bytes docs/logos/xclim-logo-small-dark.png | Bin 0 -> 7066 bytes ...o-small.png => xclim-logo-small-light.png} | Bin 5 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 docs/logos/empty.png create mode 100644 docs/logos/xclim-logo-small-dark.png rename docs/logos/{xclim-logo-small.png => xclim-logo-small-light.png} (100%) diff --git a/README.rst b/README.rst index 03e6045a3..fa39d419f 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,6 @@ -====================================== -xclim: Climate services library |logo| -====================================== +=============================================================== +xclim: Climate services library |logo| |logo-dark| |logo-light| +=============================================================== +----------------------------+-----------------------------------------------------+ | Versions | |pypi| |conda| |versions| | @@ -187,6 +187,17 @@ This package was created with Cookiecutter_ and the `audreyfeldroy/cookiecutter- .. |logo| image:: https://raw.githubusercontent.com/Ouranosinc/xclim/main/docs/logos/xclim-logo-small.png :target: https://github.com/Ouranosinc/xclim :alt: Xclim + :class: xclim-logo-small no-theme + +.. |logo-light| image:: logos/empty.png + :target: https://github.com/Ouranosinc/xclim + :alt: + :class: xclim-logo-small only-light-inline + +.. |logo-dark| image:: logos/empty.png + :target: https://github.com/Ouranosinc/xclim + :alt: + :class: xclim-logo-small only-dark-inline .. |pre-commit| image:: https://results.pre-commit.ci/badge/github/Ouranosinc/xclim/main.svg :target: https://results.pre-commit.ci/latest/github/Ouranosinc/xclim/main diff --git a/docs/_static/style.css b/docs/_static/style.css index abe960f45..81d0b7332 100644 --- a/docs/_static/style.css +++ b/docs/_static/style.css @@ -38,7 +38,7 @@ td.name { } tr:nth-child(even) { - background-color: #dddddd; + background-color: var(--color-foreground-border); } dd { @@ -99,6 +99,63 @@ code > .indName { background-color: #ddd; } -#incVirtModLbl { +#incVirtModLbl { display: inline; } + +/* extend furo for inline ".only-dark" elements */ +body .only-dark-inline, +body .only-light-inline { + display: none !important; +} + +body[data-theme="dark"] .only-dark-inline, +body[data-theme="light"] .only-light-inline { + display: inline !important; +} +@media not print { + body[data-theme="dark"] .only-dark-inline, + body[data-theme="light"] .only-light-inline { + display: inline !important; + } + @media (prefers-color-scheme: dark) { + body:not([data-theme="light"]) .only-dark-inline{ + display: inline !important; + } + } + @media (prefers-color-scheme: light) { + body:not([data-theme="dark"]) .only-light-inline{ + display: inline !important; + } + } +} + +img.xclim-logo-small.only-dark-inline { + width: 91px; + height: 103px; + margin: 0; + padding: 0; + background-color: transparent; + background-repeat: no-repeat; + border-image-width: 0px; + border: none; + border-image-width: 0px; + background-image: url("xclim-logo-small-dark.png"); +} + +img.xclim-logo-small.only-light-inline { + width: 91px; + height: 103px; + margin: 0; + padding: 0; + background-color: transparent; + background-repeat: no-repeat; + border: none; + border-image-width: 0px; + background-image: url("xclim-logo-small-light.png"); +} + +img.xclim-logo-small.no-theme { + display: none; + width: 0px; +} \ No newline at end of file diff --git a/docs/logos/empty.png b/docs/logos/empty.png new file mode 100644 index 0000000000000000000000000000000000000000..fd9b503f88a308581286dfd0501184cd802c95c9 GIT binary patch literal 563 zcmV-30?hr1P)EX>4Tx04R}tkv&MmKpe$iKcpfRK|6>jWT?7W5EXIMDionYs1;guFuC*#nlvOS zE{=k0!NHHks)LKOt`4q(Aou~|?BJy6A|?JWDYS_3;J6>}?mh0_0seZKsb+8-P&La) zCE`LRyDEfU5yTLB0gOt_)aOJo3D5C$4FbDicO5?I6%LkMG0kCh|#K%Vj@NRaS#81;}^*#ldA+q zjs;YpLUR1zfAG6oGe0@uCWYfb$BS)$3wo|N02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{000X~L_t&t*JEG+0ssI700H7A1)Bf>002ovPDHLkV1kr! B-HQMK literal 0 HcmV?d00001 diff --git a/docs/logos/xclim-logo-small-dark.png b/docs/logos/xclim-logo-small-dark.png new file mode 100644 index 0000000000000000000000000000000000000000..fadaa2a7603eb6a73399b3d9ee782b1780101522 GIT binary patch literal 7066 zcmeHKc{r5&+kcED#*r;5TBb3SG-Hgx%rMp&OV%Tiip=sD6JwYe#-7MAsT_NYEEQTT zNup$JlXQ+0MTkz6EUAd1@;=n*)b;+Z>%Go(y}$pOx#oH1doQ2weShxz{?0u6U7T#> z;A(IH0Oag!DX!3c2lQb{OF>s|vZ*t4YmRW+CUB(*5kWkzFFOE42*QIv1Q^El1%R-} z9G4wSuVba>+O$LWN!*TqR^Y#WT*~D7Qmv$WCgx<$i)~gyJ#w$ikQODm z+T1^R!rAFpE$6|TmjtDWu3m_Y6{+KolV&E~307g-gr8w{jn zMNMjrV!BL=Turo&D(BtD1n__d-k7HF=wk;+#fFnwsgIO*cI~mUvhwM8y(} z3EDNb`{(W9Xu1jERkLs=x;J{sdw5WmMTPt)>yyh*7AWK?|E?ym_{*lO z71I!mA&k8^s;H53Oe0xAHbFIO#}O5|%&;`Vxie}*bNU#a|IPhy5F;*1zm5QYFJ`s`efjEz+70J8Wz| zk&aoJrXlG!I~hLk>0rIK>{Ksob#Wl~Q1o$AfIYG?Tzu6kn1q(65)mpwHj zzW*ApypNQf4fS3a8|txbjt(RSmxG}(xpWW{#tDL&4**Qe!h&cFe^7v+gDiF+898ya z0f}HU$w&_aN33Iz73jydjo^V>BAnb95&jG!6KQ4&Hwhy_031+2Lxgbx0{NscGI9}@ z1btr+>mm`0CIWvla+{+I!iviS5qJz9gGE!r*r7P2DI8(KWBQU@Db`;hpcNVEClCaY zbajP7Ax5Z=;qq9zdPE{o7mL%y;n0u;njao0poO6W`5FrlUoa>jpTT1X3E12~!~!Ob z&J7Wekw{37_&YvMkfY-__(1+w79c)!!)QUedKj!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I=6 z8u126x^R=LVv1Fi`#H$CyCxs|>sj&`D$!cT92)P#;soVJ;$D^!3Rwh|J5OeS04%S( zYKw_cYE4{8*_3BPNh$+2o+6ZV&#FcB%WrmylAh@VC5^9HgRgVh$b|B9i7SaDrAvR ze;}j%x8@WsQ&~yjDYpo1V~VBc>rws4l_@4?&1XSW|KNO2K$-^W=%F#>2k&)Q)V#%8 zuQbQ-`)l0ZsTDq%K@vSL>GY_kt;$HRKE_NNe7LG#1(lc}7j+O`A3sRTdA|~s_iO#5 zAv?32!5+^{Ia^aIkN@xz8O42x91BS(ib1X2!fsA6$r!vx$^-U z;q=_7J#OLdsraM~FDiF7DA3XegL5*xPDSDJ%9TlP47O%_4*xa`GxL({w|lD)!pW|g z9)*SD44qE(mix??iYjpN&+X@w5=ZFui28d)G02KljgCNsSXX{c#yUXtz-`Cyjr`s2 zPd1oX)t5`>8Fh?CDYE+$C(Jti=UxA}$dxDu8Wn+o3ZK`O@39`vf`4;pqHmH$0OCGD0bKLGY_#hs^-h> zFjmd_2QjgBz-}=U3a)=GjC{g-iARLzlX0K)+BK{Db;_10+EAXuE<0+^95wO!a|htv zIx@=WqQ;r7XWdZB-S}o^?ckh2vO0$BvS(9dzx+=!yn)@y)_}OF< z`YF}$FPDhD+myYd!?C4`3Tzka5bNsbUaHX_JTMN*9S{2GIX^I|URk$Z?f%=4xXQCG^O`;BqgQ2(CmbZ4=uvImdAE}VYxrvG^N z0d1Zn@q)tKq*3~&uOtnwK8eAqvRTaa@&a*}U9w2Nl ztu?i1HbaqReR4&WAxe?B*om{w&l-Rdsn=&jm8pVz!5Or@qLQ{2;fZ4w=-x+qOVX4( zVjCPN567<0&{c%{MYW Date: Mon, 29 Apr 2024 18:17:40 +0000 Subject: [PATCH 13/35] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- README.rst | 2 +- docs/_static/style.css | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index fa39d419f..423f91f7a 100644 --- a/README.rst +++ b/README.rst @@ -193,7 +193,7 @@ This package was created with Cookiecutter_ and the `audreyfeldroy/cookiecutter- :target: https://github.com/Ouranosinc/xclim :alt: :class: xclim-logo-small only-light-inline - + .. |logo-dark| image:: logos/empty.png :target: https://github.com/Ouranosinc/xclim :alt: diff --git a/docs/_static/style.css b/docs/_static/style.css index 81d0b7332..34cbc1c19 100644 --- a/docs/_static/style.css +++ b/docs/_static/style.css @@ -99,7 +99,7 @@ code > .indName { background-color: #ddd; } -#incVirtModLbl { +#incVirtModLbl { display: inline; } @@ -158,4 +158,4 @@ img.xclim-logo-small.only-light-inline { img.xclim-logo-small.no-theme { display: none; width: 0px; -} \ No newline at end of file +} From 73787dbe0cc074cb1488e2ecd2d33f68930dcad1 Mon Sep 17 00:00:00 2001 From: Sarah G <91751417+sg2475962@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:21:22 -0400 Subject: [PATCH 14/35] fix copybutton --- docs/_static/style.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/_static/style.css b/docs/_static/style.css index 81d0b7332..630fa458d 100644 --- a/docs/_static/style.css +++ b/docs/_static/style.css @@ -158,4 +158,8 @@ img.xclim-logo-small.only-light-inline { img.xclim-logo-small.no-theme { display: none; width: 0px; +} + +button.copybtn svg { + stroke: var(--color-content-foreground); } \ No newline at end of file From cf4865a4646d58dd78fae98d9a999299f7914c74 Mon Sep 17 00:00:00 2001 From: Sarah G <91751417+sg2475962@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:26:16 -0400 Subject: [PATCH 15/35] tables were too dark --- docs/_static/style.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/_static/style.css b/docs/_static/style.css index 69dc36e79..94c5a8448 100644 --- a/docs/_static/style.css +++ b/docs/_static/style.css @@ -38,7 +38,7 @@ td.name { } tr:nth-child(even) { - background-color: var(--color-foreground-border); + background-color: var(--color-table-border); } dd { @@ -160,6 +160,6 @@ img.xclim-logo-small.no-theme { width: 0px; } -button.copybtn svg { +button.copybtn.copybtn svg { stroke: var(--color-content-foreground); } From 58ac2d9775f821217f6736781e426af59e734277 Mon Sep 17 00:00:00 2001 From: Sarah G <91751417+sg2475962@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:34:27 -0400 Subject: [PATCH 16/35] fix svg background --- docs/notebooks/Indicator.svg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/notebooks/Indicator.svg b/docs/notebooks/Indicator.svg index 742b663f3..619cb7c16 100644 --- a/docs/notebooks/Indicator.svg +++ b/docs/notebooks/Indicator.svg @@ -160,7 +160,9 @@ - + + + From 045dab50bfaa7775c1295f8599db88ad6b9ae96a Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 29 Apr 2024 15:19:21 -0400 Subject: [PATCH 17/35] change pygments style to higher contrast `sas` and `lightbulb` themes for better accessibility --- docs/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 1ea3d5550..cb4cd97a0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -273,8 +273,8 @@ class XCStyle(AlphaStyle): ] # The name of the Pygments (syntax highlighting) style to use for light and dark themes. -pygments_style = "sphinx" -pygments_dark_style = "monokai" +pygments_style = "sas" +pygments_dark_style = "lightbulb" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True From 6a1c49422d69befbfdb93261226c8608122bb890 Mon Sep 17 00:00:00 2001 From: Sarah G <91751417+sg2475962@users.noreply.github.com> Date: Mon, 29 Apr 2024 15:52:11 -0400 Subject: [PATCH 18/35] use conf.py variables, deal with print --- README.rst | 2 +- docs/_static/style.css | 17 +++++++++++------ docs/conf.py | 8 ++++++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 423f91f7a..262f5c322 100644 --- a/README.rst +++ b/README.rst @@ -184,7 +184,7 @@ This package was created with Cookiecutter_ and the `audreyfeldroy/cookiecutter- :target: https://github.com/psf/black :alt: Python Black -.. |logo| image:: https://raw.githubusercontent.com/Ouranosinc/xclim/main/docs/logos/xclim-logo-small.png +.. |logo| image:: https://raw.githubusercontent.com/Ouranosinc/xclim/main/docs/logos/xclim-logo-small-light.png :target: https://github.com/Ouranosinc/xclim :alt: Xclim :class: xclim-logo-small no-theme diff --git a/docs/_static/style.css b/docs/_static/style.css index 94c5a8448..81dd45ecb 100644 --- a/docs/_static/style.css +++ b/docs/_static/style.css @@ -38,7 +38,7 @@ td.name { } tr:nth-child(even) { - background-color: var(--color-table-border); + background-color: var(--color-table-rows-even); } dd { @@ -109,10 +109,6 @@ body .only-light-inline { display: none !important; } -body[data-theme="dark"] .only-dark-inline, -body[data-theme="light"] .only-light-inline { - display: inline !important; -} @media not print { body[data-theme="dark"] .only-dark-inline, body[data-theme="light"] .only-light-inline { @@ -130,6 +126,15 @@ body[data-theme="light"] .only-light-inline { } } +@media print { + .only-light-inline{ + display: inline !important; + } + .only-dark-inline{ + display: none !important; + } +} + img.xclim-logo-small.only-dark-inline { width: 91px; height: 103px; @@ -161,5 +166,5 @@ img.xclim-logo-small.no-theme { } button.copybtn.copybtn svg { - stroke: var(--color-content-foreground); + stroke: var(--color-copybutton); } diff --git a/docs/conf.py b/docs/conf.py index cb4cd97a0..73cf4d303 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -307,6 +307,14 @@ class XCStyle(AlphaStyle): "class": "", }, ], + "light_css_variables": { + "color-table-rows-even": "#eeebee", + "color-copybutton": "#000" + }, + "dark_css_variables": { + "color-table-rows-even": "#303335", + "color-copybutton": "#fff" + }, } html_sidebars = { From f792b555a330c0fe4a5c8e3f1e5127006a299eb3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 19:53:07 +0000 Subject: [PATCH 19/35] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 73cf4d303..bdf9e97ed 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -309,11 +309,11 @@ class XCStyle(AlphaStyle): ], "light_css_variables": { "color-table-rows-even": "#eeebee", - "color-copybutton": "#000" + "color-copybutton": "#000", }, "dark_css_variables": { "color-table-rows-even": "#303335", - "color-copybutton": "#fff" + "color-copybutton": "#fff", }, } From 71a10f1f9f0a7c37c0f7cd2f4c4d065c1f30a786 Mon Sep 17 00:00:00 2001 From: Sarah G <91751417+sg2475962@users.noreply.github.com> Date: Mon, 29 Apr 2024 16:25:52 -0400 Subject: [PATCH 20/35] re-style indicators --- docs/_static/indsearch.js | 2 +- docs/_static/style.css | 19 ++++++++++++++++--- docs/conf.py | 8 ++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/docs/_static/indsearch.js b/docs/_static/indsearch.js index ef8d826a7..5efdfe267 100644 --- a/docs/_static/indsearch.js +++ b/docs/_static/indsearch.js @@ -68,7 +68,7 @@ function makeVariableList(ind) { /* kv[0] is the variable name, kv[1] is the variable description. */ /* Convert kv[1] to a string literal */ const text = escapeHTML(kv[1]); - const tooltip = ``; + const tooltip = ``; return tooltip }).join(''); } diff --git a/docs/_static/style.css b/docs/_static/style.css index 81dd45ecb..4670bd728 100644 --- a/docs/_static/style.css +++ b/docs/_static/style.css @@ -75,7 +75,8 @@ ul.simple li { .indElem { margin: 10px; padding: 10px; - background-color: #ddd; + background-color: var(--color-indicator-background); + color: var(--color-indicator-text); border-radius: 10px; } @@ -84,11 +85,19 @@ ul.simple li { } code > .indName { - background-color: #ccc; + background-color: var(--color-indicator-background); + color: var(--color-indicator-text); } .indVarname { border-radius: 10px; + background-color: var(--color-indicator-widget-background); + color: var(--color-indicator-widget-text); + border: solid 1px var(--color-indicator-widget-text); + margin-right: 3px; + margin-bottom: 3px; + line-height: 24px; + cursor: help; } /* Rounded corners for keyword labels: */ @@ -96,7 +105,11 @@ code > .indName { border-radius: 10px; padding: 5px; margin: 5px; - background-color: #ddd; + background-color: var(--color-indicator-widget-background); + color: var(--color-indicator-widget-text); + border: solid 1px var(--color-indicator-widget-text); + line-height: 24px; + } #incVirtModLbl { diff --git a/docs/conf.py b/docs/conf.py index bdf9e97ed..7217df013 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -310,10 +310,18 @@ class XCStyle(AlphaStyle): "light_css_variables": { "color-table-rows-even": "#eeebee", "color-copybutton": "#000", + "color-indicator-text": "#5a5c63", + "color-indicator-background": "#eeebee", + "color-indicator-widget-text": "#2f2f2f", + "color-indicator-widget-background": "#bdbdbd", }, "dark_css_variables": { "color-table-rows-even": "#303335", "color-copybutton": "#fff", + "color-indicator-text": "#cfd0d0", + "color-indicator-background": "#3e3e3e", + "color-indicator-widget-text": "#a8a8a8", + "color-indicator-widget-background": "#303335", }, } From add1cfd738123b9a11e2f082e7a6d441089bb261 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 1 May 2024 11:46:53 -0400 Subject: [PATCH 21/35] code theming improvements and adjustments --- docs/notebooks/example.ipynb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/notebooks/example.ipynb b/docs/notebooks/example.ipynb index 26d8f0b9b..cb237befd 100644 --- a/docs/notebooks/example.ipynb +++ b/docs/notebooks/example.ipynb @@ -138,7 +138,7 @@ " chunks={\"time\": 365, \"lat\": 168, \"lon\": 150},\n", " drop_variables=[\"ts\", \"time_vectors\"],\n", ")\n", - "print(ds)" + "ds" ] }, { @@ -195,7 +195,7 @@ "outputs": [], "source": [ "ds2 = ds.sel(lat=slice(50, 45), lon=slice(-70, -65), time=slice(\"2090\", \"2100\"))\n", - "print(ds2.tasmin)" + "ds2.tasmin" ] }, { @@ -205,7 +205,7 @@ "outputs": [], "source": [ "ds3 = ds.sel(lat=46.8, lon=-71.22, method=\"nearest\").sel(time=\"1993\")\n", - "print(ds3.tasmin)" + "ds3.tasmin" ] }, { @@ -259,7 +259,7 @@ "outputs": [], "source": [ "out = xclim.atmos.tx_max(ds2.tasmax, freq=\"YS\")\n", - "print(out)" + "out" ] }, { @@ -294,7 +294,7 @@ "outputs": [], "source": [ "out = xclim.indices.tx_days_above(ds2.tasmax, thresh=\"30 degC\", freq=\"YS\")\n", - "print(out)" + "out" ] }, { @@ -315,7 +315,7 @@ "outputs": [], "source": [ "out = xclim.atmos.tx_days_above(ds2.tasmax, thresh=\"30 degC\", freq=\"YS\")\n", - "print(out)" + "out" ] }, { @@ -331,7 +331,7 @@ "\n", "# Add our climate index as a data variable to the dataset\n", "ds_out[out.name] = out\n", - "print(ds_out)" + "ds_out" ] }, { @@ -462,7 +462,7 @@ "source": [ "%%time\n", "output_file = output_folder / \"test_tx_max.nc\"\n", - "dsOut.to_netcdf(output_file)" + "ds_out.to_netcdf(output_file)" ] }, { From 853634ec80e1646792e8162d519dfa2fdb0f9b81 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 1 May 2024 11:47:10 -0400 Subject: [PATCH 22/35] code theming improvements and adjustments --- docs/notebooks/extendxclim.ipynb | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/docs/notebooks/extendxclim.ipynb b/docs/notebooks/extendxclim.ipynb index e046a92a2..f1fccf5e4 100644 --- a/docs/notebooks/extendxclim.ipynb +++ b/docs/notebooks/extendxclim.ipynb @@ -96,6 +96,7 @@ "from __future__ import annotations\n", "\n", "import xarray as xr\n", + "from IPython.display import Code, display\n", "\n", "import xclim\n", "from xclim.core.units import convert_units_to, declare_units\n", @@ -325,14 +326,6 @@ }, "outputs": [], "source": [ - "from pathlib import Path\n", - "\n", - "from pygments import highlight\n", - "\n", - "# Workaround absence of syntax highlighting in notebooks\n", - "from pygments.formatters import Terminal256Formatter\n", - "from pygments.lexers import JsonLexer, PythonLexer, YamlLexer\n", - "\n", "example_dir = notebook_folder / \"example\"\n", "\n", "with open(example_dir / \"example.py\") as f:\n", @@ -342,11 +335,7 @@ " ymldata = f.read()\n", "\n", "with open(example_dir / \"example.fr.json\") as f:\n", - " jsondata = f.read()\n", - "\n", - "highlighted_py = highlight(pydata, PythonLexer(), Terminal256Formatter(style=\"manni\"))\n", - "highlighted_yaml = highlight(ymldata, YamlLexer(), Terminal256Formatter(style=\"manni\"))\n", - "highlighted_json = highlight(jsondata, JsonLexer(), Terminal256Formatter(style=\"manni\"))" + " jsondata = f.read()" ] }, { @@ -357,11 +346,11 @@ "source": [ "# These variables were generated by a hidden cell above that syntax-colored them.\n", "print(\"Content of example.py :\")\n", - "print(highlighted_py)\n", + "display(Code(pydata, language=\"python\"))\n", "print(\"\\n\\nContent of example.yml :\")\n", - "print(highlighted_yaml)\n", + "display(Code(ymldata, language=\"yaml\"))\n", "print(\"\\n\\nContent of example.fr.json :\")\n", - "print(highlighted_json)" + "display(Code(jsondata, language=\"json\"))" ] }, { @@ -540,7 +529,6 @@ "outputs": [], "source": [ "from xclim.core.indicator import build_indicator_module, registry\n", - "from xclim.core.utils import wrapped_partial\n", "\n", "mapping = dict(\n", " egg_cooking_season=registry[\"MAXIMUM_CONSECUTIVE_WARM_DAYS\"](\n", From 8623526186b8a24732170bb3030ffb66f5b6d769 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 1 May 2024 13:06:07 -0400 Subject: [PATCH 23/35] fix docstring and warning message length --- xclim/core/indicator.py | 97 ++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 44 deletions(-) diff --git a/xclim/core/indicator.py b/xclim/core/indicator.py index 6eacdb45c..60e587c86 100644 --- a/xclim/core/indicator.py +++ b/xclim/core/indicator.py @@ -1169,8 +1169,8 @@ def json(self, args=None): Parameters ---------- args : mapping, optional - Arguments as passed to the call method of the indicator. - If not given, the default arguments will be used when formatting the attributes. + Arguments as passed to the call method of the indicator. + If not given, the default arguments will be used when formatting the attributes. Notes ----- @@ -1215,11 +1215,11 @@ def _format( Parameters ---------- attrs : dict - Attributes containing tags to replace with arguments' values. + Attributes containing tags to replace with arguments' values. args : dict, optional - Function call arguments. If not given, the default arguments will be used when formatting the attributes. + Function call arguments. If not given, the default arguments will be used when formatting the attributes. formatter : AttrFormatter - Plaintext mappings for indicator attributes. + Plaintext mappings for indicator attributes. Returns ------- @@ -1387,10 +1387,12 @@ class CheckMissingIndicator(Indicator): Parameters ---------- missing : {any, wmo, pct, at_least_n, skip, from_context} - The name of the missing value method. See `xclim.core.missing.MissingBase` to create new custom methods. If - None, this will be determined by the global configuration (see `xclim.set_options`). Defaults to "from_context". + The name of the missing value method. See `xclim.core.missing.MissingBase` to create new custom methods. + If None, this will be determined by the global configuration (see `xclim.set_options`). + Defaults to "from_context". missing_options : dict, optional - Arguments to pass to the `missing` function. If None, this will be determined by the global configuration. + Arguments to pass to the `missing` function. + If None, this will be determined by the global configuration. """ missing = "from_context" @@ -1469,10 +1471,12 @@ class ReducingIndicator(CheckMissingIndicator): Parameters ---------- missing : {any, wmo, pct, at_least_n, skip, from_context} - The name of the missing value method. See `xclim.core.missing.MissingBase` to create new custom methods. If - None, this will be determined by the global configuration (see `xclim.set_options`). Defaults to "from_context". + The name of the missing value method. See `xclim.core.missing.MissingBase` to create new custom methods. + If None, this will be determined by the global configuration (see `xclim.set_options`). + Defaults to "from_context". missing_options : dict, optional - Arguments to pass to the `missing` function. If None, this will be determined by the global configuration. + Arguments to pass to the `missing` function. + If None, this will be determined by the global configuration. """ def _get_missing_freq(self, params): @@ -1489,14 +1493,16 @@ class ResamplingIndicator(CheckMissingIndicator): Parameters ---------- missing : {any, wmo, pct, at_least_n, skip, from_context} - The name of the missing value method. See `xclim.core.missing.MissingBase` to create new custom methods. If - None, this will be determined by the global configuration (see `xclim.set_options`). Defaults to "from_context". + The name of the missing value method. See `xclim.core.missing.MissingBase` to create new custom methods. + If None, this will be determined by the global configuration (see `xclim.set_options`). + Defaults to "from_context". missing_options : dict, optional - Arguments to pass to the `missing` function. If None, this will be determined by the global configuration. + Arguments to pass to the `missing` function. + If None, this will be determined by the global configuration. allowed_periods : Sequence[str], optional - A list of allowed periods, i.e. base parts of the `freq` parameter. For example, indicators meant to be - computed annually only will have `allowed_periods=["A"]`. `None` means "any period" or that the - indicator doesn't take a `freq` argument. + A list of allowed periods, i.e. base parts of the `freq` parameter. + For example, indicators meant to be computed annually only will have `allowed_periods=["A"]`. + `None` means "any period" or that the indicator doesn't take a `freq` argument. """ allowed_periods: list[str] | None = None @@ -1613,20 +1619,22 @@ def build_indicator_module( Parameters ---------- name : str - New module name. If it already exists, the module is extended with the passed objects, - overwriting those with same names. + New module name. + If it already exists, the module is extended with the passed objects, overwriting those with same names. objs : dict[str, Indicator] - Mapping of the indicators to put in the new module. Keyed by the name they will take in that module. + Mapping of the indicators to put in the new module. + Keyed by the name they will take in that module. doc : str - Docstring of the new module. Defaults to a simple header. Invalid if the module already exists. + Docstring of the new module. Defaults to a simple header. + Invalid if the module already exists. reload : bool - If reload is True and the module already exists, it is first removed before being rebuilt. - If False (default), indicators are added or updated, but not removed. + If reload is True and the module already exists, it is first removed before being rebuilt. + If False (default), indicators are added or updated, but not removed. Returns ------- ModuleType - A indicator module built from a mapping of Indicators. + A indicator module built from a mapping of Indicators. """ from xclim import indicators @@ -1675,35 +1683,35 @@ def build_indicator_module_from_yaml( # noqa: C901 Parameters ---------- filename : PathLike - Path to a YAML file or to the stem of all module files. See Notes for behaviour when passing a basename only. + Path to a YAML file or to the stem of all module files. See Notes for behaviour when passing a basename only. name : str, optional - The name of the new or existing module, defaults to the basename of the file. - (e.g: `atmos.yml` -> `atmos`) + The name of the new or existing module, defaults to the basename of the file. + (e.g: `atmos.yml` -> `atmos`) indices : Mapping of callables or module or path, optional - A mapping or module of indice functions or a python file declaring such a file. - When creating the indicator, the name in the `index_function` field is first sought - here, then the indicator class will search in xclim.indices.generic and finally in xclim.indices. - translations : Mapping of dicts or path, optional - Translated metadata for the new indicators. Keys of the mapping must be 2-char language tags. - Values can be translations dictionaries as defined in :ref:`internationalization:Internationalization`. - They can also be a path to a json file defining the translations. + A mapping or module of indice functions or a python file declaring such a file. + When creating the indicator, the name in the `index_function` field is first sought + here, then the indicator class will search in xclim.indices.generic and finally in xclim.indices. + translations : Mapping of dicts or path, optional + Translated metadata for the new indicators. Keys of the mapping must be 2-char language tags. + Values can be translations dictionaries as defined in :ref:`internationalization:Internationalization`. + They can also be a path to a json file defining the translations. mode : {'raise', 'warn', 'ignore'} - How to deal with broken indice definitions. + How to deal with broken indice definitions. encoding : str - The encoding used to open the `.yaml` and `.json` files. - It defaults to UTF-8, overriding python's mechanism which is machine dependent. + The encoding used to open the `.yaml` and `.json` files. + It defaults to UTF-8, overriding python's mechanism which is machine dependent. reload : bool - If reload is True and the module already exists, it is first removed before being rebuilt. - If False (default), indicators are added or updated, but not removed. + If reload is True and the module already exists, it is first removed before being rebuilt. + If False (default), indicators are added or updated, but not removed. validate : bool or path - If True (default), the yaml module is validated against xclim's schema. - Can also be the path to a yml schema against which to validate. - Or False, in which case validation is simply skipped. + If True (default), the yaml module is validated against xclim's schema. + Can also be the path to a yml schema against which to validate. + Or False, in which case validation is simply skipped. Returns ------- ModuleType - A submodule of `pym:mod:`xclim.indicators`. + A submodule of `pym:mod:`xclim.indicators`. Notes ----- @@ -1813,7 +1821,8 @@ def _merge_attrs(dbase, dextra, attr, sep): for varname, vardata in yml.get("variables", {}).items(): if varname in VARIABLES and VARIABLES[varname] != vardata: warnings.warn( - f"Variable {varname} from module {module_name} will overwrite the one already defined in `xclim.core.utils.VARIABLES`" + f"Variable {varname} from module {module_name} " + "will overwrite the one already defined in `xclim.core.utils.VARIABLES`" ) VARIABLES[varname] = vardata.copy() From f59a9c4d69cf9c1cd90297a93717f7995814ece3 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 1 May 2024 13:06:51 -0400 Subject: [PATCH 24/35] adjust docs Makefile --- docs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Makefile b/docs/Makefile index f00c6ead7..687a5c241 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -20,4 +20,4 @@ help: @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) livehtml: - sphinx-autobuild --port 54345 --open-browser --delay 2 --re-ignore "$(BUILDDIR)|apidoc|_dynamic/indicators.json|variables.json|__pycache__" "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + sphinx-autobuild --port 54345 --open-browser --delay 3 --re-ignore "$(BUILDDIR)|apidoc|Makefile|_dynamic/indicators.json|variables.json|__pycache__" "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) From b41e6cb37b459d5138e581066a385b81d2f9d9b8 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 1 May 2024 13:16:32 -0400 Subject: [PATCH 25/35] format indicators to yaml --- docs/notebooks/example/example.py | 16 ++++++++-------- docs/notebooks/extendxclim.ipynb | 32 +++++++++++++++++-------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/docs/notebooks/example/example.py b/docs/notebooks/example/example.py index 18b6be06f..e5cee3ad4 100644 --- a/docs/notebooks/example/example.py +++ b/docs/notebooks/example/example.py @@ -9,7 +9,7 @@ @declare_units(pr="[precipitation]") def extreme_precip_accumulation_and_days( pr: xr.DataArray, perc: float = 95, freq: str = "YS" -): +) -> tuple[xr.DataArray, xr.DataArray]: """Total precipitation accumulation during extreme events and number of days of such precipitation. The `perc` percentile of the precipitation (including all values, not in a day-of-year manner) @@ -19,18 +19,18 @@ def extreme_precip_accumulation_and_days( Parameters ---------- pr: xr.DataArray - Precipitation flux (both phases). + Precipitation flux (both phases). perc: float - Percentile corresponding to "extreme" precipitation, [0-100]. + Percentile corresponding to "extreme" precipitation, [0-100]. freq: str - Resampling frequency. + Resampling frequency. Returns ------- xarray.DataArray - Precipitation accumulated during events where pr was above the {perc}th percentile of the whole series. + Precipitation accumulated during events where pr was above the {perc}th percentile of the whole series. xarray.DataArray - Number of days where pr was above the {perc}th percentile of the whole series. + Number of days where pr was above the {perc}th percentile of the whole series. """ pr_thresh = pr.quantile(perc / 100, dim="time").drop_vars("quantile") @@ -38,8 +38,8 @@ def extreme_precip_accumulation_and_days( pr_extreme = rate2amount(pr).where(extreme_days) out1 = pr_extreme.resample(time=freq).sum() - out1.attrs["units"] = pr_extreme.units + out1 = out1.assign_attrs(units=pr_extreme.units) out2 = extreme_days.resample(time=freq).sum() - out2.attrs["units"] = "days" + out2 = out2.assign_attrs(units="days") return out1, out2 diff --git a/docs/notebooks/extendxclim.ipynb b/docs/notebooks/extendxclim.ipynb index f1fccf5e4..cb75d9b1a 100644 --- a/docs/notebooks/extendxclim.ipynb +++ b/docs/notebooks/extendxclim.ipynb @@ -37,7 +37,6 @@ "\n", "This introduction will focus on the Indicator/Index part of `xclim` and how one can extend it by implementing new ones.\n", "\n", - "\n", "## Indices vs Indicators\n", "\n", "Internally and in the documentation, `xclim` makes a distinction between \"indices\" and \"indicators\".\n", @@ -237,7 +236,7 @@ "metadata": {}, "outputs": [], "source": [ - "print(tg_mean_c.__doc__)" + "display(Code(tg_mean_c.__doc__, language=\"rst\"))" ] }, { @@ -403,14 +402,17 @@ "metadata": {}, "outputs": [], "source": [ - "from importlib.resources import path\n", + "from importlib.resources import files\n", "\n", "import yamale\n", "\n", - "with path(\"xclim.data\", \"schema.yml\") as f:\n", + "data = files(\"xclim.data\").joinpath(\"schema.yml\")\n", + "with data as f:\n", " schema = yamale.make_schema(f)\n", - " data = yamale.make_data(example_dir / \"example.yml\") # in the example folder\n", - "yamale.validate(schema, data)" + "\n", + "example_module = yamale.make_data(example_dir / \"example.yml\") # in the example folder\n", + "\n", + "yamale.validate(schema, example_module)" ] }, { @@ -447,9 +449,8 @@ "metadata": {}, "outputs": [], "source": [ - "print(example.__doc__)\n", - "print(\"--\")\n", - "print(xc.indicators.example.R99p.__doc__)" + "docstring = f\"{example.__doc__}\\n---\\n\\n{xc.indicators.example.R99p.__doc__}\"\n", + "display(Code(docstring, language=\"rst\"))" ] }, { @@ -479,17 +480,20 @@ "\n", "outs = []\n", "with xc.set_options(metadata_locales=\"fr\"):\n", + " inds = [\"Indicators:\"]\n", " for name, ind in example.iter_indicators():\n", - " print(f\"Indicator: {name}\")\n", - " print(f\"\\tIdentifier: {ind.identifier}\")\n", + " inds.append(f\" {name}:\")\n", + " inds.append(f\" identifier: {ind.identifier}\")\n", " out = ind(ds=ds2) # Use all default arguments and variables from the dataset\n", " if isinstance(out, tuple):\n", " outs.extend(out)\n", - " for o in out:\n", - " print(f\"\\tLong name ({o.name}): {o.long_name}\")\n", + " for i, o in enumerate(out):\n", + " inds.append(f\" long_name_{i}: ({o.name}) {o.long_name}\")\n", " else:\n", " outs.append(out)\n", - " print(f\"\\tLong name ({out.name}): {out.long_name}\")" + " inds.append(f\" long_name: ({out.name}) {out.long_name}\")\n", + "\n", + "display(Code(\"\\n\".join(inds), language=\"yaml\"))" ] }, { From fc1227a014001947cb80ca0f788c537c392717c4 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 1 May 2024 14:59:26 -0400 Subject: [PATCH 26/35] fix formatting of docstrings, fix docstrings in formatting.py --- docs/notebooks/extendxclim.ipynb | 14 +++++------ xclim/core/formatting.py | 43 +++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/docs/notebooks/extendxclim.ipynb b/docs/notebooks/extendxclim.ipynb index cb75d9b1a..aa2b679c9 100644 --- a/docs/notebooks/extendxclim.ipynb +++ b/docs/notebooks/extendxclim.ipynb @@ -106,7 +106,7 @@ "def tx_days_compare(\n", " tasmax: xr.DataArray, thresh: str = \"0 degC\", op: str = \">\", freq: str = \"YS\"\n", "):\n", - " r\"\"\"Number of days where maximum daily temperature. is above or under a threshold.\n", + " r\"\"\"Number of days where maximum daily temperature is above or under a threshold.\n", "\n", " The daily maximum temperature is compared to a threshold using a given operator and the number\n", " of days where the condition is true is returned.\n", @@ -116,19 +116,19 @@ " Parameters\n", " ----------\n", " tasmax : xarray.DataArray\n", - " Maximum daily temperature.\n", + " Maximum daily temperature.\n", " thresh : str\n", - " Threshold temperature to compare to.\n", + " Threshold temperature to compare to.\n", " op : {'>', '<'}\n", - " The operator to use.\n", - " # A fixed set of choices can be imposed. Only strings, numbers, booleans or None are accepted.\n", + " The operator to use.\n", + " # A fixed set of choices can be imposed. Only strings, numbers, booleans or None are accepted.\n", " freq : str\n", - " Resampling frequency.\n", + " Resampling frequency.\n", "\n", " Returns\n", " -------\n", " xarray.DataArray, [temperature]\n", - " Maximum value of daily maximum temperature.\n", + " Maximum value of daily maximum temperature.\n", "\n", " Notes\n", " -----\n", diff --git a/xclim/core/formatting.py b/xclim/core/formatting.py index dbbde8f44..7b548002c 100644 --- a/xclim/core/formatting.py +++ b/xclim/core/formatting.py @@ -14,7 +14,7 @@ from collections.abc import Sequence from fnmatch import fnmatch from inspect import _empty, signature # noqa -from typing import Any +from typing import Any, Callable import xarray as xr from boltons.funcutils import wraps @@ -307,7 +307,7 @@ def merge_attributes( new_line: str = "\n", missing_str: str | None = None, **inputs_kws: xr.DataArray | xr.Dataset, -): +) -> str: r"""Merge attributes from several DataArrays or Datasets. If more than one input is given, its name (if available) is prepended as: " : ". @@ -359,7 +359,7 @@ def update_history( *inputs_list: Sequence[xr.DataArray | xr.Dataset], new_name: str | None = None, **inputs_kws: xr.DataArray | xr.Dataset, -): +) -> str: r"""Return a history string with the timestamped message and the combination of the history of all inputs. The new history entry is formatted as "[] : - xclim version: ." @@ -406,7 +406,7 @@ def update_history( return merged_history -def update_xclim_history(func): +def update_xclim_history(func: Callable): """Decorator that auto-generates and fills the history attribute. The history is generated from the signature of the function and added to the first output. @@ -449,8 +449,8 @@ def _call_and_add_history(*args, **kwargs): return _call_and_add_history -def gen_call_string(funcname: str, *args, **kwargs): - """Generate a signature string for use in the history attribute. +def gen_call_string(funcname: str, *args, **kwargs) -> str: + r"""Generate a signature string for use in the history attribute. DataArrays and Dataset are replaced with their name, while Nones, floats, ints and strings are printed directly. All other objects have their type printed between < >. @@ -462,7 +462,7 @@ def gen_call_string(funcname: str, *args, **kwargs): ---------- funcname : str Name of the function - args, kwargs + \*args, \*\*kwargs Arguments given to the function. Example @@ -491,7 +491,7 @@ def gen_call_string(funcname: str, *args, **kwargs): return f"{funcname}({', '.join(elements)})" -def prefix_attrs(source: dict, keys: Sequence, prefix: str): +def prefix_attrs(source: dict, keys: Sequence, prefix: str) -> dict: """Rename some keys of a dictionary by adding a prefix. Parameters @@ -517,7 +517,7 @@ def prefix_attrs(source: dict, keys: Sequence, prefix: str): return out -def unprefix_attrs(source: dict, keys: Sequence, prefix: str): +def unprefix_attrs(source: dict, keys: Sequence, prefix: str) -> dict: """Remove prefix from keys in a dictionary. Parameters @@ -562,7 +562,9 @@ def unprefix_attrs(source: dict, keys: Sequence, prefix: str): } -def _gen_parameters_section(parameters: dict, allowed_periods: list[str] | None = None): +def _gen_parameters_section( + parameters: dict[str, dict[str, Any]], allowed_periods: list[str] | None = None +) -> str: """Generate the "parameters" section of the indicator docstring. Parameters @@ -571,6 +573,10 @@ def _gen_parameters_section(parameters: dict, allowed_periods: list[str] | None Parameters dictionary (`Ind.parameters`). allowed_periods : list of str, optional Restrict parameters to specific periods. Default: None. + + Returns + ------- + str """ section = "Parameters\n----------\n" for name, param in parameters.items(): @@ -600,22 +606,28 @@ def _gen_parameters_section(parameters: dict, allowed_periods: list[str] | None unitstr = f"[Required units : {param.units}]" else: unitstr = "" - section += f"{name} : {annotstr}\n {desc_str}\n {defstr}{unitstr}\n" + section += f"{name} {': ' if annotstr else ''}{annotstr}\n {desc_str}\n {defstr}{unitstr}\n" return section -def _gen_returns_section(cf_attrs: Sequence[dict[str, Any]]): +def _gen_returns_section(cf_attrs: Sequence[dict[str, Any]]) -> str: """Generate the "Returns" section of an indicator's docstring. Parameters ---------- cf_attrs : Sequence[Dict[str, Any]] - The list of attributes, usually Indicator.cf_attrs. + The list of attributes, usually Indicator.cf_attrs. + + Returns + ------- + str """ section = "Returns\n-------\n" for attrs in cf_attrs: + if not section.endswith("\n"): + section += "\n" section += f"{attrs['var_name']} : DataArray\n" - section += f" {attrs.get('long_name', '')}" + section += f" {attrs.get('long_name', '')}" if "standard_name" in attrs: section += f" ({attrs['standard_name']})" if "units" in attrs: @@ -627,7 +639,8 @@ def _gen_returns_section(cf_attrs: Sequence[dict[str, Any]]): attr = "" added_section += f" **{key}**: {attr};" if added_section: - section = f"{section}, with additional attributes:{added_section[:-1]}\n" + section = f"{section}, with additional attributes:{added_section[:-1]}" + section += "\n" return section From b00f69d1fd7891f950ca51772bb0d4eccd06c28f Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 1 May 2024 15:39:32 -0400 Subject: [PATCH 27/35] adjust test --- tests/test_formatting.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_formatting.py b/tests/test_formatting.py index 56cd60efb..98ffb2563 100644 --- a/tests/test_formatting.py +++ b/tests/test_formatting.py @@ -31,10 +31,10 @@ def test_indicator_docstring(): == "Based on indice :py:func:`~xclim.indices._multivariate.heat_wave_frequency`." ) assert doc[6] == "Keywords : temperature health,." - assert doc[12] == " Default : `ds.tasmin`. [Required units : [temperature]]" + assert doc[12] == " Default : `ds.tasmin`. [Required units : [temperature]]" assert ( doc[41] - == " Total number of series of at least {window} consecutive days with daily minimum temperature above " + == " Total number of series of at least {window} consecutive days with daily minimum temperature above " "{thresh_tasmin} and daily maximum temperature above {thresh_tasmax} (heat_wave_events), " "with additional attributes: **description**: {freq} number of heat wave events within a given period. " "A heat wave occurs when daily minimum and maximum temperatures exceed {thresh_tasmin} and {thresh_tasmax}, " @@ -42,7 +42,7 @@ def test_indicator_docstring(): ) doc = degree_days_exceedance_date.__doc__.split("\n") - assert doc[21] == " Default : >. " + assert doc[21] == " Default : >. " def test_update_xclim_history(atmosds): From 16d3e8b7c702f7df39d7266f90836878c6810d11 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 1 May 2024 16:21:57 -0400 Subject: [PATCH 28/35] update CHANGES.rst --- CHANGES.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index b3f162f95..4f3c1cf36 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -13,9 +13,8 @@ Announcements New features and enhancements ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * Indicator ``xclim.atmos.potential_evapotranspiration`` and indice ``xclim.indices.potential_evapotranspiration`` now accept a new value (`DA02`) for argument `method` implementing potential evapotranspiration based on Droogers and Allen (2002). (:issue:`1710`, :pull:`1723`). -* `ensemble_percentiles` now takes a `method` argument, accepting - 'interpolated_inverted_cdf', 'hazen', 'weibull', 'linear' (default), - 'median_unbiased' and 'normal_unbiased'. (:issue:`1694`, :pull:`1732`). +* ``xclim.ensembles.ensemble_percentiles`` now takes a `method` argument, accepting one of: `'interpolated_inverted_cdf'`, `'hazen'`, `'weibull'`, `'linear'` (default), `'median_unbiased'`, or `'normal_unbiased'`. (:issue:`1694`, :pull:`1732`). +* The documentation now uses the `furo `_ theme for Sphinx. This theme supports native "light" and "dark" modes, adaptive screen resolution, as well as provides a better navigation layout for pages housing long lists of entries (e.g. `indices`). (:issue:`1693`, :pull:`1731`). New indicators ^^^^^^^^^^^^^^ @@ -27,8 +26,8 @@ Breaking changes * The previously deprecated functions ``xclim.sdba.processing.construct_moving_yearly_window`` and ``xclim.sdba.processing.unpack_moving_yearly_window`` have been removed. These functions have been replaced by ``xclim.core.calendar.stack_periods`` and ``xclim.core.calendar.unstack_periods``. (:pull:`1717`). * The previously deprecated function ``xclim.ensembles.change_significance`` has been removed. (:pull:`1737`). * Indicators ``snw_season_length`` and ``snd_season_length`` have been modified, see above. -* The `hargeaves85`/`hg85` method for the ``potential_evapotranspiration`` indicator and indice has been modified for precision and consistency with recent academic literature. (:issue:`1710`, :pull:`1723`). - +* The `'hargeaves85'`/`'hg85'` method for the ``potential_evapotranspiration`` indicator and indice has been modified for precision and consistency with recent academic literature. (:issue:`1710`, :pull:`1723`). +* The default documentation theme has changed from `sphinx-rtd-theme` to `furo`; Several modifications to the documentation configuration and CSS overrides have been made to accommodate the changes. `furo` is now a `docs` dependency. (:issue:`1693`, :pull:`1731`). Bug fixes ^^^^^^^^^ @@ -39,6 +38,7 @@ Bug fixes * Fixed "agreement fraction" in ``robustness_fractions`` to distinguish between negative change and no change. Added "negative" and "changed negative" fractions (:issue:`1690`, :pull:`1711`). * ``make_criteria`` now skips columns with NaNs across all realizations. (:pull:`1713`). * Fixed bug QuantileDeltaMapping adjustment not working for seasonal grouping (:issue:`1704`, :pull:`1716`). +* ``xclim.core.formatting.generate_indicator_docstring`` has been modified to ensure that the `numpy`-docstrings of all Indicators are consistent in their formatting. (:pull:`1731`). Internal changes ^^^^^^^^^^^^^^^^ @@ -48,6 +48,7 @@ Internal changes * Added the `tox-gh` dependency to the development installation recipe. This will soon be required for running the `tox` test ensemble on GitHub Workflows. (:pull:`1709`). * Added the `vulture` static code analysis tool for finding dead code to the development dependency list and linters (makefile, tox and pre-commit hooks). (:pull:`1717`). * Added error message when using `xclim.indices.stats.dist_method` with `nnlf` and included note in docstring. (:issue:`1683`, :pull:`1714`). +* Linting dependencies have been updated to the latest versions and made consistent across `environment.yml`, `pyproject.toml` and `tox.ini` files. (:pull:`1717`). v0.48.2 (2024-02-26) -------------------- From e7dcbab56c0c8be721c5baa096baf996ff37209d Mon Sep 17 00:00:00 2001 From: Sarah G <91751417+sg2475962@users.noreply.github.com> Date: Thu, 2 May 2024 12:50:15 -0400 Subject: [PATCH 29/35] Fix for xarray output in auto theme --- docs/_static/xarray.css | 13 +++++++++++ docs/conf.py | 48 ++++++++++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 docs/_static/xarray.css diff --git a/docs/_static/xarray.css b/docs/_static/xarray.css new file mode 100644 index 000000000..49b906f9c --- /dev/null +++ b/docs/_static/xarray.css @@ -0,0 +1,13 @@ + +/* default xarray theme, this is taken from the injected css that xarray uses. +However, we change it so that it updates in the body, instead of :root, so that it updates with the theme.*/ +html, body { + --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1)); + --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54)); + --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38)); + --xr-border-color: var(--jp-border-color2, #e0e0e0); + --xr-disabled-color: var(--jp-layout-color3, #bdbdbd); + --xr-background-color: var(--jp-layout-color0, white); + --xr-background-color-row-even: var(--jp-layout-color1, white); + --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee); +} \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 7217df013..631cd0a53 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -307,14 +307,7 @@ class XCStyle(AlphaStyle): "class": "", }, ], - "light_css_variables": { - "color-table-rows-even": "#eeebee", - "color-copybutton": "#000", - "color-indicator-text": "#5a5c63", - "color-indicator-background": "#eeebee", - "color-indicator-widget-text": "#2f2f2f", - "color-indicator-widget-background": "#bdbdbd", - }, + "dark_css_variables": { "color-table-rows-even": "#303335", "color-copybutton": "#fff", @@ -322,6 +315,44 @@ class XCStyle(AlphaStyle): "color-indicator-background": "#3e3e3e", "color-indicator-widget-text": "#a8a8a8", "color-indicator-widget-background": "#303335", + # Fix for xarray injected theme error in auto*dark mode + # Note: because these are set with the selector + # body:not([data-theme="light"]), any variable that uses them needs to + # have a scope smaller than body. + # However, the xarray variables that use these are defined in the :root selector, + # which is higher than body. We therefore need to redefine them in body. + # This is done in xarray.css, included at the bottom of this file. + # furo issue to track when this is no longer needed: + # https://github.com/pradyunsg/furo/discussions/790 + "jp-content-font-color0": "rgba(255, 255, 255, 1)", + "jp-content-font-color2": "rgba(255, 255, 255, 0.54)", + "jp-content-font-color3": "rgba(255, 255, 255, 0.38)", + "jp-border-color0": "#1F1F1F", + "jp-border-color1": "#1F1F1F", + "jp-border-color2": "#1F1F1F", + "jp-layout-color0": "#111111", + "jp-layout-color1": "#111111", + "jp-layout-color2": "#313131", + "jp-layout-color3": "#515151", + }, + "light_css_variables": { + "color-table-rows-even": "#eeebee", + "color-copybutton": "#000", + "color-indicator-text": "#5a5c63", + "color-indicator-background": "#eeebee", + "color-indicator-widget-text": "#2f2f2f", + "color-indicator-widget-background": "#bdbdbd", + # (consistency for light and dark themes, so variables are unset when switching to light) + "jp-content-font-color0": "rgba(0, 0, 0, 1)", + "jp-content-font-color2": "rgba(0, 0, 0, 0.54)", + "jp-content-font-color3": "rgba(0, 0, 0, 0.38)", + "jp-border-color0": "#e0e0e0", + "jp-border-color1": "#e0e0e0", + "jp-border-color2": "#e0e0e0", + "jp-layout-color0": "#ffffff", + "jp-layout-color1": "#ffffff", + "jp-layout-color2": "#eeeeee", + "jp-layout-color3": "#bdbdbd", }, } @@ -416,3 +447,4 @@ class XCStyle(AlphaStyle): def setup(app): app.add_css_file("style.css") + app.add_css_file("xarray.css") From 1611daeda0365cf3fe913400c065807ad6d3b9f4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 16:51:09 +0000 Subject: [PATCH 30/35] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/_static/xarray.css | 4 ++-- docs/conf.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/_static/xarray.css b/docs/_static/xarray.css index 49b906f9c..5ea01f05a 100644 --- a/docs/_static/xarray.css +++ b/docs/_static/xarray.css @@ -1,5 +1,5 @@ -/* default xarray theme, this is taken from the injected css that xarray uses. +/* default xarray theme, this is taken from the injected css that xarray uses. However, we change it so that it updates in the body, instead of :root, so that it updates with the theme.*/ html, body { --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1)); @@ -10,4 +10,4 @@ html, body { --xr-background-color: var(--jp-layout-color0, white); --xr-background-color-row-even: var(--jp-layout-color1, white); --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee); -} \ No newline at end of file +} diff --git a/docs/conf.py b/docs/conf.py index 631cd0a53..e1d9e45b3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -307,7 +307,6 @@ class XCStyle(AlphaStyle): "class": "", }, ], - "dark_css_variables": { "color-table-rows-even": "#303335", "color-copybutton": "#fff", @@ -318,7 +317,7 @@ class XCStyle(AlphaStyle): # Fix for xarray injected theme error in auto*dark mode # Note: because these are set with the selector # body:not([data-theme="light"]), any variable that uses them needs to - # have a scope smaller than body. + # have a scope smaller than body. # However, the xarray variables that use these are defined in the :root selector, # which is higher than body. We therefore need to redefine them in body. # This is done in xarray.css, included at the bottom of this file. From 0b6700d16c853d475c0fdc8d1ed5daca4e3fe131 Mon Sep 17 00:00:00 2001 From: Sarah G <91751417+sg2475962@users.noreply.github.com> Date: Thu, 2 May 2024 13:56:48 -0400 Subject: [PATCH 31/35] increase css specificity on tables to target dask css --- docs/_static/style.css | 12 ++++++++++-- docs/conf.py | 10 ++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/docs/_static/style.css b/docs/_static/style.css index 4670bd728..88122a6e4 100644 --- a/docs/_static/style.css +++ b/docs/_static/style.css @@ -37,8 +37,16 @@ td.name { font-weight: 500; } -tr:nth-child(even) { - background-color: var(--color-table-rows-even); +body div tr:nth-child(even), +body div.rendered_html tbody tr:nth-child(even) { + background-color: var(--color-background-table-rows-even); + color: var(--color-text-table-rows-even); +} + +body div tr:nth-child(odd), +body div.rendered_html tbody tr:nth-child(odd) { + background-color: var(--color-background-table-rows-odd); + color: var(--color-text-table-rows-odd); } dd { diff --git a/docs/conf.py b/docs/conf.py index e1d9e45b3..b4e71d3a6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -308,7 +308,10 @@ class XCStyle(AlphaStyle): }, ], "dark_css_variables": { - "color-table-rows-even": "#303335", + "color-background-table-rows-even": "#303335", + "color-background-table-rows-odd": "#3e3e3e", + "color-text-table-rows-even": "#fff", + "color-text-table-rows-odd": "#fff", "color-copybutton": "#fff", "color-indicator-text": "#cfd0d0", "color-indicator-background": "#3e3e3e", @@ -335,7 +338,10 @@ class XCStyle(AlphaStyle): "jp-layout-color3": "#515151", }, "light_css_variables": { - "color-table-rows-even": "#eeebee", + "color-background-table-rows-even": "#eeebee", + "color-background-table-rows-odd": "#f5f5f5", + "color-text-table-rows-even": "#000", + "color-text-table-rows-odd": "#000", "color-copybutton": "#000", "color-indicator-text": "#5a5c63", "color-indicator-background": "#eeebee", From 1984b392b91fa6c131c7ab5af7d65ef41a07d9b2 Mon Sep 17 00:00:00 2001 From: Sarah G <91751417+sg2475962@users.noreply.github.com> Date: Thu, 2 May 2024 13:59:20 -0400 Subject: [PATCH 32/35] Add myself as a contributor --- AUTHORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.rst b/AUTHORS.rst index 17582a6b6..0504718e7 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -29,6 +29,7 @@ Contributors * David Caron `@davidcaron `_ * Carsten Ehbrecht `@cehbrecht `_ * Jeremy Fyke `@jeremyfyke `_ +* Sarah Gammon `@SarahG-579462 `_ * Tom Keel `@Thomasjkeel `_ * Marie-Pier Labonté `@marielabonte `_ * Ludwig Lierhammer `@ludwiglierhammer `_ From c3eee812f1aa74db48bcec002774953d239c2258 Mon Sep 17 00:00:00 2001 From: Sarah G <91751417+sg2475962@users.noreply.github.com> Date: Thu, 2 May 2024 14:07:31 -0400 Subject: [PATCH 33/35] prep for merge for Github changes: logos --- README.rst | 4 ++-- docs/logos/xclim-logo-small-light.png | Bin 3492 -> 7684 bytes 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 262f5c322..05d940f5a 100644 --- a/README.rst +++ b/README.rst @@ -189,12 +189,12 @@ This package was created with Cookiecutter_ and the `audreyfeldroy/cookiecutter- :alt: Xclim :class: xclim-logo-small no-theme -.. |logo-light| image:: logos/empty.png +.. |logo-light| image:: https://raw.githubusercontent.com/Ouranosinc/xclim/main/docs/logos/empty.png :target: https://github.com/Ouranosinc/xclim :alt: :class: xclim-logo-small only-light-inline -.. |logo-dark| image:: logos/empty.png +.. |logo-dark| image:: https://raw.githubusercontent.com/Ouranosinc/xclim/main/docs/logos/empty.png :target: https://github.com/Ouranosinc/xclim :alt: :class: xclim-logo-small only-dark-inline diff --git a/docs/logos/xclim-logo-small-light.png b/docs/logos/xclim-logo-small-light.png index 615b9271e07be09f20e839164f3a92dc41264006..191b0178d6c8530d9e6dbc11087bf38fefb03dcc 100644 GIT binary patch literal 7684 zcmeHMc{r5o`+rH+FtTQyMud!63}!4*_I=;7H7jGAF=H7CrKAWUZI%#83&~EUl7y7) zNMujQmP(PMelK;->0H0>b^We$UBB;t=bh`FdEV!_@6U7JpXc-3*E}<)>}*W=c_n!P z0N^(_GjaewJ;2+Sn-hGerR=o@Kbj9YxrI95BcOB!jY171Lqj9!WGIQsE!DhN<(3A~VsCq5G%lA{jFo!_Er(%Csy+NktYa+yo^ITtaDuz}bD_(^ru_BLCHa@4=SQ&OGGZ)B zzgh9yQ%#Qv<;OAwC<=xOxw}%{I3<6GKi!Ud?veeQMRL_btB*umz@B!`V%%vCv2qR` zm`Jak$yPB!rGMcCv#yxeP5N(E6d1~HRF0()*_^MPk-6eYHNc7+GOcmoZ#3wd0N7q)V(NTy5+~IS5OGATB)Y=!T8;x@10*nVirz^jJ z!edcEfw@^*X%lHdYIqWjKvrV~(Lv<_fUZ7^jwc3?L!kt+FEv;Xw%E`JgHlO)Fjoz0 zq&3};>_;^_#2`B!vT-6F3LxT0F#Wx}x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b(h^A3SAFnd!I`48)%?`1{!Fffd(3Apn(P&XrO_y ahyMXGV1W6%+lycT0000 Date: Thu, 2 May 2024 14:49:23 -0400 Subject: [PATCH 34/35] Update zenodo --- .zenodo.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.zenodo.json b/.zenodo.json index bc29d900e..585d12ba7 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -41,6 +41,11 @@ "affiliation": "Ouranos, Montréal, Québec, Canada", "orcid": "0000-0003-3389-9406" }, + { + "name": "Gammon, Sarah", + "affiliation": "Ouranos, Montréal, Québec, Canada", + "orcid": "0009-0007-6082-9063" + }, { "name": "Alegre, Raquel", "affiliation": "University College London, London, United Kingdom", From fa02918203d6c4a8fc4da73101420f3b7a7e91a4 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 2 May 2024 14:51:13 -0400 Subject: [PATCH 35/35] update CHANGES.rst --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index acadf0779..8f90ee6b9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -53,6 +53,8 @@ Internal changes * Added error message when using `xclim.indices.stats.dist_method` with `nnlf` and included note in docstring. (:issue:`1683`, :pull:`1714`). * PEP8 rule `N802` is now enabled in the `ruff` formatter. Function names should follow `Snake case `_, with rare exceptions. (:pull:`1721`). * Linting dependencies have been updated to the latest versions and made consistent across `environment.yml`, `pyproject.toml` and `tox.ini` files. (:pull:`1717`). +* Code styling for the documentation now uses `sas` ("light" theme) and `lightbulb` ("dark" theme) in order to ensure adequate contrast for code blocks. (:pull:`1731`). +* Added several CSS overrides related to the HTML elements generated by `xarray` in the notebook-sourced documentation. (:pull:`1731`). v0.48.2 (2024-02-26) --------------------