From 5ad5e2e38652860f4b8640e131327aacec96184c Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Tue, 9 Jun 2026 23:29:58 +0200 Subject: [PATCH 1/4] use `ruff`, `prettier`, and `taplo` --- .pre-commit-config.yaml | 28 +++++++++++++++++----------- pyproject.toml | 39 +++++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 19cd0e2a..972628ba 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,10 +11,9 @@ repos: - id: check-json exclude: ^.devcontainer/ - id: check-yaml - - id: double-quote-string-fixer - repo: https://github.com/codespell-project/codespell - rev: "v2.4.1" + rev: 'v2.4.1' hooks: - id: codespell @@ -28,21 +27,28 @@ repos: rev: v0.4.6 hooks: - id: blackdoc + additional_dependencies: ['black==26.1.0'] + - id: blackdoc-autoupdate-black - - repo: https://github.com/PyCQA/flake8 - rev: 7.3.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.15.15 hooks: - - id: flake8 + - id: ruff-check + args: ['--fix', '--show-fixes'] - - repo: https://github.com/PyCQA/isort - rev: 8.0.1 + - repo: https://github.com/rbubley/mirrors-prettier + rev: v3.8.3 hooks: - - id: isort + - id: prettier + args: ['--cache-location=.prettier_cache/cache'] - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v4.0.0-alpha.8 + - repo: https://github.com/ComPWA/taplo-pre-commit + rev: v0.9.3 hooks: - - id: prettier + - id: taplo-format + args: ['--option', 'array_auto_collapse=false'] + - id: taplo-lint + args: ['--no-schema'] - repo: https://github.com/kynan/nbstripout rev: 0.9.1 diff --git a/pyproject.toml b/pyproject.toml index e45b1274..504066e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,29 +22,28 @@ classifiers = [ [tool.black] line-length = 100 -target-version = ['py38'] -skip-string-normalization = true +target-version = ['py311'] -[tool.flake8] -#exclude = -ignore = "E203,E266,E501,W503,E722,E402,C901" -max-line-length = 100 -max-complexity = 18 -select = "B,C,E,F,W,T4,B9" - -[tool.isort] -#known_first_party= -#known_third_party= -multi_line_output=3 -include_trailing_comma=true -force_grid_wrap=0 -combine_as_imports=true -line_length=100 -#skip= +[tool.ruff.lint] +select = [ + "I", # isort + "W", # pycodestyle warnings + "B", # flake8-bugbear + "F", # Pyflakes + "E", # Pycodestyle +] +ignore = [ + "E203", # whitespace before '{symbol}' + "E266", # too many leading '#' before block comment + "E501", # line too long + "E722", # do not use bare except + "E402", # module level import not at top of file + "E731", # do not assign a lambda expression, use a def +] [tool.codespell] -ignore-words-list="nd" -skip="pixi.lock,.pixi,qaqc.yaml" +ignore-words-list = "nd" +skip = "pixi.lock,.pixi,qaqc.yaml" [tool.pixi.workspace] name = "xarray-tutorial" From 07d2b9af904ae8bb4e66dcdfc5d5d2c7ac6c01b7 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Tue, 9 Jun 2026 23:34:58 +0200 Subject: [PATCH 2/4] only auto-fix isort warnings --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 504066e9..e8a3696c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,7 @@ ignore = [ "E402", # module level import not at top of file "E731", # do not assign a lambda expression, use a def ] +fixable = ["I"] [tool.codespell] ignore-words-list = "nd" From eab55f0e47784a1f02f572547b10d7a6ca2817f4 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Tue, 9 Jun 2026 23:36:02 +0200 Subject: [PATCH 3/4] run all hooks --- .devcontainer/scipy2023/jupyter_lab_config.py | 4 +- .devcontainer/scipy2024/jupyter_lab_config.py | 4 +- .github/actions/setup-pixi/action.yml | 6 +-- .github/dependabot.yml | 6 +-- .github/workflows/main.yaml | 2 +- .github/workflows/pull_request.yaml | 2 +- .github/workflows/qaqc.yaml | 4 +- .github/workflows/surge_preview.yml | 2 +- _config.yml | 14 ++--- _static/style.css | 2 +- advanced/accessors/01_accessor_examples.ipynb | 51 ++++++++++--------- .../automatic-vectorizing-numpy.ipynb | 2 +- .../apply_ufunc/complex-output-numpy.ipynb | 2 +- advanced/apply_ufunc/example-interp.ipynb | 2 +- .../apply_ufunc/numba-vectorization.ipynb | 4 +- fundamentals/01.1_io.ipynb | 6 +-- fundamentals/01_datastructures.ipynb | 2 +- .../01_datatree_hierarchical_data.ipynb | 8 +-- fundamentals/02.1_indexing_Basic.ipynb | 8 +-- .../03.1_computation_with_xarray.ipynb | 2 +- fundamentals/03.2_groupby_with_xarray.ipynb | 4 +- fundamentals/03.3_windowed.ipynb | 2 +- fundamentals/03.4_weighted.ipynb | 2 +- intermediate/BiologyDataset.ipynb | 10 ++-- .../01-high-level-computation-patterns.ipynb | 2 +- .../hierarchical_computation.ipynb | 2 +- .../data_cleaning/05.3_ice_velocity.ipynb | 47 ++++++++--------- .../datastructures-intermediate.ipynb | 16 +++--- intermediate/indexing/advanced-indexing.ipynb | 2 +- .../indexing/boolean-masking-indexing.ipynb | 2 +- intermediate/intro-to-zarr.ipynb | 45 ++++++++-------- intermediate/remote_data/remote-data.ipynb | 13 ++--- intermediate/xarray_and_dask.ipynb | 4 +- intermediate/xarray_ecosystem.ipynb | 18 +++---- overview/xarray-in-45-min.ipynb | 2 +- 35 files changed, 154 insertions(+), 150 deletions(-) diff --git a/.devcontainer/scipy2023/jupyter_lab_config.py b/.devcontainer/scipy2023/jupyter_lab_config.py index 60b8642e..c8857f0d 100644 --- a/.devcontainer/scipy2023/jupyter_lab_config.py +++ b/.devcontainer/scipy2023/jupyter_lab_config.py @@ -1,3 +1,3 @@ c = get_config() # noqa -c.LabApp.default_url = '/lab/tree/workshops/scipy2023/index.ipynb' -c.ServerApp.allow_origin = '*' +c.LabApp.default_url = "/lab/tree/workshops/scipy2023/index.ipynb" +c.ServerApp.allow_origin = "*" diff --git a/.devcontainer/scipy2024/jupyter_lab_config.py b/.devcontainer/scipy2024/jupyter_lab_config.py index 836bf30c..441e67d3 100644 --- a/.devcontainer/scipy2024/jupyter_lab_config.py +++ b/.devcontainer/scipy2024/jupyter_lab_config.py @@ -1,3 +1,3 @@ c = get_config() # noqa -c.LabApp.default_url = '/lab/tree/workshops/scipy2024/index.ipynb' -c.ServerApp.allow_origin = '*' +c.LabApp.default_url = "/lab/tree/workshops/scipy2024/index.ipynb" +c.ServerApp.allow_origin = "*" diff --git a/.github/actions/setup-pixi/action.yml b/.github/actions/setup-pixi/action.yml index d7ad03fc..2d7902df 100644 --- a/.github/actions/setup-pixi/action.yml +++ b/.github/actions/setup-pixi/action.yml @@ -1,8 +1,8 @@ -name: "Setup Pixi" -description: "Create Python environment for GitHub Action Job" +name: 'Setup Pixi' +description: 'Create Python environment for GitHub Action Job' runs: - using: "composite" + using: 'composite' steps: - uses: prefix-dev/setup-pixi@v0.8.10 with: diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d00361ed..482483ab 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,7 +1,7 @@ # Regularly update Docker tags and Actions steps version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/.github" + - package-ecosystem: 'github-actions' + directory: '/.github' schedule: - interval: "monthly" + interval: 'monthly' diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 5b332031..915b0cbe 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -4,7 +4,7 @@ on: push: branches: main paths-ignore: - - ".devcontainer/**" + - '.devcontainer/**' # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index e0085fcc..5cf4a6af 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -4,7 +4,7 @@ on: pull_request: types: [opened, synchronize, reopened, closed] paths-ignore: - - ".devcontainer/**" + - '.devcontainer/**' concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/qaqc.yaml b/.github/workflows/qaqc.yaml index c57528ec..312327fc 100644 --- a/.github/workflows/qaqc.yaml +++ b/.github/workflows/qaqc.yaml @@ -6,7 +6,7 @@ on: branches: - main paths-ignore: - - ".devcontainer/**" + - '.devcontainer/**' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -28,7 +28,7 @@ jobs: with: check_filenames: true check_hidden: true - skip: ".git,*.js,qaqc.yml" + skip: '.git,*.js,qaqc.yml' ignore_words_list: hist,nd # borrowed from https://github.com/ProjectPythia/pythia-foundations/blob/main/.github/workflows/link-checker.yaml diff --git a/.github/workflows/surge_preview.yml b/.github/workflows/surge_preview.yml index 69937ab7..e9725198 100644 --- a/.github/workflows/surge_preview.yml +++ b/.github/workflows/surge_preview.yml @@ -2,7 +2,7 @@ name: Pull Request Preview on: workflow_run: - workflows: ["Pull Request Build"] + workflows: ['Pull Request Build'] types: - completed diff --git a/_config.yml b/_config.yml index 45bea26e..6ae842ed 100644 --- a/_config.yml +++ b/_config.yml @@ -1,7 +1,7 @@ # Learn more at https://jupyterbook.org/customize/config.html -title: "" +title: '' author: The Xarray Community -copyright: "2025" +copyright: '2025' logo: images/logo.png only_build_toc_files: true exclude_patterns: [.github, .pixi] @@ -18,7 +18,7 @@ html: extra_footer: '

