Skip to content

Commit

Permalink
Merge pull request #73 from ocefpaf/modernize
Browse files Browse the repository at this point in the history
Modernize
  • Loading branch information
ocefpaf authored Oct 22, 2024
2 parents dcbf42a + 1840f1f commit d1f1e36
Show file tree
Hide file tree
Showing 16 changed files with 249 additions and 210 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
os: [ windows-latest, ubuntu-latest, macos-latest ]
fail-fast: false

steps:
Expand All @@ -23,7 +23,7 @@ jobs:
environment-name: TEST
init-shell: bash
create-args: >-
python=3 pip
python=${{ matrix.python-version }} pip
--file requirements.txt
--file requirements-dev.txt
--channel conda-forge
Expand Down
58 changes: 27 additions & 31 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,6 @@ repos:
- id: file-contents-sorter
files: requirements-dev.txt

- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
exclude: docs/source/conf.py
args: [--max-line-length=105]

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
additional_dependencies: [toml]
args: ["--profile", "black", "--filter-files"]

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
language_version: python3

- repo: https://github.com/keewis/blackdoc
rev: v0.3.9
hooks:
Expand All @@ -56,23 +36,39 @@ repos:
args:
- --quiet-level=2

- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
hooks:
- id: pyupgrade
args:
- --py36-plus

- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
hooks:
- id: add-trailing-comma

- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.8.7
hooks:
- id: nbqa-check-ast
- id: nbqa-black
- id: nbqa-ruff
args: [
--fix,
--config=ruff.toml,
]

- repo: https://github.com/bdice/nb-strip-paths
rev: v0.1.0
hooks:
- id: nb-strip-paths

- repo: https://github.com/tox-dev/pyproject-fmt
rev: 2.4.3
hooks:
- id: pydocstyle
exclude: ^(docs|setup.py)
- id: pyproject-fmt

