Skip to content

Commit 98dd222

Browse files
committed
Remove file linting exclusions and Fix lint issues
This stops excluding the Jumper notebook and restart files (now removed from repo) from linting and fixes linting issues. Adds jupyter files types to pre-commit ruff hook so that notebooks are formatted.
1 parent c916713 commit 98dd222

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ repos:
1111
rev: v0.9.6
1212
hooks:
1313
- id: ruff-format
14-
types_or: [ python ]
14+
types_or: [ python, jupyter ]

Notebooks/Jumper.ipynb

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
18-
"import os\n",
1918
"import pickle\n",
2019
"import random\n",
2120
"from importlib.resources import files\n",
2221
"from pathlib import Path\n",
2322
"\n",
24-
"import matplotlib.pyplot as plt\n",
2523
"import numpy as np\n",
2624
"import pandas as pd\n",
2725
"\n",
@@ -30,13 +28,6 @@
3028
")\n",
3129
"from nemo_spinup_forecast.forecast import Predictions, Simulation, load_ts\n",
3230
"from nemo_spinup_forecast.forecast_method import forecast_techniques\n",
33-
"from nemo_spinup_forecast.utils import (\n",
34-
" create_run_dir,\n",
35-
" get_dr_technique,\n",
36-
" get_forecast_technique,\n",
37-
" get_ocean_term,\n",
38-
")\n",
39-
"\n",
4031
"from nemo_spinup_forecast.plotting_utils import (\n",
4132
" plot_bar_with_errors,\n",
4233
" plot_component_timeseries,\n",
@@ -48,6 +39,12 @@
4839
" plot_rmse_depth_profile,\n",
4940
" plot_rmse_maps,\n",
5041
" plot_simulation_snapshots,\n",
42+
")\n",
43+
"from nemo_spinup_forecast.utils import (\n",
44+
" create_run_dir,\n",
45+
" get_dr_technique,\n",
46+
" get_forecast_technique,\n",
47+
" get_ocean_term,\n",
5148
")"
5249
]
5350
},
@@ -198,7 +195,7 @@
198195
"simus = [simu_zos, simu_so, simu_thetao]\n",
199196
"# names = [\"zos\",\"so\",\"thetao\"]\n",
200197
"names = [ssh_term, so_term, thetao_term]\n",
201-
"\n",
198+
"print(simu_so.simulation[0, 0], simu_so.simulation.shape, simu_so.simulation[0, 0].shape)\n",
202199
"plot_simulation_snapshots(simus, names)"
203200
]
204201
},
@@ -300,7 +297,6 @@
300297
"metadata": {},
301298
"outputs": [],
302299
"source": [
303-
"rmseV_zos\n",
304300
"values = [rmseV_zos, rmseV_so.T, rmseV_thetao.T]\n",
305301
"maps = [rmseM_zos, rmseM_so, rmseM_thetao]\n",
306302
"names = [ssh_term, so_term, thetao_term]\n",
@@ -435,15 +431,15 @@
435431
"import random\n",
436432
"\n",
437433
"random.seed(100)\n",
438-
"comp, train_len, steps = 1, len(ts_zos), steps\n",
439-
"print(len(ts_zos))\n",
434+
"# steps unchanged\n",
435+
"comp, train_len = 1, len(ts_zos)\n",
440436
"\n",
441437
"hat_zos, std_zos, metrics_zos = ts_zos.forecast_single_series(comp, train_len, steps)\n",
442438
"hat_so, std_so, metrics_so = ts_so.forecast_single_series(comp, train_len, steps)\n",
443439
"hat_thetao, std_thetao, metrics_thetao = ts_thetao.forecast_single_series(\n",
444440
" comp, train_len, steps\n",
445441
")\n",
446-
"\n",
442+
"print(\"hat_zos shape:\", hat_zos.shape)\n",
447443
"ts_zos.show(comp, hat_zos, std_zos, train_len)\n",
448444
"ts_so.show(comp, hat_so, std_so, train_len, color=\"darkgreen\")\n",
449445
"ts_thetao.show(comp, hat_thetao, std_thetao, train_len, color=\"darkred\")"
@@ -479,7 +475,8 @@
479475
"outputs": [],
480476
"source": [
481477
"n = np.shape(ts_zos.info[\"ts\"])[1]\n",
482-
"predictions, n, info = hat_zos, n, ts_zos.info\n",
478+
"# n unchanged\n",
479+
"predictions, info = hat_zos, ts_zos.info\n",
483480
"\n",
484481
"predictions_zos = simu_zos.reconstruct(hat_zos, n, ts_zos.info)\n",
485482
"\n",
@@ -550,7 +547,6 @@
550547
},
551548
"outputs": [],
552549
"source": [
553-
"import matplotlib.pyplot as plt\n",
554550
"import numpy as np\n",
555551
"import xarray as xr\n",
556552
"\n",
@@ -581,7 +577,7 @@
581577
"id_, start2, end2 = \"106\", start, end + steps # start, end + steps\n",
582578
"\n",
583579
"\n",
584-
"ye = False\n",
580+
"ye = True\n",
585581
"\n",
586582
"ref_zos = Simulation(\n",
587583
" path=data_path,\n",
@@ -656,6 +652,11 @@
656652
"source": [
657653
"print(ref_so.simulation[end:].shape)\n",
658654
"\n",
655+
"print(\"pred_so shape:\")\n",
656+
"print(pred_so.shape)\n",
657+
"print(\"ref_so shape:\")\n",
658+
"print(ref_so.simulation.shape)\n",
659+
"\n",
659660
"err_so = np.abs((ref_so.simulation - pred_so))\n",
660661
"err_thetao = np.abs((ref_thetao.simulation - pred_thetao))\n",
661662
"err_zos = np.abs((ref_zos.simulation - pred_zos))\n",

ruff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extend-select = ["D417"]
2424
# Ignore D105 (Missing docstring in magic method)
2525
ignore = ["SIM108", "RUF002", "PLR0913", "PLR2004", "D100", "D104", "D105"]
2626

27-
exclude = ["standalone/**", "src/nemo_spinup_forecast/optimization.py", "main_restart.py", "Notebooks/Restart.ipynb", "Notebooks/Jumper.ipynb"]
27+
exclude = ["src/nemo_spinup_forecast/density.py"]
2828

2929
[lint.per-file-ignores]
3030
"tests/**/*.py" = ["S101"]

0 commit comments

Comments
 (0)