Xarray is a fiscally sponsored project of NumFOCUS, a nonprofit dedicated to supporting the open-source scientific computing community.
Theme by the Executable Book Project.

Content licensed under the terms of the Apache 2.0 License.' analytics: google_analytics_id: G-JRQHYVFQR7 - favicon: "images/favicon.ico" + favicon: 'images/favicon.ico' parse: # https://jupyterbook.org/content/content-blocks.html?highlight=myst%20substitution#define-substitutions-for-your-whole-book @@ -40,7 +40,7 @@ parse: # Force re-execution of notebooks on each build. # See https://jupyterbook.org/content/execute.html execute: - execute_notebooks: "cache" + execute_notebooks: 'cache' allow_errors: false # Per-cell notebook execution limit (seconds) timeout: 300 @@ -53,11 +53,11 @@ latex: # Configure your Binder links, such as the URL of the BinderHub. launch_buttons: notebook_interface: jupyterlab - binderhub_url: "https://mybinder.org" + binderhub_url: 'https://mybinder.org' # Information about where the book exists on the web repository: - url: "https://github.com/xarray-contrib/xarray-tutorial" + url: 'https://github.com/xarray-contrib/xarray-tutorial' branch: main # Bibliography @@ -78,7 +78,7 @@ sphinx: config: language: en # accessibility # application/vnd.holoviews_load.v0+json, application/vnd.holoviews_exec.v0+json - suppress_warnings: ["mystnb.unknown_mime_type", "misc.highlighting_failure"] + suppress_warnings: ['mystnb.unknown_mime_type', 'misc.highlighting_failure'] codeautolink_concat_default: True notfound_context: body: "

Whoops! 404 Page Not Found

\n\n

Sorry, this page doesn't exist. Many sections of this book have been updated recently.

Try the search box 🔎 to find what you're looking for!