ci:
autofix_commit_msg: |
Expand Down
17 changes: 11 additions & 6 deletions notebooks/ocean_s_coordinate.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"outputs": [],
"source": [
"from netCDF4 import Dataset\n",
"\n",
"from odvc.parse_formula_terms import get_formula_terms_variables\n",
"\n",
"nc = Dataset(url)\n",
Expand Down Expand Up @@ -117,8 +118,12 @@
"metadata": {},
"outputs": [],
"source": [
"salt = nc.get_variables_by_attributes(long_name=\"averaged salinity\")[0]\n",
"temp = nc.get_variables_by_attributes(long_name=\"averaged potential temperature\")[0]\n",
"salt = nc.get_variables_by_attributes(\n",
" long_name=\"averaged salinity\",\n",
")[0]\n",
"temp = nc.get_variables_by_attributes(\n",
" long_name=\"averaged potential temperature\",\n",
")[0]\n",
"\n",
"s = salt[-1, :, 45, 137]\n",
"t = temp[-1, :, 45, 137]\n",
Expand All @@ -134,7 +139,7 @@
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import mpl_toolkits.axisartist as AA\n",
"from mpl_toolkits import axisartist\n",
"from mpl_toolkits.axes_grid1 import host_subplot\n",
"\n",
"\n",
Expand All @@ -145,7 +150,7 @@
"\n",
"fig = plt.figure(figsize=(6, 9))\n",
"fig.subplots_adjust(bottom=0.1, top=0.85)\n",
"ax0 = host_subplot(111, axes_class=AA.Axes)\n",
"ax0 = host_subplot(111, axes_class=axisartist.Axes)\n",
"\n",
"ax0.invert_yaxis()\n",
"ax1 = ax0.twiny()\n",
Expand All @@ -163,7 +168,7 @@
"ax0.set_xlabel(\"Temperature (\\xb0C)\")\n",
"ax1.set_xlabel(r\"Salinity (g kg$^{-1}$)\")\n",
"\n",
"kw = dict(linewidth=2.5)\n",
"kw = {\"linewidth\": 2.5}\n",
"(l0,) = ax0.plot(t, -p, **kw)\n",
"(l1,) = ax1.plot(s, -p, **kw)\n",
"\n",
Expand Down Expand Up @@ -191,7 +196,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
28 changes: 16 additions & 12 deletions notebooks/ocean_s_coordinate_g1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"outputs": [],
"source": [
"from netCDF4 import Dataset\n",
"\n",
"from odvc.parse_formula_terms import get_formula_terms_variables\n",
"\n",
"nc = Dataset(url)\n",
Expand Down Expand Up @@ -102,7 +103,11 @@
"from odvc import ocean_s_coordinate_g1\n",
"\n",
"z = ocean_s_coordinate_g1(\n",
" arrays[\"s\"], arrays[\"C\"], arrays[\"eta\"], arrays[\"depth\"], arrays[\"depth_c\"]\n",
" arrays[\"s\"],\n",
" arrays[\"C\"],\n",
" arrays[\"eta\"],\n",
" arrays[\"depth\"],\n",
" arrays[\"depth_c\"],\n",
")\n",
"\n",
"print(z.shape)"
Expand All @@ -114,10 +119,12 @@
"metadata": {},
"outputs": [],
"source": [
"salt = nc.get_variables_by_attributes(standard_name=\"sea_water_salinity\")[0]\n",
"temp = nc.get_variables_by_attributes(standard_name=\"sea_water_potential_temperature\")[\n",
" 0\n",
"]\n",
"salt = nc.get_variables_by_attributes(\n",
" standard_name=\"sea_water_salinity\",\n",
")[0]\n",
"temp = nc.get_variables_by_attributes(\n",
" standard_name=\"sea_water_potential_temperature\",\n",
")[0]\n",
"\n",
"s = salt[-1, :, 5, 364]\n",
"t = temp[-1, :, 5, 364]\n",
Expand All @@ -133,12 +140,9 @@
"%matplotlib inline\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import mpl_toolkits.axisartist as AA\n",
"import seaborn\n",
"from mpl_toolkits import axisartist\n",
"from mpl_toolkits.axes_grid1 import host_subplot\n",
"\n",
"seaborn.set(style=\"ticks\")\n",
"\n",
"\n",
"def adjust_xlim(ax, offset):\n",
" x1, x2 = ax.get_xlim()\n",
Expand All @@ -147,7 +151,7 @@
"\n",
"fig = plt.figure(figsize=(6, 9))\n",
"fig.subplots_adjust(bottom=0.1, top=0.85)\n",
"ax0 = host_subplot(111, axes_class=AA.Axes)\n",
"ax0 = host_subplot(111, axes_class=axisartist.Axes)\n",
"\n",
"ax0.invert_yaxis()\n",
"ax1 = ax0.twiny()\n",
Expand All @@ -165,7 +169,7 @@
"ax0.set_xlabel(\"Temperature (\\xb0C)\")\n",
"ax1.set_xlabel(r\"Salinity (g kg$^{-1}$)\")\n",
"\n",
"kw = dict(linewidth=2.5)\n",
"kw = {\"linewidth\": 2.5}\n",
"(l0,) = ax0.plot(t, -p, **kw)\n",
"(l1,) = ax1.plot(s, -p, **kw)\n",
"\n",
Expand Down Expand Up @@ -193,7 +197,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
15 changes: 10 additions & 5 deletions notebooks/ocean_s_coordinate_g2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"outputs": [],
"source": [
"from netCDF4 import Dataset\n",
"\n",
"from odvc.parse_formula_terms import get_formula_terms_variables\n",
"\n",
"nc = Dataset(url)\n",
Expand Down Expand Up @@ -103,7 +104,11 @@
"from odvc import ocean_s_coordinate_g1\n",
"\n",
"z = ocean_s_coordinate_g1(\n",
" arrays[\"s\"], arrays[\"C\"], arrays[\"eta\"], arrays[\"depth\"], arrays[\"depth_c\"]\n",
" arrays[\"s\"],\n",
" arrays[\"C\"],\n",
" arrays[\"eta\"],\n",
" arrays[\"depth\"],\n",
" arrays[\"depth_c\"],\n",
")\n",
"\n",
"print(z.shape)"
Expand All @@ -130,7 +135,7 @@
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import mpl_toolkits.axisartist as AA\n",
"from mpl_toolkits import axisartist\n",
"from mpl_toolkits.axes_grid1 import host_subplot\n",
"\n",
"\n",
Expand All @@ -141,7 +146,7 @@
"\n",
"fig = plt.figure(figsize=(6, 9))\n",
"fig.subplots_adjust(bottom=0.1, top=0.85)\n",
"ax0 = host_subplot(111, axes_class=AA.Axes)\n",
"ax0 = host_subplot(111, axes_class=axisartist.Axes)\n",
"\n",
"ax0.invert_yaxis()\n",
"ax1 = ax0.twiny()\n",
Expand All @@ -159,7 +164,7 @@
"ax0.set_xlabel(\"Temperature (\\xb0C)\")\n",
"ax1.set_xlabel(r\"Salinity (g kg$^{-1}$)\")\n",
"\n",
"kw = dict(linewidth=2.5)\n",
"kw = {\"linewidth\": 2.5}\n",
"(l0,) = ax0.plot(t, -p, **kw)\n",
"(l1,) = ax1.plot(s, -p, **kw)\n",
"\n",
Expand Down Expand Up @@ -187,7 +192,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
19 changes: 11 additions & 8 deletions notebooks/ocean_sigma_coordinate-FVCOM.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"outputs": [],
"source": [
"from netCDF4 import Dataset\n",
"\n",
"from odvc.parse_formula_terms import get_formula_terms_variables\n",
"\n",
"nc = Dataset(url)\n",
Expand Down Expand Up @@ -103,10 +104,12 @@
"metadata": {},
"outputs": [],
"source": [
"salt = nc.get_variables_by_attributes(standard_name=\"sea_water_salinity\")[0]\n",
"temp = nc.get_variables_by_attributes(standard_name=\"sea_water_potential_temperature\")[\n",
" 0\n",
"]\n",
"salt = nc.get_variables_by_attributes(\n",
" standard_name=\"sea_water_salinity\",\n",
")[0]\n",
"temp = nc.get_variables_by_attributes(\n",
" standard_name=\"sea_water_potential_temperature\",\n",
")[0]\n",
"\n",
"s = salt[-1, :, 175]\n",
"t = temp[-1, :, 175]\n",
Expand All @@ -120,7 +123,7 @@
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import mpl_toolkits.axisartist as AA\n",
"from mpl_toolkits import axisartist\n",
"from mpl_toolkits.axes_grid1 import host_subplot\n",
"\n",
"\n",
Expand All @@ -131,7 +134,7 @@
"\n",
"fig = plt.figure(figsize=(6, 9))\n",
"fig.subplots_adjust(bottom=0.1, top=0.85)\n",
"ax0 = host_subplot(111, axes_class=AA.Axes)\n",
"ax0 = host_subplot(111, axes_class=axisartist.Axes)\n",
"\n",
"ax0.invert_yaxis()\n",
"ax1 = ax0.twiny()\n",
Expand All @@ -149,7 +152,7 @@
"ax0.set_xlabel(\"Temperature (\\xb0C)\")\n",
"ax1.set_xlabel(r\"Salinity (g kg$^{-1}$)\")\n",
"\n",
"kw = dict(linewidth=2.5)\n",
"kw = {\"linewidth\": 2.5}\n",
"(l0,) = ax0.plot(t, -p, **kw)\n",
"(l1,) = ax1.plot(s, -p, **kw)\n",
"\n",
Expand Down Expand Up @@ -177,7 +180,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit d1f1e36

Please sign in to comment.