" diff --git a/_static/style.css b/_static/style.css index 6622dee5..842c6d9b 100644 --- a/_static/style.css +++ b/_static/style.css @@ -5,7 +5,7 @@ /* workaround Pydata Sphinx theme using light colors for widget cell outputs in dark-mode */ /* works for many widgets but not for Xarray html reprs */ /* https://github.com/pydata/pydata-sphinx-theme/issues/2189 */ -html[data-theme="dark"] div.cell_output .text_html:has(div.xr-wrap) { +html[data-theme='dark'] div.cell_output .text_html:has(div.xr-wrap) { background-color: var(--pst-color-on-background) !important; color: var(--pst-color-text-base) !important; } diff --git a/advanced/accessors/01_accessor_examples.ipynb b/advanced/accessors/01_accessor_examples.ipynb index 8efce1c8..7cc557b2 100644 --- a/advanced/accessors/01_accessor_examples.ipynb +++ b/advanced/accessors/01_accessor_examples.ipynb @@ -98,7 +98,7 @@ "outputs": [], "source": [ "ds = xr.tutorial.load_dataset(\"air_temperature\")\n", - "ds[\"skewair\"] = ds['air'].stats.skewness(dim=\"time\")\n", + "ds[\"skewair\"] = ds[\"air\"].stats.skewness(dim=\"time\")\n", "ds" ] }, @@ -126,8 +126,9 @@ "metadata": {}, "outputs": [], "source": [ - "import numpy as np\n", "import os\n", + "\n", + "import numpy as np\n", "import pandas as pd\n", "import xarray as xr\n", "\n", @@ -151,7 +152,7 @@ "\n", " @staticmethod\n", " def _validate(self, req_dim=None, req_vars=None):\n", - " '''\n", + " \"\"\"\n", " Make sure the xarray dataset has the correct dimensions and variables.\n", "\n", " Running this function will check that my dataset has all the needed dimensions and variables\n", @@ -164,7 +165,7 @@ " List of all required dimension names\n", " req_vars : list of str\n", " List of all required variable names\n", - " '''\n", + " \"\"\"\n", "\n", " if req_dim is not None:\n", " if all([dim not in list(self._xrds.dims) for dim in req_dim]):\n", @@ -179,8 +180,8 @@ "\n", " def change_vars_to_coords(\n", " self,\n", - " req_dim=['ny', 'nx'],\n", - " req_vars={'xaxis': ['nx'], 'yaxis': ['ny']},\n", + " req_dim=[\"ny\", \"nx\"],\n", + " req_vars={\"xaxis\": [\"nx\"], \"yaxis\": [\"ny\"]},\n", " ):\n", " \"\"\"\n", " Turn the xaxis and y axis variables into coordinates.\n", @@ -195,8 +196,8 @@ "\n", " self._validate(self, req_dim, req_vars)\n", "\n", - " self._xrds = self._xrds.swap_dims({'ny': 'yaxis', 'nx': 'xaxis'})\n", - " self._xrds = self._xrds.rename({'xaxis': 'x', 'yaxis': 'y'})\n", + " self._xrds = self._xrds.swap_dims({\"ny\": \"yaxis\", \"nx\": \"xaxis\"})\n", + " self._xrds = self._xrds.rename({\"xaxis\": \"x\", \"yaxis\": \"y\"})\n", "\n", " return self._xrds\n", "\n", @@ -207,7 +208,7 @@ " \"\"\"\n", "\n", " reorged = []\n", - " for reorg_var in ['vx', 'vy', 'err']:\n", + " for reorg_var in [\"vx\", \"vy\", \"err\"]:\n", " ds = self.reorg_var_time(reorg_var)\n", " reorged.append(ds)\n", "\n", @@ -232,12 +233,12 @@ " das_to_reorg = [self._xrds[var] for var in to_reorg]\n", "\n", " # add the time dimension\n", - " das_to_reorg = [das_to_reorg[var].expand_dims('time') for var in range(len(das_to_reorg))]\n", + " das_to_reorg = [das_to_reorg[var].expand_dims(\"time\") for var in range(len(das_to_reorg))]\n", "\n", " # update variable name to remove time\n", " das_to_reorg = [das_to_reorg[var].rename(reorg_var) for var in range(len(das_to_reorg))]\n", "\n", - " ds = xr.concat(das_to_reorg, dim='time')\n", + " ds = xr.concat(das_to_reorg, dim=\"time\")\n", "\n", " return ds" ] @@ -248,7 +249,7 @@ "metadata": {}, "outputs": [], "source": [ - "ds = xr.tutorial.open_dataset('ASE_ice_velocity.nc')" + "ds = xr.tutorial.open_dataset(\"ASE_ice_velocity.nc\")" ] }, { @@ -311,7 +312,7 @@ " # as specific to my workflow, saving time and headache later if they were missing and the computation fails\n", " # partway through.\n", " self._validate(\n", - " self, req_dim=['x', 'y', 'dtime'], req_vars={'elevation': ['x', 'y', 'dtime']}\n", + " self, req_dim=[\"x\", \"y\", \"dtime\"], req_vars={\"elevation\": [\"x\", \"y\", \"dtime\"]}\n", " )\n", "\n", " # ----------------------------------------------------------------------\n", @@ -319,7 +320,7 @@ "\n", " @staticmethod\n", " def _validate(self, req_dim=None, req_vars=None):\n", - " '''\n", + " \"\"\"\n", " Make sure the xarray dataset has the correct dimensions and variables\n", "\n", " Parameters\n", @@ -328,7 +329,7 @@ " List of all required dimension names\n", " req_vars : list of str\n", " List of all required variable names\n", - " '''\n", + " \"\"\"\n", "\n", " if req_dim is not None:\n", " if all([dim not in list(self._xrds.dims) for dim in req_dim]):\n", @@ -340,8 +341,8 @@ " # Notice that 'geoid' has been added to the req_vars list\n", " def to_geoid(\n", " self,\n", - " req_dim=['dtime', 'x', 'y'],\n", - " req_vars={'elevation': ['x', 'y', 'dtime', 'geoid']},\n", + " req_dim=[\"dtime\", \"x\", \"y\"],\n", + " req_vars={\"elevation\": [\"x\", \"y\", \"dtime\", \"geoid\"]},\n", " source=None,\n", " ):\n", " \"\"\"\n", @@ -361,11 +362,11 @@ "\n", " # check to make sure you haven't already run this function (and are thus applying the offset twice)\n", " try:\n", - " values = self._xrds.attrs['offset_names']\n", - " assert 'geoid_offset' not in values, \"You've already applied the geoid offset!\"\n", - " values = list([values]) + ['geoid_offset']\n", + " values = self._xrds.attrs[\"offset_names\"]\n", + " assert \"geoid_offset\" not in values, \"You've already applied the geoid offset!\"\n", + " values = list([values]) + [\"geoid_offset\"]\n", " except KeyError:\n", - " values = ['geoid_offset']\n", + " values = [\"geoid_offset\"]\n", "\n", " self._validate(self, req_dim, req_vars)\n", "\n", @@ -374,12 +375,12 @@ " # them to. If not, you will need to reproject and/or resample them to match the data to which you are applying them.\n", " # That step is not included here to emphasize the accessor aspect of the workflow.\n", " with rasterio.open(source) as src:\n", - " geoid = src['geoid_varname']\n", + " geoid = src[\"geoid_varname\"]\n", "\n", " # As noted above, this step will fail or produce unreliable results if your data is not properly gridded\n", - " self._xrds['elevation'] = self._xrds.elevation - geoid\n", + " self._xrds[\"elevation\"] = self._xrds.elevation - geoid\n", "\n", - " self._xrds.attrs['offset_names'] = values\n", + " self._xrds.attrs[\"offset_names\"] = values\n", "\n", " return self._xrds" ] @@ -401,7 +402,7 @@ }, "outputs": [], "source": [ - "ds = ds.geoidxr.to_geoid(source='/Path/to/Custom/source/file.nc')\n", + "ds = ds.geoidxr.to_geoid(source=\"/Path/to/Custom/source/file.nc\")\n", "ds" ] } diff --git a/advanced/apply_ufunc/automatic-vectorizing-numpy.ipynb b/advanced/apply_ufunc/automatic-vectorizing-numpy.ipynb index 4fd42fdc..46c4180a 100644 --- a/advanced/apply_ufunc/automatic-vectorizing-numpy.ipynb +++ b/advanced/apply_ufunc/automatic-vectorizing-numpy.ipynb @@ -107,8 +107,8 @@ "source": [ "%xmode minimal\n", "\n", - "import xarray as xr\n", "import numpy as np\n", + "import xarray as xr\n", "\n", "xr.set_options(display_expand_data=False)\n", "\n", diff --git a/advanced/apply_ufunc/complex-output-numpy.ipynb b/advanced/apply_ufunc/complex-output-numpy.ipynb index 0ad4c244..e9e80fcf 100644 --- a/advanced/apply_ufunc/complex-output-numpy.ipynb +++ b/advanced/apply_ufunc/complex-output-numpy.ipynb @@ -49,8 +49,8 @@ "source": [ "%xmode minimal\n", "\n", - "import xarray as xr\n", "import numpy as np\n", + "import xarray as xr\n", "\n", "np.set_printoptions(threshold=10, edgeitems=2)\n", "xr.set_options(display_expand_data=False)\n", diff --git a/advanced/apply_ufunc/example-interp.ipynb b/advanced/apply_ufunc/example-interp.ipynb index d895b9aa..57318fd1 100644 --- a/advanced/apply_ufunc/example-interp.ipynb +++ b/advanced/apply_ufunc/example-interp.ipynb @@ -65,8 +65,8 @@ "source": [ "%xmode minimal\n", "\n", - "import xarray as xr\n", "import numpy as np\n", + "import xarray as xr\n", "\n", "# limit the amount of information printed to screen\n", "xr.set_options(display_expand_data=False)\n", diff --git a/advanced/apply_ufunc/numba-vectorization.ipynb b/advanced/apply_ufunc/numba-vectorization.ipynb index 5cff94b1..3da709c5 100644 --- a/advanced/apply_ufunc/numba-vectorization.ipynb +++ b/advanced/apply_ufunc/numba-vectorization.ipynb @@ -81,7 +81,7 @@ }, "outputs": [], "source": [ - "from numba import vectorize, float64\n", + "from numba import float64, vectorize\n", "\n", "\n", "@vectorize([float64(float64, float64)])\n", @@ -138,7 +138,7 @@ "from numba import guvectorize, int64\n", "\n", "\n", - "@guvectorize([(int64[:], int64, int64[:])], '(n),()->(n)')\n", + "@guvectorize([(int64[:], int64, int64[:])], \"(n),()->(n)\")\n", "def g(x, y, res):\n", " for i in range(x.shape[0]):\n", " res[i] = x[i] + y\n", diff --git a/fundamentals/01.1_io.ipynb b/fundamentals/01.1_io.ipynb index 317c961c..0520f976 100644 --- a/fundamentals/01.1_io.ipynb +++ b/fundamentals/01.1_io.ipynb @@ -61,7 +61,7 @@ "import pathlib\n", "import shutil\n", "\n", - "datadir = pathlib.Path('../data/io-tutorial')\n", + "datadir = pathlib.Path(\"../data/io-tutorial\")\n", "if datadir.exists():\n", " shutil.rmtree(datadir)\n", "else:\n", @@ -263,7 +263,7 @@ "metadata": {}, "outputs": [], "source": [ - "da.rio.to_raster(datadir / 'ds1_a.tiff')" + "da.rio.to_raster(datadir / \"ds1_a.tiff\")" ] }, { @@ -281,7 +281,7 @@ "metadata": {}, "outputs": [], "source": [ - "DA = xr.open_dataarray(datadir / 'ds1_a.tiff', engine='rasterio')\n", + "DA = xr.open_dataarray(datadir / \"ds1_a.tiff\", engine=\"rasterio\")\n", "DA.rio.crs" ] } diff --git a/fundamentals/01_datastructures.ipynb b/fundamentals/01_datastructures.ipynb index fa3875de..f9add737 100644 --- a/fundamentals/01_datastructures.ipynb +++ b/fundamentals/01_datastructures.ipynb @@ -36,8 +36,8 @@ "outputs": [], "source": [ "import numpy as np\n", - "import xarray as xr\n", "import pandas as pd\n", + "import xarray as xr\n", "\n", "# When working in a Jupyter Notebook you might want to customize Xarray display settings to your liking\n", "# The following settings reduce the amount of data displayed out by default\n", diff --git a/fundamentals/01_datatree_hierarchical_data.ipynb b/fundamentals/01_datatree_hierarchical_data.ipynb index f1601d6a..4c4d4142 100644 --- a/fundamentals/01_datatree_hierarchical_data.ipynb +++ b/fundamentals/01_datatree_hierarchical_data.ipynb @@ -60,7 +60,7 @@ "metadata": {}, "outputs": [], "source": [ - "precipitation = xr.tutorial.open_datatree('precipitation.nc4')" + "precipitation = xr.tutorial.open_datatree(\"precipitation.nc4\")" ] }, { @@ -95,7 +95,7 @@ "metadata": {}, "outputs": [], "source": [ - "precipitation['observed']\n", + "precipitation[\"observed\"]\n", "\n", "# Returns a DataTree object, containing the variables, dimensions, and coordinates in the \"observed\" node" ] @@ -106,7 +106,7 @@ "metadata": {}, "outputs": [], "source": [ - "precipitation['/observed/precipitation']" + "precipitation[\"/observed/precipitation\"]" ] }, { @@ -133,7 +133,7 @@ "metadata": {}, "outputs": [], "source": [ - "precipitation['reanalysis'].parent" + "precipitation[\"reanalysis\"].parent" ] }, { diff --git a/fundamentals/02.1_indexing_Basic.ipynb b/fundamentals/02.1_indexing_Basic.ipynb index ef4f4d39..217c21ab 100644 --- a/fundamentals/02.1_indexing_Basic.ipynb +++ b/fundamentals/02.1_indexing_Basic.ipynb @@ -481,7 +481,7 @@ }, "outputs": [], "source": [ - "ds.sel(time='2013-01-01 06:00')" + "ds.sel(time=\"2013-01-01 06:00\")" ] }, { @@ -499,7 +499,7 @@ }, "outputs": [], "source": [ - "ds.sel(time='2013-01-01')" + "ds.sel(time=\"2013-01-01\")" ] }, { @@ -560,7 +560,7 @@ "outputs": [], "source": [ "# This will return a subset of the dataset corresponding to the entire year of 2013.\n", - "ds.sel(time=slice('2013-01-01', '2013-12-31'))" + "ds.sel(time=slice(\"2013-01-01\", \"2013-12-31\"))" ] }, { @@ -607,7 +607,7 @@ }, "outputs": [], "source": [ - "dates = ['2013-07-09', '2013-10-11', '2013-12-24']\n", + "dates = [\"2013-07-09\", \"2013-10-11\", \"2013-12-24\"]\n", "ds.sel(time=dates)" ] }, diff --git a/fundamentals/03.1_computation_with_xarray.ipynb b/fundamentals/03.1_computation_with_xarray.ipynb index fadc9be6..8ef77a3e 100644 --- a/fundamentals/03.1_computation_with_xarray.ipynb +++ b/fundamentals/03.1_computation_with_xarray.ipynb @@ -24,9 +24,9 @@ "metadata": {}, "outputs": [], "source": [ + "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import xarray as xr\n", - "import matplotlib.pyplot as plt\n", "\n", "# Ask Xarray to not show data values by default\n", "xr.set_options(display_expand_data=False)\n", diff --git a/fundamentals/03.2_groupby_with_xarray.ipynb b/fundamentals/03.2_groupby_with_xarray.ipynb index ab743e9b..fbff6529 100644 --- a/fundamentals/03.2_groupby_with_xarray.ipynb +++ b/fundamentals/03.2_groupby_with_xarray.ipynb @@ -22,9 +22,9 @@ "metadata": {}, "outputs": [], "source": [ + "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import xarray as xr\n", - "import matplotlib.pyplot as plt\n", "\n", "# don't expand data by default\n", "xr.set_options(display_expand_data=False, display_expand_attrs=False)\n", @@ -629,7 +629,7 @@ "from IPython.display import display_html\n", "\n", "grouped = ds.groupby(\"time.year\").mean().sst.sel(lon=300, lat=50)\n", - "resampled = ds.resample(time='Y').mean().sst.sel(lon=300, lat=50)\n", + "resampled = ds.resample(time=\"Y\").mean().sst.sel(lon=300, lat=50)\n", "display_html(grouped)\n", "display_html(resampled)" ] diff --git a/fundamentals/03.3_windowed.ipynb b/fundamentals/03.3_windowed.ipynb index a56494e9..9bdf9644 100644 --- a/fundamentals/03.3_windowed.ipynb +++ b/fundamentals/03.3_windowed.ipynb @@ -25,9 +25,9 @@ "metadata": {}, "outputs": [], "source": [ + "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import xarray as xr\n", - "import matplotlib.pyplot as plt\n", "\n", "np.set_printoptions(threshold=10, edgeitems=2)\n", "xr.set_options(display_expand_data=False)\n", diff --git a/fundamentals/03.4_weighted.ipynb b/fundamentals/03.4_weighted.ipynb index 8f6807e1..c6d49756 100644 --- a/fundamentals/03.4_weighted.ipynb +++ b/fundamentals/03.4_weighted.ipynb @@ -22,9 +22,9 @@ "metadata": {}, "outputs": [], "source": [ + "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import xarray as xr\n", - "import matplotlib.pyplot as plt\n", "\n", "%config InlineBackend.figure_format='retina'" ] diff --git a/intermediate/BiologyDataset.ipynb b/intermediate/BiologyDataset.ipynb index 0c5bccf3..dd46a968 100644 --- a/intermediate/BiologyDataset.ipynb +++ b/intermediate/BiologyDataset.ipynb @@ -49,7 +49,7 @@ "metadata": {}, "outputs": [], "source": [ - "ds['images'].max('z').sel(c='nuclei').plot()" + "ds[\"images\"].max(\"z\").sel(c=\"nuclei\").plot()" ] }, { @@ -59,7 +59,7 @@ "metadata": {}, "outputs": [], "source": [ - "ds['images'].sel(z=9, method='nearest').sel(c='membrane').plot()" + "ds[\"images\"].sel(z=9, method=\"nearest\").sel(c=\"membrane\").plot()" ] }, { @@ -69,8 +69,8 @@ "metadata": {}, "outputs": [], "source": [ - "ds['images'].max('z').sel(c='nuclei').plot()\n", - "ds['mask'].plot.contour(cmap='r')" + "ds[\"images\"].max(\"z\").sel(c=\"nuclei\").plot()\n", + "ds[\"mask\"].plot.contour(cmap=\"r\")" ] }, { @@ -80,7 +80,7 @@ "metadata": {}, "outputs": [], "source": [ - "ds['mask'].plot()" + "ds[\"mask\"].plot()" ] }, { diff --git a/intermediate/computation/01-high-level-computation-patterns.ipynb b/intermediate/computation/01-high-level-computation-patterns.ipynb index b12cbd01..517fb604 100644 --- a/intermediate/computation/01-high-level-computation-patterns.ipynb +++ b/intermediate/computation/01-high-level-computation-patterns.ipynb @@ -118,9 +118,9 @@ }, "outputs": [], "source": [ + "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import xarray as xr\n", - "import matplotlib.pyplot as plt\n", "\n", "# reduce figure size\n", "plt.rcParams[\"figure.dpi\"] = 90\n", diff --git a/intermediate/computation/hierarchical_computation.ipynb b/intermediate/computation/hierarchical_computation.ipynb index 2c73a8d9..1338be88 100644 --- a/intermediate/computation/hierarchical_computation.ipynb +++ b/intermediate/computation/hierarchical_computation.ipynb @@ -20,8 +20,8 @@ "metadata": {}, "outputs": [], "source": [ - "import xarray as xr\n", "import numpy as np\n", + "import xarray as xr\n", "\n", "xr.set_options(keep_attrs=True, display_expand_attrs=False, display_expand_data=False)" ] diff --git a/intermediate/data_cleaning/05.3_ice_velocity.ipynb b/intermediate/data_cleaning/05.3_ice_velocity.ipynb index e54ff918..ca29fc3d 100644 --- a/intermediate/data_cleaning/05.3_ice_velocity.ipynb +++ b/intermediate/data_cleaning/05.3_ice_velocity.ipynb @@ -28,10 +28,11 @@ "metadata": {}, "outputs": [], "source": [ - "import xarray as xr\n", - "import pandas as pd\n", "import os\n", - "import numpy as np" + "\n", + "import numpy as np\n", + "import pandas as pd\n", + "import xarray as xr" ] }, { @@ -41,7 +42,7 @@ "metadata": {}, "outputs": [], "source": [ - "ds = xr.tutorial.open_dataset('ASE_ice_velocity.nc')\n", + "ds = xr.tutorial.open_dataset(\"ASE_ice_velocity.nc\")\n", "ds" ] }, @@ -78,7 +79,7 @@ "metadata": {}, "outputs": [], "source": [ - "ds.attrs['Projection']" + "ds.attrs[\"Projection\"]" ] }, { @@ -96,8 +97,8 @@ "metadata": {}, "outputs": [], "source": [ - "print(ds.dims['ny'])\n", - "print(ds.dims['nx'])" + "print(ds.dims[\"ny\"])\n", + "print(ds.dims[\"nx\"])" ] }, { @@ -126,7 +127,7 @@ "metadata": {}, "outputs": [], "source": [ - "ds = ds.swap_dims({'ny': 'yaxis', 'nx': 'xaxis'})" + "ds = ds.swap_dims({\"ny\": \"yaxis\", \"nx\": \"xaxis\"})" ] }, { @@ -154,7 +155,7 @@ "metadata": {}, "outputs": [], "source": [ - "ds = ds.rename({'xaxis': 'x', 'yaxis': 'y'})" + "ds = ds.rename({\"xaxis\": \"x\", \"yaxis\": \"y\"})" ] }, { @@ -193,9 +194,9 @@ "source": [ "var_ls = list(ds)\n", "\n", - "vx_ls = [var for var in var_ls if 'vx' in var]\n", - "vy_ls = [var for var in var_ls if 'vy' in var]\n", - "err_ls = [var for var in var_ls if 'err' in var]\n", + "vx_ls = [var for var in var_ls if \"vx\" in var]\n", + "vy_ls = [var for var in var_ls if \"vy\" in var]\n", + "err_ls = [var for var in var_ls if \"err\" in var]\n", "\n", "yr_ls = [int(var[-4:]) for var in vx_ls]" ] @@ -235,8 +236,8 @@ "metadata": {}, "outputs": [], "source": [ - "print('Object type: ', type(da_vx_ls))\n", - "print('Object length: ', len(da_vx_ls))\n", + "print(\"Object type: \", type(da_vx_ls))\n", + "print(\"Object length: \", len(da_vx_ls))\n", "da_vx_ls[0]" ] }, @@ -255,7 +256,7 @@ "metadata": {}, "outputs": [], "source": [ - "da_vx_ls = [da_vx_ls[var].expand_dims('time') for var in range(len(da_vx_ls))]" + "da_vx_ls = [da_vx_ls[var].expand_dims(\"time\") for var in range(len(da_vx_ls))]" ] }, { @@ -312,7 +313,7 @@ "metadata": {}, "outputs": [], "source": [ - "da_vx_ls = [da_vx_ls[var].rename('vx') for var in range(len(da_vx_ls))]" + "da_vx_ls = [da_vx_ls[var].rename(\"vx\") for var in range(len(da_vx_ls))]" ] }, { @@ -342,9 +343,9 @@ "metadata": {}, "outputs": [], "source": [ - "da_vy_ls = [ds[var].expand_dims(time=[int(var[-4:])]).rename('vy') for var in vy_ls]\n", + "da_vy_ls = [ds[var].expand_dims(time=[int(var[-4:])]).rename(\"vy\") for var in vy_ls]\n", "\n", - "da_err_ls = [ds[var].expand_dims(time=[int(var[-4:])]).rename('err') for var in err_ls]" + "da_err_ls = [ds[var].expand_dims(time=[int(var[-4:])]).rename(\"err\") for var in err_ls]" ] }, { @@ -362,9 +363,9 @@ "metadata": {}, "outputs": [], "source": [ - "vx_concat = xr.concat(da_vx_ls, dim='time')\n", - "vy_concat = xr.concat(da_vy_ls, dim='time')\n", - "err_concat = xr.concat(da_err_ls, dim='time')\n", + "vx_concat = xr.concat(da_vx_ls, dim=\"time\")\n", + "vy_concat = xr.concat(da_vy_ls, dim=\"time\")\n", + "err_concat = xr.concat(da_err_ls, dim=\"time\")\n", "\n", "ds_merge = xr.merge([vx_concat, vy_concat, err_concat])" ] @@ -394,7 +395,7 @@ "metadata": {}, "outputs": [], "source": [ - "ds_merge['vv'] = np.sqrt((ds_merge.vx**2) + (ds_merge.vy**2))" + "ds_merge[\"vv\"] = np.sqrt((ds_merge.vx**2) + (ds_merge.vy**2))" ] }, { @@ -468,7 +469,7 @@ "metadata": {}, "outputs": [], "source": [ - "ds_merge['vx'].sel(time=1996, drop=True).equals(ds.vx1996)" + "ds_merge[\"vx\"].sel(time=1996, drop=True).equals(ds.vx1996)" ] } ], diff --git a/intermediate/datastructures-intermediate.ipynb b/intermediate/datastructures-intermediate.ipynb index 1cd76d34..bf58ee3b 100644 --- a/intermediate/datastructures-intermediate.ipynb +++ b/intermediate/datastructures-intermediate.ipynb @@ -364,11 +364,11 @@ "def air_as_dictionary():\n", " ds = xr.tutorial.open_dataset(\"air_temperature\")\n", " return {\n", - " 'lat': ds['lat'].values,\n", - " 'lon': ds['lon'].values,\n", - " 'attrs': ds.attrs,\n", - " 'time': ds['time'].values,\n", - " 'air-temp': ds['air'].values,\n", + " \"lat\": ds[\"lat\"].values,\n", + " \"lon\": ds[\"lon\"].values,\n", + " \"attrs\": ds.attrs,\n", + " \"time\": ds[\"time\"].values,\n", + " \"air-temp\": ds[\"air\"].values,\n", " }\n", "\n", "\n", @@ -605,9 +605,9 @@ "metadata": {}, "outputs": [], "source": [ - "tree = xr.tutorial.open_datatree('precipitation.nc4')\n", - "reanalysis = xr.Dataset(tree['observed'])\n", - "observed = xr.Dataset(tree['reanalysis'])" + "tree = xr.tutorial.open_datatree(\"precipitation.nc4\")\n", + "reanalysis = xr.Dataset(tree[\"observed\"])\n", + "observed = xr.Dataset(tree[\"reanalysis\"])" ] }, { diff --git a/intermediate/indexing/advanced-indexing.ipynb b/intermediate/indexing/advanced-indexing.ipynb index c83a2bf7..b6ea47cb 100644 --- a/intermediate/indexing/advanced-indexing.ipynb +++ b/intermediate/indexing/advanced-indexing.ipynb @@ -353,7 +353,7 @@ "metadata": {}, "outputs": [], "source": [ - "da_air.sel(lat=lat_points, lon=lon_points, method=\"nearest\").plot(x='time', hue='points');" + "da_air.sel(lat=lat_points, lon=lon_points, method=\"nearest\").plot(x=\"time\", hue=\"points\");" ] }, { diff --git a/intermediate/indexing/boolean-masking-indexing.ipynb b/intermediate/indexing/boolean-masking-indexing.ipynb index 67aeced7..6432b86a 100644 --- a/intermediate/indexing/boolean-masking-indexing.ipynb +++ b/intermediate/indexing/boolean-masking-indexing.ipynb @@ -35,10 +35,10 @@ "outputs": [], "source": [ "import cartopy.crs as ccrs\n", + "import matplotlib as mpl\n", "import numpy as np\n", "import xarray as xr\n", "from matplotlib import pyplot as plt\n", - "import matplotlib as mpl\n", "\n", "xr.set_options(display_expand_attrs=False)\n", "np.set_printoptions(threshold=10, edgeitems=2)" diff --git a/intermediate/intro-to-zarr.ipynb b/intermediate/intro-to-zarr.ipynb index e991cf4f..911ba391 100644 --- a/intermediate/intro-to-zarr.ipynb +++ b/intermediate/intro-to-zarr.ipynb @@ -66,17 +66,18 @@ "metadata": {}, "outputs": [], "source": [ - "import zarr\n", "import pathlib\n", "import shutil\n", "\n", + "import zarr\n", + "\n", "# Ensure we start with a clean directory for the tutorial\n", - "datadir = pathlib.Path('../data/zarr-tutorial')\n", + "datadir = pathlib.Path(\"../data/zarr-tutorial\")\n", "if datadir.exists():\n", " shutil.rmtree(datadir)\n", "\n", - "output = datadir / 'test.zarr'\n", - "z = zarr.create_array(shape=(40, 50), chunks=(10, 10), dtype='f8', store=output)\n", + "output = datadir / \"test.zarr\"\n", + "z = zarr.create_array(shape=(40, 50), chunks=(10, 10), dtype=\"f8\", store=output)\n", "z" ] }, @@ -165,8 +166,8 @@ "metadata": {}, "outputs": [], "source": [ - "z.attrs['units'] = 'm/s'\n", - "z.attrs['standard_name'] = 'wind_speed'\n", + "z.attrs[\"units\"] = \"m/s\"\n", + "z.attrs[\"standard_name\"] = \"wind_speed\"\n", "print(dict(z.attrs))" ] }, @@ -245,10 +246,10 @@ "source": [ "store = zarr.storage.MemoryStore()\n", "root = zarr.create_group(store=store)\n", - "temp = root.create_group('temp')\n", - "precip = root.create_group('precip')\n", - "t2m = temp.create_array('t2m', shape=(100, 100), chunks=(10, 10), dtype='i4')\n", - "prcp = precip.create_array('prcp', shape=(1000, 1000), chunks=(10, 10), dtype='i4')\n", + "temp = root.create_group(\"temp\")\n", + "precip = root.create_group(\"precip\")\n", + "t2m = temp.create_array(\"t2m\", shape=(100, 100), chunks=(10, 10), dtype=\"i4\")\n", + "prcp = precip.create_array(\"prcp\", shape=(1000, 1000), chunks=(10, 10), dtype=\"i4\")\n", "root.tree()" ] }, @@ -268,8 +269,8 @@ "metadata": {}, "outputs": [], "source": [ - "display(root['temp'])\n", - "root['temp/t2m'][:, 3]" + "display(root[\"temp\"])\n", + "root[\"temp/t2m\"][:, 3]" ] }, { @@ -346,8 +347,8 @@ "metadata": {}, "outputs": [], "source": [ - "output = datadir / 'c.zarr'\n", - "c = zarr.create_array(shape=(200, 200, 200), chunks=(1, 200, 200), dtype='f8', store=output)\n", + "output = datadir / \"c.zarr\"\n", + "c = zarr.create_array(shape=(200, 200, 200), chunks=(1, 200, 200), dtype=\"f8\", store=output)\n", "c[:] = np.random.randn(*c.shape)" ] }, @@ -368,8 +369,8 @@ "metadata": {}, "outputs": [], "source": [ - "output = datadir / 'd.zarr'\n", - "d = zarr.create_array(shape=(200, 200, 200), chunks=(200, 200, 1), dtype='f8', store=output)\n", + "output = datadir / \"d.zarr\"\n", + "d = zarr.create_array(shape=(200, 200, 200), chunks=(200, 200, 1), dtype=\"f8\", store=output)\n", "d[:] = np.random.randn(*d.shape)" ] }, @@ -424,7 +425,7 @@ " shape=(10000, 10000, 1000),\n", " chunks=(100, 100, 100),\n", " shards=(1000, 1000, 1000),\n", - " dtype='uint8',\n", + " dtype=\"uint8\",\n", ")\n", "\n", "z6.info" @@ -526,9 +527,9 @@ "source": [ "store = zarr.storage.MemoryStore()\n", "group = zarr.create_group(store=store)\n", - "group.create_array(shape=(1,), name='a', dtype='float64')\n", - "group.create_array(shape=(2, 2), name='b', dtype='float64')\n", - "group.create_array(shape=(3, 3, 3), name='c', dtype='float64')\n", + "group.create_array(shape=(1,), name=\"a\", dtype=\"float64\")\n", + "group.create_array(shape=(2, 2), name=\"b\", dtype=\"float64\")\n", + "group.create_array(shape=(3, 3, 3), name=\"c\", dtype=\"float64\")\n", "zarr.consolidate_metadata(store)" ] }, @@ -616,9 +617,9 @@ "source": [ "import xarray as xr\n", "\n", - "store = 'https://ncsa.osn.xsede.org/Pangeo/pangeo-forge/gpcp-feedstock/gpcp.zarr'\n", + "store = \"https://ncsa.osn.xsede.org/Pangeo/pangeo-forge/gpcp-feedstock/gpcp.zarr\"\n", "\n", - "ds = xr.open_dataset(store, engine='zarr', chunks={}, consolidated=True)\n", + "ds = xr.open_dataset(store, engine=\"zarr\", chunks={}, consolidated=True)\n", "ds" ] }, diff --git a/intermediate/remote_data/remote-data.ipynb b/intermediate/remote_data/remote-data.ipynb index 7765a386..df1f0952 100644 --- a/intermediate/remote_data/remote-data.ipynb +++ b/intermediate/remote_data/remote-data.ipynb @@ -55,6 +55,7 @@ "outputs": [], "source": [ "import sys\n", + "\n", "from IPython.display import Code\n", "\n", "tracing_output = []\n", @@ -62,7 +63,7 @@ "\n", "\n", "def trace_calls(frame, event, arg):\n", - " if event == 'call':\n", + " if event == \"call\":\n", " code = frame.f_code\n", " func_name = code.co_name\n", " func_file = code.co_filename.split(\"/site-packages/\")[-1]\n", @@ -78,7 +79,7 @@ "sys.settrace(None)\n", "\n", "# Print the trace with some syntax highlighting\n", - "Code(\" \\n\".join(tracing_output[0:10]), language='python')" + "Code(\" \\n\".join(tracing_output[0:10]), language=\"python\")" ] }, { @@ -110,7 +111,7 @@ "sys.settrace(None)\n", "\n", "# Print the top 10 calls to public methods\n", - "Code(\" \\n\".join(tracing_output[0:10]), language='python')" + "Code(\" \\n\".join(tracing_output[0:10]), language=\"python\")" ] }, { @@ -249,7 +250,7 @@ "\n", "uri = \"https://its-live-data.s3-us-west-2.amazonaws.com/test-space/sample-data/sst.mnmean.nc\"\n", "# we prepend the cache type to the URI, this is called protocol chaining in fsspec-speak\n", - "file = fsspec.open_local(f\"simplecache::{uri}\", simplecache={'cache_storage': '/tmp/fsspec_cache'})\n", + "file = fsspec.open_local(f\"simplecache::{uri}\", simplecache={\"cache_storage\": \"/tmp/fsspec_cache\"})\n", "\n", "ds = xr.open_dataset(file, engine=\"netcdf4\")\n", "ds" @@ -277,7 +278,7 @@ "%%time\n", "uri = \"https://its-live-data.s3-us-west-2.amazonaws.com/test-space/sample-data/sst.mnmean.nc\"\n", "\n", - "fs = fsspec.filesystem('http')\n", + "fs = fsspec.filesystem(\"http\")\n", "\n", "fsspec_caching = {\n", " \"cache_type\": \"blockcache\", # block cache stores blocks of fixed size and uses eviction using a LRU strategy.\n", @@ -316,7 +317,7 @@ "uri = \"s3://its-live-data/test-space/sample-data/sst.mnmean.nc\"\n", "\n", "# If we need to pass credentials to our remote storage we can do it here, in this case this is a public bucket\n", - "fs = fsspec.filesystem('s3', anon=True)\n", + "fs = fsspec.filesystem(\"s3\", anon=True)\n", "\n", "fsspec_caching = {\n", " \"cache_type\": \"blockcache\", # block cache stores blocks of fixed size and uses eviction using a LRU strategy.\n", diff --git a/intermediate/xarray_and_dask.ipynb b/intermediate/xarray_and_dask.ipynb index b2f5c775..aff1c790 100644 --- a/intermediate/xarray_and_dask.ipynb +++ b/intermediate/xarray_and_dask.ipynb @@ -412,11 +412,11 @@ "metadata": {}, "outputs": [], "source": [ - "from dask.distributed import Client\n", + "import os\n", "\n", "# This piece of code is just for a correct dashboard link mybinder.org or other JupyterHub demos\n", "import dask\n", - "import os\n", + "from dask.distributed import Client\n", "\n", "# if os.environ.get('JUPYTERHUB_USER'):\n", "# dask.config.set(**{\"distributed.dashboard.link\": \"/user/{JUPYTERHUB_USER}/proxy/{port}/status\"})\n", diff --git a/intermediate/xarray_ecosystem.ipynb b/intermediate/xarray_ecosystem.ipynb index 0fc6a73f..d455b486 100644 --- a/intermediate/xarray_ecosystem.ipynb +++ b/intermediate/xarray_ecosystem.ipynb @@ -45,8 +45,8 @@ "metadata": {}, "outputs": [], "source": [ - "import xarray as xr\n", - "import numpy as np" + "import numpy as np\n", + "import xarray as xr" ] }, { @@ -123,7 +123,7 @@ "metadata": {}, "outputs": [], "source": [ - "ds['air'].isel(time=1).hvplot(cmap=\"fire\")" + "ds[\"air\"].isel(time=1).hvplot(cmap=\"fire\")" ] }, { @@ -175,8 +175,8 @@ "metadata": {}, "outputs": [], "source": [ - "url = 'https://sentinel-s1-rtc-indigo.s3.us-west-2.amazonaws.com/tiles/RTC/1/IW/10/U/CU/2017/S1A_20170101_10UCU_ASC/Gamma0_VV.tif'\n", - "da = xr.open_dataarray(url, engine='rasterio', open_kwargs={\"overview_level\": 2})\n", + "url = \"https://sentinel-s1-rtc-indigo.s3.us-west-2.amazonaws.com/tiles/RTC/1/IW/10/U/CU/2017/S1A_20170101_10UCU_ASC/Gamma0_VV.tif\"\n", + "da = xr.open_dataarray(url, engine=\"rasterio\", open_kwargs={\"overview_level\": 2})\n", "da" ] }, @@ -211,7 +211,7 @@ "metadata": {}, "outputs": [], "source": [ - "da_lonlat = da.rio.reproject('epsg:4326')\n", + "da_lonlat = da.rio.reproject(\"epsg:4326\")\n", "da_lonlat" ] }, @@ -232,10 +232,10 @@ "import panel as pn\n", "\n", "img1 = da.sel(band=1).hvplot.image(\n", - " x='x', y='y', rasterize=True, cmap='gray', clim=(0, 0.5), title='UTM'\n", + " x=\"x\", y=\"y\", rasterize=True, cmap=\"gray\", clim=(0, 0.5), title=\"UTM\"\n", ")\n", "img2 = da_lonlat.sel(band=1).hvplot.image(\n", - " rasterize=True, cmap='gray', clim=(0, 0.5), title='LON/LAT'\n", + " rasterize=True, cmap=\"gray\", clim=(0, 0.5), title=\"LON/LAT\"\n", ")\n", "\n", "pn.Column(img1, img2)" @@ -545,7 +545,7 @@ "metadata": {}, "outputs": [], "source": [ - "ds.air.attrs['units']" + "ds.air.attrs[\"units\"]" ] }, { diff --git a/overview/xarray-in-45-min.ipynb b/overview/xarray-in-45-min.ipynb index 2b8c3616..2566262d 100644 --- a/overview/xarray-in-45-min.ipynb +++ b/overview/xarray-in-45-min.ipynb @@ -1113,7 +1113,7 @@ "metadata": {}, "outputs": [], "source": [ - "ds.air.hvplot(groupby=\"time\", clim=(270, 300), widget_location='bottom')" + "ds.air.hvplot(groupby=\"time\", clim=(270, 300), widget_location=\"bottom\")" ] }, { From 935322bee55f8f5869626accd0ae4faed149cd07 Mon Sep 17 00:00:00 2001 From: Justus Magin Date: Tue, 9 Jun 2026 23:39:07 +0200 Subject: [PATCH 4/4] ignore the remaining failures --- pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index e8a3696c..fd0c87ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,12 @@ ignore = [ "E722", # do not use bare except "E402", # module level import not at top of file "E731", # do not assign a lambda expression, use a def + # to remove fix eventually + "F401", # unused import + "F811", # redefinition of name + "B006", # mutable argument defaults + "B007", # unused loop control variable + "B905", # zip without explicit strict parameter ] fixable = ["I"]